-
Notifications
You must be signed in to change notification settings - Fork 206
Migrate to ESLint 9 and ESLint flat config #6615
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Changes from all commits
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.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import hypothesis from 'eslint-config-hypothesis'; | ||
import jsxA11y from 'eslint-plugin-jsx-a11y'; | ||
import globals from 'globals'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
export default tseslint.config( | ||
{ | ||
ignores: [ | ||
'.tox/**/*', | ||
'.yalc/**/*', | ||
'.yarn/**/*', | ||
'build/**/*', | ||
'**/vendor/**/*.js', | ||
'**/coverage/**/*', | ||
'docs/_build/*', | ||
'dev-server/static/**/*.js', | ||
], | ||
}, | ||
...hypothesis, | ||
...tseslint.configs.recommended, | ||
jsxA11y.flatConfigs.recommended, | ||
{ | ||
rules: { | ||
'prefer-arrow-callback': [ | ||
'error', | ||
{ | ||
allowNamedFunctions: true, | ||
}, | ||
], | ||
|
||
'object-shorthand': ['error', 'properties'], | ||
'react/prop-types': 'off', | ||
'@typescript-eslint/no-unused-vars': 'error', | ||
'no-use-before-define': 'off', | ||
|
||
'@typescript-eslint/no-use-before-define': [ | ||
'error', | ||
{ | ||
functions: false, | ||
typedefs: false, | ||
ignoreTypeReferences: false, | ||
}, | ||
], | ||
|
||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'@typescript-eslint/no-this-alias': 'off', | ||
'@typescript-eslint/consistent-type-assertions': 'error', | ||
'@typescript-eslint/consistent-type-imports': 'error', | ||
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. I think we use the same rules in other TS-enabled projects. It would be good to centralize them in eslint-config-hypothesis where appropriate. |
||
}, | ||
}, | ||
|
||
// Annotator module | ||
{ | ||
files: ['src/annotator/**/*.{js|tx|tsx}'], | ||
rules: { | ||
'no-restricted-properties': [ | ||
2, | ||
{ | ||
// Disable `bind` usage in annotator/ code to prevent unexpected behavior | ||
// due to broken bind polyfills. See | ||
// https://github.com/hypothesis/client/issues/245 | ||
property: 'bind', | ||
message: | ||
'Use function expressions instead of bind() in annotator/ code', | ||
}, | ||
], | ||
}, | ||
}, | ||
|
||
// Scripts and configuration files | ||
{ | ||
files: ['**/*.js'], | ||
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. I think I would prefer to use an allow-list rather than making these rules apply to all files and then attempting to exclude 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. Agree, but for now let's just migrate the config as-is (as much as possible). We can adjust that 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. OK |
||
ignores: ['src/**'], | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'no-console': 'off', | ||
'react-hooks/rules-of-hooks': 'off', | ||
}, | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
}, | ||
}, | ||
); |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of these files are already ignored by
.gitignore
. Does ESLint not automatically respect that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, doesn't seem to. I even had to add a few more there that were not part of
.eslintignore
and were getting scanned now (.tox
,.yarn
and.yalc
specifically).