-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[core] Update @typescript-eslint/*
packages and remove deprecated eslint-config-airbnb-typescript
package
#45245
Merged
ZeeshanTamboli
merged 10 commits into
mui:master
from
ZeeshanTamboli:bump-typescript-eslint-to-v8
Feb 11, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d22207a
remove eslint-config-airbnb-typescript and update typescript-eslint
ZeeshanTamboli 446f40d
remove redundant rules
ZeeshanTamboli ade25d6
format
ZeeshanTamboli 97d9695
Merge branch 'master' into bump-typescript-eslint-to-v8
ZeeshanTamboli 627a513
resolve conflict
ZeeshanTamboli e6f1d56
separate out eslint-config-airbnb-typescript in its own file
ZeeshanTamboli b32a292
Merge branch 'master' into bump-typescript-eslint-to-v8
ZeeshanTamboli 538400f
pnpm dedupe
ZeeshanTamboli c8dde30
resolve conflict
ZeeshanTamboli ed03594
pnpm dedupe
ZeeshanTamboli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
const { rules: baseBestPracticesRules } = require('eslint-config-airbnb-base/rules/best-practices'); | ||
const { rules: baseES6Rules } = require('eslint-config-airbnb-base/rules/es6'); | ||
const { rules: baseImportsRules } = require('eslint-config-airbnb-base/rules/imports'); | ||
const { rules: baseStyleRules } = require('eslint-config-airbnb-base/rules/style'); | ||
const { rules: baseVariablesRules } = require('eslint-config-airbnb-base/rules/variables'); | ||
|
||
module.exports = { | ||
settings: { | ||
// Apply special parsing for TypeScript files | ||
'import/parsers': { | ||
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'], | ||
}, | ||
'import/resolver': { | ||
node: { | ||
extensions: ['.mjs', '.js', '.jsx', '.json', '.ts', '.tsx', '.d.ts'], | ||
}, | ||
}, | ||
// Append 'ts' extensions to Airbnb 'import/extensions' setting | ||
// Original: ['.js', '.mjs', '.jsx'] | ||
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'], | ||
// Resolve type definition packages | ||
'import/external-module-folders': ['node_modules', 'node_modules/@types'], | ||
}, | ||
rules: { | ||
camelcase: 'off', | ||
// The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this. | ||
'@typescript-eslint/naming-convention': [ | ||
'error', | ||
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10) | ||
{ | ||
selector: 'variable', | ||
format: ['camelCase', 'PascalCase', 'UPPER_CASE'], | ||
}, | ||
// Allow camelCase functions (23.2), and PascalCase functions (23.8) | ||
{ | ||
selector: 'function', | ||
format: ['camelCase', 'PascalCase'], | ||
}, | ||
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make TypeScript recommendations, we are assuming this rule would similarly apply to anything "type like", including interfaces, type aliases, and enums | ||
{ | ||
selector: 'typeLike', | ||
format: ['PascalCase'], | ||
}, | ||
], | ||
'default-param-last': 'off', | ||
'@typescript-eslint/default-param-last': baseBestPracticesRules['default-param-last'], | ||
'no-array-constructor': 'off', | ||
'@typescript-eslint/no-array-constructor': baseStyleRules['no-array-constructor'], | ||
'no-empty-function': 'off', | ||
'@typescript-eslint/no-empty-function': baseBestPracticesRules['no-empty-function'], | ||
'no-loss-of-precision': 'error', | ||
'no-loop-func': 'off', | ||
'@typescript-eslint/no-loop-func': baseBestPracticesRules['no-loop-func'], | ||
'no-magic-numbers': 'off', | ||
'@typescript-eslint/no-magic-numbers': baseBestPracticesRules['no-magic-numbers'], | ||
'no-shadow': 'off', | ||
'@typescript-eslint/no-shadow': baseVariablesRules['no-shadow'], | ||
'no-unused-expressions': 'off', | ||
'@typescript-eslint/no-unused-expressions': baseBestPracticesRules['no-unused-expressions'], | ||
'no-useless-constructor': 'off', | ||
'@typescript-eslint/no-useless-constructor': baseES6Rules['no-useless-constructor'], | ||
'require-await': 'off', | ||
'@typescript-eslint/require-await': baseBestPracticesRules['require-await'], | ||
|
||
// Append 'ts' and 'tsx' to Airbnb 'import/extensions' rule | ||
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md | ||
'import/extensions': [ | ||
baseImportsRules['import/extensions'][0], | ||
baseImportsRules['import/extensions'][1], | ||
typeof baseImportsRules['import/extensions'][2] === 'object' | ||
? { | ||
...baseImportsRules['import/extensions'][2], | ||
ts: 'never', | ||
tsx: 'never', | ||
} | ||
: { ts: 'never', tsx: 'never' }, | ||
], | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.ts', '*.tsx'], | ||
rules: { | ||
// The following rules are enabled in Airbnb config, but are already checked (more thoroughly) by the TypeScript compiler | ||
// Some of the rules also fail in TypeScript files, for example: https://github.com/typescript-eslint/typescript-eslint/issues/662#issuecomment-507081586 | ||
// Rules are inspired by: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts | ||
'constructor-super': 'off', | ||
'getter-return': 'off', | ||
'no-const-assign': 'off', | ||
'no-dupe-args': 'off', | ||
'no-dupe-class-members': 'off', | ||
'no-dupe-keys': 'off', | ||
'no-func-assign': 'off', | ||
'no-import-assign': 'off', | ||
'no-new-symbol': 'off', | ||
'no-obj-calls': 'off', | ||
'no-redeclare': 'off', | ||
'no-setter-return': 'off', | ||
'no-this-before-super': 'off', | ||
'no-undef': 'off', | ||
'no-unreachable': 'off', | ||
'no-unsafe-negation': 'off', | ||
'valid-typeof': 'off', | ||
// The following rules are enabled in Airbnb config, but are recommended to be disabled within TypeScript projects | ||
// See: https://github.com/typescript-eslint/typescript-eslint/blob/13583e65f5973da2a7ae8384493c5e00014db51b/docs/linting/TROUBLESHOOTING.md#eslint-plugin-import | ||
'import/named': 'off', | ||
'import/no-named-as-default-member': 'off', | ||
'import/no-unresolved': 'off', | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Override
caughtErrors
tonone
here to avoid an unusederror
parameter eslint error in the catch block. It's a breaking change in v8—the default is changed toall
. See https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/#rule-breaking-changes. So I had to override it.