-
-
Notifications
You must be signed in to change notification settings - Fork 2k
chore: migrate eslint config to flat format #4887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1254db9
5661c1e
727cb96
6764780
e8d26e3
15a5c96
441378f
30f9b8f
8671a5a
4fa1936
f20590c
3e5cb40
3595758
89b5d53
0427dd6
9baba88
59d187f
70c6a30
a0ecfb4
4b12129
49757c0
825948e
d0cc0bb
abdadfa
dda0e34
3dd0f0f
530c2d8
f6ed7de
e6e1cda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import { FlatCompat } from '@eslint/eslintrc'; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import js from '@eslint/js'; | ||
import nxEslintPlugin from '@nx/eslint-plugin'; | ||
|
||
const compat = new FlatCompat({ | ||
baseDirectory: dirname(fileURLToPath(import.meta.url)), | ||
recommendedConfig: js.configs.recommended, | ||
}); | ||
|
||
export default [ | ||
{ | ||
ignores: ['**/dist'], | ||
}, | ||
{ plugins: { '@nx': nxEslintPlugin } }, | ||
{ | ||
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], | ||
rules: { | ||
'@nx/enforce-module-boundaries': [ | ||
'error', | ||
{ | ||
allow: [], | ||
depConstraints: [ | ||
{ | ||
sourceTag: '*', | ||
onlyDependOnLibsWithTags: ['*'], | ||
}, | ||
], | ||
}, | ||
], | ||
'@typescript-eslint/member-ordering': 'off', | ||
'@typescript-eslint/no-inferrable-types': 'warn', | ||
}, | ||
}, | ||
...compat | ||
.config({ | ||
extends: ['plugin:@nx/typescript'], | ||
}) | ||
.map((config) => ({ | ||
...config, | ||
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'], | ||
rules: { | ||
...config.rules, | ||
'no-extra-semi': 'off', | ||
}, | ||
})), | ||
...compat | ||
.config({ | ||
extends: ['plugin:@nx/javascript'], | ||
}) | ||
.map((config) => ({ | ||
...config, | ||
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'], | ||
rules: { | ||
...config.rules, | ||
'no-extra-semi': 'off', | ||
}, | ||
})), | ||
...compat | ||
.config({ | ||
plugins: ['eslint-plugin-import', '@typescript-eslint'], | ||
}) | ||
.map((config) => ({ | ||
...config, | ||
files: ['**/*.ts'], | ||
rules: { | ||
...config.rules, | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'warn', | ||
{ | ||
argsIgnorePattern: '^_', | ||
varsIgnorePattern: '^_', | ||
caughtErrorsIgnorePattern: '^_', | ||
}, | ||
], | ||
'@typescript-eslint/naming-convention': 'off', | ||
'@typescript-eslint/prefer-namespace-keyword': 'error', | ||
'@typescript-eslint/no-empty-function': 'warn', | ||
'@typescript-eslint/no-empty-object-type': 'warn', | ||
eqeqeq: ['off', 'smart'], | ||
'id-blacklist': [ | ||
'error', | ||
'any', | ||
'Number', | ||
'number', | ||
'String', | ||
'string', | ||
'Boolean', | ||
'boolean', | ||
'Undefined', | ||
'undefined', | ||
], | ||
'id-match': 'error', | ||
'no-eval': 'off', | ||
'no-redeclare': 'off', | ||
'no-underscore-dangle': 'off', | ||
'no-var': 'error', | ||
'no-prototype-builtins': 'off', | ||
'@typescript-eslint/no-wrapper-object-types': 'off', | ||
'@typescript-eslint/no-unsafe-function-type': 'off', | ||
}, | ||
})), | ||
{ | ||
files: ['**/*.html'], | ||
// Override or add rules here | ||
rules: {}, | ||
}, | ||
]; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { FlatCompat } from '@eslint/eslintrc'; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import js from '@eslint/js'; | ||
import baseConfig from '../../eslint.config.mjs'; | ||
|
||
const compat = new FlatCompat({ | ||
baseDirectory: dirname(fileURLToPath(import.meta.url)), | ||
recommendedConfig: js.configs.recommended, | ||
}); | ||
|
||
export default [ | ||
{ | ||
ignores: ['**/dist', '**/jest.config.ts', '**/schematics-core/test-setup.ts', '**/schematics-core/utility/standalone.ts'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to add this to the base config and remove it in the module specific configs? In the base config: ignores: ['**/dist', '**/jest.config.ts', '**/schematics-core'], I don't remember why we excluded these, this can be looked into later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the exclusions were added to match previous files. The lints fail without them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential option is to add In base config, could add an overrides array like this: overrides: [
{
files: ['**/jest.config.ts'],
env: { node: true },
rules: {
// customize rules for config files
},
},
{
files: ['**/schematics-core/**/*.ts'],
env: { node: true },
rules: {
// loosen rules or add globals as needed
},
},
], Typically, files are ignored if they use "globals" or unusual patterns that could break if linted. Code that uses TypeScript AST, Node.js (node vs web environments), and schematics is also typically ignored. That standalone utility looks a stop-gap or bridge file and may be something that could potentially be removed as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine, we don't need to add a eslintignore - AFAIK this isn't supported anymore. |
||
}, | ||
...baseConfig, | ||
...compat | ||
.config({ | ||
extends: [ | ||
'plugin:@nx/angular', | ||
'plugin:@angular-eslint/template/process-inline-templates', | ||
], | ||
plugins: ['@typescript-eslint'], | ||
}) | ||
.map((config) => ({ | ||
...config, | ||
files: ['**/*.ts'], | ||
rules: { | ||
...config.rules, | ||
'@angular-eslint/directive-selector': 'off', | ||
'@angular-eslint/component-selector': 'off', | ||
'@angular-eslint/prefer-standalone': 'off', | ||
}, | ||
languageOptions: { | ||
parserOptions: { | ||
project: ['modules/component-store/tsconfig.*.json'], | ||
}, | ||
}, | ||
})), | ||
...compat | ||
.config({ | ||
extends: ['plugin:@nx/angular-template'], | ||
}) | ||
.map((config) => ({ | ||
...config, | ||
files: ['**/*.html'], | ||
rules: { | ||
...config.rules, | ||
}, | ||
})), | ||
{ | ||
ignores: ['schematics-core'], | ||
}, | ||
]; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { FlatCompat } from '@eslint/eslintrc'; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import js from '@eslint/js'; | ||
import baseConfig from '../../eslint.config.mjs'; | ||
|
||
const compat = new FlatCompat({ | ||
baseDirectory: dirname(fileURLToPath(import.meta.url)), | ||
recommendedConfig: js.configs.recommended, | ||
}); | ||
|
||
export default [ | ||
{ | ||
ignores: ['**/dist', '**/jest.config.ts', '**/schematics-core/test-setup.ts', '**/schematics-core/utility/standalone.ts'], | ||
}, | ||
...baseConfig, | ||
...compat | ||
.config({ | ||
extends: [ | ||
'plugin:@nx/angular', | ||
'plugin:@angular-eslint/template/process-inline-templates', | ||
], | ||
plugins: ['@typescript-eslint'], | ||
}) | ||
.map((config) => ({ | ||
...config, | ||
files: ['**/*.ts'], | ||
rules: { | ||
...config.rules, | ||
'@angular-eslint/directive-selector': 'off', | ||
'@angular-eslint/component-selector': 'off', | ||
'@angular-eslint/no-input-rename': 'off', | ||
'@angular-eslint/prefer-standalone': 'off', | ||
}, | ||
languageOptions: { | ||
parserOptions: { | ||
project: ['modules/component/tsconfig.*.json'], | ||
}, | ||
}, | ||
})), | ||
...compat | ||
.config({ | ||
extends: ['plugin:@nx/angular-template'], | ||
}) | ||
.map((config) => ({ | ||
...config, | ||
files: ['**/*.html'], | ||
rules: { | ||
...config.rules, | ||
}, | ||
})), | ||
{ | ||
ignores: ['schematics-core'], | ||
}, | ||
]; |
Uh oh!
There was an error while loading. Please reload this page.