Skip to content

Commit

Permalink
perf: ⚡ use ESM only
Browse files Browse the repository at this point in the history
Inflint now requires ESM module to support the community to change CJS
to ESM
  • Loading branch information
tal-rofe committed Apr 14, 2023
1 parent 185245d commit 45a06ea
Show file tree
Hide file tree
Showing 71 changed files with 1,766 additions and 1,376 deletions.
3 changes: 1 addition & 2 deletions .depcheckrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
"ts-loader",
"ts-node",
"rimraf"
],
"skipMissing": true
]
}
12 changes: 1 addition & 11 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
.eslintrc.js
.prettierrc.js
commitlint.config.js
lint-staged.config.js
release.config.js
jest.config.js
czvinyl.config.ts
webpack.config.ts
inflint.config.ts
.eslintrc.cjs
dist
scripts
bin
49 changes: 41 additions & 8 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module.exports = {
root: true,
env: {
node: true,
jest: true,
},
env: { node: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
Expand All @@ -12,13 +9,15 @@ module.exports = {
],
parserOptions: {
ecmaVersion: 12,
project: 'tsconfig.eslint.json',
sourceType: 'module',
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname,
extraFileExtensions: ['.cjs'],
},
plugins: ['@typescript-eslint', 'unused-imports', 'node', 'import'],
plugins: ['@typescript-eslint', 'unused-imports', 'node', 'import', 'deprecation', 'unicorn'],
rules: {
'max-lines': ['error', { max: 200, skipBlankLines: true, skipComments: true }],
'indent': ['error', 'tab'],
'indent': ['error', 'tab', { SwitchCase: 1 }],
'quotes': ['error', 'single', { avoidEscape: true }],
'semi': ['error', 'always'],
'no-empty': [
Expand All @@ -44,7 +43,6 @@ module.exports = {
'no-eval': 'error',
'no-implicit-globals': 'error',
'no-useless-call': 'error',
'no-useless-escape': 'off',
'curly': ['error', 'all'],
'padding-line-between-statements': [
'error',
Expand Down Expand Up @@ -121,6 +119,13 @@ module.exports = {
'@typescript-eslint/ban-tslint-comment': ['error'],
'@typescript-eslint/no-require-imports': ['error'],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/consistent-type-imports': ['error'],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{ accessbility: 'explicit', overrides: { constructors: 'off' } },
],

'unused-imports/no-unused-imports': 'error',

Expand Down Expand Up @@ -157,5 +162,33 @@ module.exports = {
],

'node/no-sync': 'error',

'deprecation/deprecation': 'error',

'unicorn/catch-error-name': 'error',
'unicorn/new-for-builtins': 'error',
'unicorn/prefer-node-protocol': 'error',
'unicorn/no-new-buffer': 'error',
'unicorn/throw-new-error': 'error',
'unicorn/text-encoding-identifier-case': 'error',
'unicorn/switch-case-braces': 'error',
'unicorn/prefer-module': 'error',
'unicorn/no-empty-file': 'error',
},
overrides: [
{
files: ['./scripts/onboarding.js', './bin/inflint.js'],
rules: {
'no-console': 'off',
},
},
{
files: ['./**/*.cjs'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-require-imports': 'off',
'import/no-commonjs': 'off',
},
},
],
};
9 changes: 6 additions & 3 deletions .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: Lint Commit Messages

on: [pull_request]

jobs:
commitlint:
name: Commitlint
permissions:
contents: read
pull-requests: read

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: wagoid/commitlint-github-action@v4
- uses: wagoid/commitlint-github-action@v5
66 changes: 33 additions & 33 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,91 +9,91 @@ permissions:

jobs:
depcheck:
name: Testing Depcheck
name: Depcheck

runs-on: [self-hosted, Linux, X64, integration]
runs-on: ubuntu-latest
steps:
- name: Setup Node environment
uses: Exlint/[email protected].4
uses: Exlint/[email protected].6
with:
node-version: 18.13.0
node-version: 18.15.0
package-manager: pnpm
package-manager-version: 7.26.3
package-manager-version: 8.1.0

- name: Test Depcheck
run: pnpm depcheck

inflint:
name: Testing Inflint
name: Inflint

runs-on: [self-hosted, Linux, X64, integration]
runs-on: ubuntu-latest
steps:
- name: Setup Node environment
uses: Exlint/[email protected].4
uses: Exlint/[email protected].6
with:
node-version: 18.13.0
node-version: 18.15.0
package-manager: pnpm
package-manager-version: 7.26.3
package-manager-version: 8.1.0

- name: Test Inflint
run: pnpm inflint

typescript:
name: Testing TypeScript
name: TypeScript

runs-on: [self-hosted, Linux, X64, integration]
runs-on: ubuntu-latest
steps:
- name: Setup Node environment
uses: Exlint/[email protected].4
uses: Exlint/[email protected].6
with:
node-version: 18.13.0
node-version: 18.15.0
package-manager: pnpm
package-manager-version: 7.26.3
package-manager-version: 8.1.0

- name: Test TypeScript
run: pnpm type-check

prettier:
name: Testing Prettier
name: Prettier

runs-on: [self-hosted, Linux, X64, integration]
runs-on: ubuntu-latest
steps:
- name: Setup Node environment
uses: Exlint/[email protected].4
uses: Exlint/[email protected].6
with:
node-version: 18.13.0
node-version: 18.15.0
package-manager: pnpm
package-manager-version: 7.26.3
package-manager-version: 8.1.0

- name: Test Prettier
run: pnpm prettier

eslint:
name: Testing ESLint
name: ESLint

runs-on: [self-hosted, Linux, X64, integration]
runs-on: ubuntu-latest
steps:
- name: Setup Node environment
uses: Exlint/[email protected].4
uses: Exlint/[email protected].6
with:
node-version: 18.13.0
node-version: 18.15.0
package-manager: pnpm
package-manager-version: 7.26.3
package-manager-version: 8.1.0

- name: Test ESLint
run: pnpm lint

dist:
name: Testing dist
build:
name: Build

runs-on: [self-hosted, Linux, X64, integration]
runs-on: ubuntu-latest
steps:
- name: Setup Node environment
uses: Exlint/[email protected].4
uses: Exlint/[email protected].6
with:
node-version: 18.13.0
node-version: 18.15.0
package-manager: pnpm
package-manager-version: 7.26.3
package-manager-version: 8.1.0

- name: Test dist
run: pnpm dist
- name: Test build
run: pnpm build
14 changes: 7 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ on:
jobs:
release:
name: Release version
runs-on: ubuntu-latest
permissions:
contents: write

runs-on: ubuntu-latest
steps:
- name: Setup Node environment
uses: Exlint/[email protected].4
uses: Exlint/[email protected].6
with:
node-version: 18.13.0
package-manager: pnpm
package-manager-version: 7.26.3
should-cache: false
node-version: 14
package-manager: pnpm
package-manager-version: 8.1.0

- name: Build dist folder
run: pnpm dist
run: pnpm build

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v3.4.0
with:
extra_plugins: |
@semantic-release/changelog
Expand Down
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/node_modules
/coverage
/dist

*.tsbuildinfo
node_modules
coverage
dist
*.tsbuildinfo
5 changes: 2 additions & 3 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
save-exact=true
stream=true
strict-peer-dependencies=false
save-exact="true"
stream="true"
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
dist
coverage
README.md
README.md
pnpm-lock.yaml
File renamed without changes.
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,16 @@
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"material-icon-theme.files.associations": {
".inflintignore": "crystal",
"inflint.config.cjs": "crystal",
"czvinyl.config.ts": "ocaml",
".depcheckrc.json": "parcel",
".cz.json": "jinja",
"tsconfig.paths.json": "tsconfig"
}
}
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Update From GitHub",
"type": "shell",
"command": "git fetch",
"group": "none",
"presentation": {
"reveal": "always",
"panel": "new"
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}
25 changes: 7 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ npm install --save-dev @exlint.io/inflint
$ inflint [options] [files]
```

## ESM support

Inflint now supports **only** ESM modules. For any issue regarding this, please visit this link https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

## Configuration

You can specify the configuration of Inflint through various options.
Expand All @@ -55,23 +59,9 @@ Configuration can be set in the following files:
- a `package.json` property: `"inflint": {...}`
- a `.inflintrc` file in JSON or YAML format
- a `.inflintrc.json`, `.inflintrc.yaml`, `.inflintrc.yml`, `.inflintrc.js`, `.inflintrc.ts`, or `.inflintrc.cjs` file
- a `inflint.config.js`, `inflint.config.ts` or `inflint.config.cjs` CommonJS module exporting an object

If you set a TypeScript configuration file, you can use the configuration interface:
```ts
import type { Config } from '@exlint.io/inflint';

const inflintConfig: Config = {
...
}
- a `inflint.config.js`, or `inflint.config.cjs` CommonJS module exporting an object

export default inflintConfig;
```

You can set a configuration file using our wizard:
```bash
npx @exlint.io/inflint --init
```
Currently, a TypeScript configuration file is not supported: https://github.com/Codex-/cosmiconfig-typescript-loader/issues/60

### Rules format
When applying rules either via the CLI or other conifguration, you must follow the rules format.
Expand Down Expand Up @@ -171,8 +161,7 @@ The JSON should follow the aliases format described above.
| `--max-warnings` | `maxWarnings` | Number | `0` | Number of warnings to trigger non-zero exit code |
| `--bail` | `bail` | Boolean or Number | `0` | Number of failures (errors) to make Inflint to exit. Setting "bail" to true is the same as setting "1" |
| `-o`, `--output-file` | `outputFile` | String | - | Specify file to write report to |
| `--color`, `--no-color` | - | Boolean | `true` | Force enabling/disabling of color |
| `--init` | - | Boolean | `false` | Run configuration initialization wizard |
| `--color`, `--no-color` | - | Boolean | `true` | Force enabling/disabling of color | |
| `-h`, `--help` | - | Boolean | `false` | Show help |
| `-v`, `--version` | - | Boolean | `false` | Output the version number |
| `--env-info` | - | Boolean | `false` | Output the environment version |
Expand Down
Loading

0 comments on commit 45a06ea

Please sign in to comment.