Skip to content

Commit a97b0ea

Browse files
Benjamin SÉGAULTbsegault
authored andcommitted
fix: upgraded @typescript-eslint* to v7
relax a bit some new rules that we cannot apply easily
1 parent 7312403 commit a97b0ea

File tree

4 files changed

+482
-7644
lines changed

4 files changed

+482
-7644
lines changed

.eslintrc.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ module.exports = {
4343
extends: [
4444
// Base recommended set of rules
4545
"eslint:recommended",
46-
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs
47-
// recommended extends @typescript-eslint/eslint-recommended which disables some of eslint:recommended
48-
"plugin:@typescript-eslint/recommended",
46+
47+
// https://typescript-eslint.io/linting/configs/#recommended-configurations
48+
"plugin:@typescript-eslint/recommended-type-checked",
49+
"plugin:@typescript-eslint/stylistic",
50+
4951
// Additional recommended react rules
5052
"plugin:react/recommended",
5153
// Additional recommended react-hooks rules
@@ -203,6 +205,25 @@ module.exports = {
203205
],
204206
},
205207
],
208+
209+
// Relax some @typescript-eslint/recommended-type-checked rules
210+
// Sometimes we use any type implictely, because we don't have the type at all
211+
"@typescript-eslint/no-unsafe-argument": "off",
212+
"@typescript-eslint/no-unsafe-assignment": "off",
213+
"@typescript-eslint/no-unsafe-call": "off",
214+
"@typescript-eslint/no-unsafe-enum-comparison": "off",
215+
"@typescript-eslint/no-unsafe-member-access": "off",
216+
217+
// Allow to serialize caught variables like `${err}` (because err would have unknown type by default)
218+
"@typescript-eslint/restrict-template-expressions": "off",
219+
220+
// Relax some @typescript-eslint/stylistic rules
221+
// Allow to use indexed objects
222+
"@typescript-eslint/consistent-indexed-object-style": "off",
223+
// Allow to use interfaces and types
224+
"@typescript-eslint/consistent-type-definitions": "off",
225+
// Allow to use T[] and Array<T>
226+
"@typescript-eslint/array-type": "off",
206227
},
207228
overrides: [
208229
// Typescript overrides
@@ -219,6 +240,18 @@ module.exports = {
219240
// Allow assertion operator in unit tests because TS does not recognize
220241
// jest expects such as toBeDefined() or not.toBeNull() as type-validating
221242
"@typescript-eslint/no-non-null-assertion": "off",
243+
// Lots of tests can have async test callback, for consistency and easy update
244+
// Allow to have them without await in the callback body, because side effect in tests are minimal
245+
"@typescript-eslint/require-await": "off",
246+
},
247+
},
248+
// TSOA/Nest Overrides
249+
{
250+
files: ["**/controllers/**"],
251+
rules: {
252+
// Some annotations helpers must be used but explicitly return any
253+
// Disable them for those cases
254+
"@typescript-eslint/no-unsafe-return": "off",
222255
},
223256
},
224257
// Storybook overrides

