-
Notifications
You must be signed in to change notification settings - Fork 1
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
Update typescript-eslint monorepo to v7 (major) #518
Changes from 15 commits
fadb7d6
bcb735b
a674449
30b1e97
3143131
dbfe610
d38589f
cfc8127
2ea2e56
4596d01
94fa0bd
7606e55
70d5c1c
8e13a5d
00be138
acf2b18
338a212
39c20bb
b468608
8a1755a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ module.exports = { | |
}, | ||
// camelCase for everything not otherwise indicated | ||
{ selector: 'default', format: ['camelCase'] }, | ||
// allow any naming convention for imports | ||
{ selector: 'import', format: null }, | ||
// allow known default exclusions | ||
{ selector: 'default', filter: { regex: '^(_id|__v|_raw)$', match: true }, format: null }, | ||
// allow variables to be camelCase or UPPER_CASE | ||
|
@@ -72,6 +74,7 @@ module.exports = { | |
'plugin:jest/recommended', | ||
'plugin:jest/style', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/stylistic', | ||
'plugin:import/typescript', | ||
'prettier', | ||
], | ||
|
@@ -139,11 +142,14 @@ module.exports = { | |
], | ||
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }], | ||
|
||
// disable consistent indexed object style. both are used in mvom | ||
'@typescript-eslint/consistent-indexed-object-style': 'off', | ||
|
||
// enforce consistent order of class members | ||
'@typescript-eslint/member-ordering': 'error', | ||
|
||
// disallow parameter properties in favor of explicit class declarations | ||
'@typescript-eslint/no-parameter-properties': 'error', | ||
'@typescript-eslint/parameter-properties': 'error', | ||
|
||
// ensure unused variables are treated as an error | ||
// overrides @typescript-eslint/recommended -- '@typescript-eslint/no-unused-vars': 'warn' | ||
|
@@ -153,7 +159,10 @@ module.exports = { | |
}, | ||
{ | ||
files: tsGlobs, | ||
extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking'], | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended-type-checked', | ||
'plugin:@typescript-eslint/stylistic-type-checked', | ||
], | ||
rules: { | ||
// ban ts-comment except with description | ||
'@typescript-eslint/ban-ts-comment': [ | ||
|
@@ -166,8 +175,8 @@ module.exports = { | |
}, | ||
], | ||
|
||
// disable rules turned on by @typescript-eslint/recommended-requiring-type-checking which are too noisy | ||
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts | ||
// disable rules turned on by @typescript-eslint/recommended-type-checked which are too noisy | ||
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-type-checked.ts | ||
'@typescript-eslint/no-unsafe-argument': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
|
@@ -176,9 +185,22 @@ module.exports = { | |
'@typescript-eslint/restrict-template-expressions': 'off', | ||
'@typescript-eslint/unbound-method': 'off', | ||
|
||
// override @typescript-eslint/stylistic-type-checked to ignore consistent-indexed-object-style. Both are used as required. | ||
'@typescript-eslint/consistent-indexed-object-style': 'off', | ||
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. If we did need to disable this rule, we shouldn't have to disable it in both the But as noted previously, I think we should enable the rule. 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 moved this to 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. My comment was on However, it seems like you've moved the 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. Oh ok gotcha. Thank you. I moved |
||
|
||
// force explicit member accessibility modifiers | ||
'@typescript-eslint/explicit-member-accessibility': 'error', | ||
|
||
// override @typescript-eslint/stylistic-type-checked to ignore booleans in nullish coalescing checks | ||
// https://typescript-eslint.io/rules/prefer-nullish-coalescing#ignoreprimitives | ||
'@typescript-eslint/prefer-nullish-coalescing': [ | ||
'error', | ||
{ ignorePrimitives: { boolean: true } }, | ||
], | ||
|
||
// ban non-null assertions | ||
'@typescript-eslint/no-non-null-assertion': '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 usually try to group related rules or keep them at least alphabetically ordered. So I would flip-flop these two for readability. |
||
|
||
// disallow boolean comparisons against non-boolean values | ||
'@typescript-eslint/strict-boolean-expressions': ['error', { allowNullableBoolean: true }], | ||
}, | ||
|
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.
We use
Record
and the index signature. TheRecord
is good in most scenarios as used inmvom
but,TypeScript will report errors about recursive type reference in scenarios like in
Schema.ts
whereSchemaDefinition
referencesSchemaTypeDefinition
andSchemaTypeDefinition
referencesSchemaDefinition
.I think turning the rule off is better than trying to force one or the other. I think I liked the use of
Record
where it made sense and the use the index signature where needed as well.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.
I would prefer to see a global enforcement of consistency and an override of the rule where it's not possible to use that. It looks like its by design that
Record
cannot circularly reference itself: microsoft/TypeScript#33050 (comment)However, for those scenarios where that's not the case, it would be better to have consistency and enforce the rule.
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.
Good idea.
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.
Removed the override to the turn the rule off. I updated where possible to use
Record
and provided an override for where not possible.