config.json

Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,18 @@
4646
"@typescript-eslint/adjacent-overload-signatures": [
4747
"error"
4848
],
49+
"@typescript-eslint/array-type": [
50+
"off"
51+
],
52+
"@typescript-eslint/await-thenable": [
53+
"error"
54+
],
4955
"@typescript-eslint/ban-ts-comment": [
5056
"error"
5157
],
58+
"@typescript-eslint/ban-tslint-comment": [
59+
"error"
60+
],
5261
"@typescript-eslint/ban-types": [
5362
"warn"
5463
],
@@ -58,12 +67,27 @@
5867
"@typescript-eslint/brace-style": [
5968
"off"
6069
],
70+
"@typescript-eslint/class-literal-property-style": [
71+
"error"
72+
],
6173
"@typescript-eslint/comma-dangle": [
6274
"off"
6375
],
6476
"@typescript-eslint/comma-spacing": [
6577
"off"
6678
],
79+
"@typescript-eslint/consistent-generic-constructors": [
80+
"error"
81+
],
82+
"@typescript-eslint/consistent-indexed-object-style": [
83+
"off"
84+
],
85+
"@typescript-eslint/consistent-type-assertions": [
86+
"error"
87+
],
88+
"@typescript-eslint/consistent-type-definitions": [
89+
"off"
90+
],
6791
"@typescript-eslint/explicit-module-boundary-types": [
6892
"warn"
6993
],
@@ -88,6 +112,18 @@
88112
"@typescript-eslint/no-array-constructor": [
89113
"error"
90114
],
115+
"@typescript-eslint/no-base-to-string": [
116+
"error"
117+
],
118+
"@typescript-eslint/no-confusing-non-null-assertion": [
119+
"error"
120+
],
121+
"@typescript-eslint/no-duplicate-enum-values": [
122+
"error"
123+
],
124+
"@typescript-eslint/no-duplicate-type-constituents": [
125+
"error"
126+
],
91127
"@typescript-eslint/no-empty-function": [
92128
"error"
93129
],
@@ -106,6 +142,15 @@
106142
"@typescript-eslint/no-extra-semi": [
107143
"off"
108144
],
145+
"@typescript-eslint/no-floating-promises": [
146+
"error"
147+
],
148+
"@typescript-eslint/no-for-in-array": [
149+
"error"
150+
],
151+
"@typescript-eslint/no-implied-eval": [
152+
"error"
153+
],
109154
"@typescript-eslint/no-inferrable-types": [
110155
"error"
111156
],
@@ -115,21 +160,48 @@
115160
"@typescript-eslint/no-misused-new": [
116161
"error"
117162
],
163+
"@typescript-eslint/no-misused-promises": [
164+
"error"
165+
],
118166
"@typescript-eslint/no-namespace": [
119167
"error"
120168
],
121169
"@typescript-eslint/no-non-null-asserted-optional-chain": [
122170
"error"
123171
],
124-
"@typescript-eslint/no-non-null-assertion": [
125-
"warn"
172+
"@typescript-eslint/no-redundant-type-constituents": [
173+
"error"
126174
],
127175
"@typescript-eslint/no-this-alias": [
128176
"error"
129177
],
178+
"@typescript-eslint/no-unnecessary-type-assertion": [
179+
"error"
180+
],
130181
"@typescript-eslint/no-unnecessary-type-constraint": [
131182
"error"
132183
],
184+
"@typescript-eslint/no-unsafe-argument": [
185+
"off"
186+
],
187+
"@typescript-eslint/no-unsafe-assignment": [
188+
"off"
189+
],
190+
"@typescript-eslint/no-unsafe-call": [
191+
"off"
192+
],
193+
"@typescript-eslint/no-unsafe-declaration-merging": [
194+
"error"
195+
],
196+
"@typescript-eslint/no-unsafe-enum-comparison": [
197+
"off"
198+
],
199+
"@typescript-eslint/no-unsafe-member-access": [
200+
"off"
201+
],
202+
"@typescript-eslint/no-unsafe-return": [
203+
"error"
204+
],
133205
"@typescript-eslint/no-unused-vars": [
134206
"warn",
135207
{
@@ -146,12 +218,27 @@
146218
"@typescript-eslint/prefer-as-const": [
147219
"error"
148220
],
221+
"@typescript-eslint/prefer-for-of": [
222+
"error"
223+
],
224+
"@typescript-eslint/prefer-function-type": [
225+
"error"
226+
],
149227
"@typescript-eslint/prefer-namespace-keyword": [
150228
"error"
151229
],
152230
"@typescript-eslint/quotes": [
153231
0
154232
],
233+
"@typescript-eslint/require-await": [
234+
"error"
235+
],
236+
"@typescript-eslint/restrict-plus-operands": [
237+
"error"
238+
],
239+
"@typescript-eslint/restrict-template-expressions": [
240+
"off"
241+
],
155242
"@typescript-eslint/semi": [
156243
"off"
157244
],
@@ -170,6 +257,9 @@
170257
"@typescript-eslint/type-annotation-spacing": [
171258
"off"
172259
],
260+
"@typescript-eslint/unbound-method": [
261+
"error"
262+
],
173263
"array-bracket-newline": [
174264
"off"
175265
],
@@ -436,6 +526,9 @@
436526
"no-global-assign": [
437527
"error"
438528
],
529+
"no-implied-eval": [
530+
"off"
531+
],
439532
"no-import-assign": [
440533
"error"
441534
],
@@ -791,6 +884,9 @@
791884
"react/require-render-return": [
792885
2
793886
],
887+
"require-await": [
888+
"off"
889+
],
794890
"require-yield": [
795891
"error"
796892
],
@@ -971,9 +1067,6 @@
9711067
"template-tag-spacing": [
9721068
"off"
9731069
],
974-
"unicode-bom": [
975-
"off"
976-
],
9771070
"unicorn/empty-brace-spaces": [
9781071
"off"
9791072
],
@@ -983,6 +1076,9 @@
9831076
"unicorn/number-literal-case": [
9841077
"off"
9851078
],
1079+
"unicorn/template-indent": [
1080+
0
1081+
],
9861082
"use-isnan": [
9871083
"error"
9881084
],

0 commit comments

Comments
 (0)