@qlik/eslint-config 2.0.0-next.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -21,8 +21,8 @@ import qlik from "@qlik/eslint-config";
|
|
|
21
21
|
import { defineConfig } from "eslint/config";
|
|
22
22
|
|
|
23
23
|
export default defineConfig(
|
|
24
|
-
qlik.configs.react,
|
|
25
|
-
qlik.configs.vitest,
|
|
24
|
+
...qlik.configs.react,
|
|
25
|
+
...qlik.configs.vitest,
|
|
26
26
|
{
|
|
27
27
|
rules: {
|
|
28
28
|
// Override rules if needed
|
|
@@ -44,8 +44,8 @@ import pluginQuery from "@tanstack/eslint-plugin-query";
|
|
|
44
44
|
import { defineConfig } from "eslint/config";
|
|
45
45
|
|
|
46
46
|
export default defineConfig([
|
|
47
|
-
qlik.configs.react,
|
|
48
|
-
qlik.configs.vitest,
|
|
47
|
+
...qlik.configs.react,
|
|
48
|
+
...qlik.configs.vitest,
|
|
49
49
|
pluginQuery.configs["flat/recommended"],
|
|
50
50
|
{
|
|
51
51
|
ignores: ["dist", "script", "my-special-no-linting.ts"],
|
|
@@ -75,7 +75,7 @@ import qlik from "@qlik/eslint-config";
|
|
|
75
75
|
import { defineConfig } from "eslint/config";
|
|
76
76
|
|
|
77
77
|
export default defineConfig(
|
|
78
|
-
qlik.configs.recommended, // adds linting on .js, .jsx, .mjs, .cjs, .ts, .tsx, .cts, .mts files. use for pure browser environment
|
|
78
|
+
...qlik.configs.recommended, // adds linting on .js, .jsx, .mjs, .cjs, .ts, .tsx, .cts, .mts files. use for pure browser environment
|
|
79
79
|
{
|
|
80
80
|
ignores: ["dist"],
|
|
81
81
|
},
|
|
@@ -90,7 +90,7 @@ import qlik from "@qlik/eslint-config";
|
|
|
90
90
|
import { defineConfig } from "eslint/config";
|
|
91
91
|
|
|
92
92
|
export default defineConfig(
|
|
93
|
-
qlik.configs.react, // based on the recommended config and adds react linting on .jsx and .tsx files
|
|
93
|
+
...qlik.configs.react, // based on the recommended config and adds react linting on .jsx and .tsx files
|
|
94
94
|
{
|
|
95
95
|
ignores: ["dist"],
|
|
96
96
|
},
|
|
@@ -105,7 +105,7 @@ import qlik from "@qlik/eslint-config";
|
|
|
105
105
|
import { defineConfig } from "eslint/config";
|
|
106
106
|
|
|
107
107
|
export default defineConfig(
|
|
108
|
-
qlik.configs.esbrowser, // based on the recommended config and adds specific es module rules (file endings)
|
|
108
|
+
...qlik.configs.esbrowser, // based on the recommended config and adds specific es module rules (file endings)
|
|
109
109
|
{
|
|
110
110
|
ignores: ["dist"],
|
|
111
111
|
},
|
|
@@ -120,7 +120,7 @@ import qlik from "@qlik/eslint-config";
|
|
|
120
120
|
import { defineConfig } from "eslint/config";
|
|
121
121
|
|
|
122
122
|
export default defineConfig(
|
|
123
|
-
qlik.configs.esm, // or qlik.configs.cjs for commonjs, recommended config with node environment enabled
|
|
123
|
+
...qlik.configs.esm, // or qlik.configs.cjs for commonjs, recommended config with node environment enabled
|
|
124
124
|
{
|
|
125
125
|
ignores: ["dist"],
|
|
126
126
|
},
|
|
@@ -135,9 +135,9 @@ import qlik from "@qlik/eslint-config";
|
|
|
135
135
|
import { defineConfig } from "eslint/config";
|
|
136
136
|
|
|
137
137
|
export default defineConfig(
|
|
138
|
-
qlik.configs.recommended, // pure browser environment
|
|
139
|
-
qlik.configs.vitest, // enable vitest linting on files inside __test(s)__ folder
|
|
140
|
-
qlik.configs.playwright, // enable playwright linting on files inside ./test(s) folder.
|
|
138
|
+
...qlik.configs.recommended, // pure browser environment
|
|
139
|
+
...qlik.configs.vitest, // enable vitest linting on files inside __test(s)__ folder
|
|
140
|
+
...qlik.configs.playwright, // enable playwright linting on files inside ./test(s) folder.
|
|
141
141
|
{
|
|
142
142
|
ignores: ["dist"],
|
|
143
143
|
},
|
|
@@ -152,8 +152,8 @@ import qlik from "@qlik/eslint-config";
|
|
|
152
152
|
import { defineConfig } from "eslint/config";
|
|
153
153
|
|
|
154
154
|
export default defineConfig(
|
|
155
|
-
qlik.configs.recommended, // pure browser environment
|
|
156
|
-
qlik.configs.vitest, // enable vitest linting on files inside __test(s)__ folder
|
|
155
|
+
...qlik.configs.recommended, // pure browser environment
|
|
156
|
+
...qlik.configs.vitest, // enable vitest linting on files inside __test(s)__ folder
|
|
157
157
|
{
|
|
158
158
|
files: ["playwright/**/*.{js,jsx,ts,tsx}"], // will lint the files inside ./playwright folder with the playwright plugin
|
|
159
159
|
extends: [...qlik.configs.playwright],
|
|
@@ -173,8 +173,8 @@ import qlik from "@qlik/eslint-config";
|
|
|
173
173
|
import { defineConfig } from "eslint/config";
|
|
174
174
|
|
|
175
175
|
export default defineConfig(
|
|
176
|
-
qlik.configs.react, // based on the recommended config and adds react linting on .jsx and .tsx files
|
|
177
|
-
qlik.configs.vitest, // enable vitest linting on files inside __test(s)__ folder
|
|
176
|
+
...qlik.configs.react, // based on the recommended config and adds react linting on .jsx and .tsx files
|
|
177
|
+
...qlik.configs.vitest, // enable vitest linting on files inside __test(s)__ folder
|
|
178
178
|
{
|
|
179
179
|
ignores: ["dist"],
|
|
180
180
|
},
|
|
@@ -203,10 +203,10 @@ with typescript support
|
|
|
203
203
|
import { reactJS, reactTS } from "@qlik/eslint-config";
|
|
204
204
|
import { defineConfig } from "eslint/config";
|
|
205
205
|
|
|
206
|
-
export default defineConfig(
|
|
206
|
+
export default defineConfig(
|
|
207
207
|
reactJS,
|
|
208
208
|
reactTS,
|
|
209
|
-
|
|
209
|
+
)
|
|
210
210
|
```
|
|
211
211
|
|
|
212
212
|
This is equal to:
|
|
@@ -216,7 +216,7 @@ import qlik from "@qlik/eslint-config";
|
|
|
216
216
|
import { defineConfig } from "eslint/config";
|
|
217
217
|
|
|
218
218
|
export default defineConfig(
|
|
219
|
-
qlik.configs.react,
|
|
219
|
+
...qlik.configs.react,
|
|
220
220
|
)
|
|
221
221
|
```
|
|
222
222
|
|
|
@@ -229,7 +229,7 @@ import { defineConfig } from "eslint/config";
|
|
|
229
229
|
|
|
230
230
|
export default defineConfig(
|
|
231
231
|
// apply recommended config to all files
|
|
232
|
-
qlik.configs.recommended,
|
|
232
|
+
...qlik.configs.recommended,
|
|
233
233
|
{
|
|
234
234
|
// set node esm config on .mjs files inside the tools folder
|
|
235
235
|
files: ["tools/**/*.mjs"],
|
|
@@ -253,20 +253,136 @@ The biggest changes between v1 and v2 is the plugins used. Since a lot of plugin
|
|
|
253
253
|
- `eslint-plugin-playwright` - Removed
|
|
254
254
|
- `eslint-plugin-svelte` - Removed
|
|
255
255
|
- `eslint-plugin-react` - Replaced with [@eslint-react/eslint-plugin](https://github.com/Rel1cx/eslint-react)
|
|
256
|
-
- `eslint-plugin-react-hooks` -
|
|
256
|
+
- `eslint-plugin-react-hooks` - Replaced with [@eslint-react/eslint-plugin](https://github.com/Rel1cx/eslint-react)
|
|
257
257
|
|
|
258
258
|
When migrating from v1 -> v2 do the following:
|
|
259
259
|
|
|
260
|
+
Automatic:
|
|
261
|
+
|
|
262
|
+
Use the prompt [supplied below](#ai-prompt) and give to a co-pilot agent.
|
|
263
|
+
|
|
264
|
+
Manual:
|
|
265
|
+
|
|
260
266
|
1. Remove the `qlik.compose` function and replace it with `defineConfig`
|
|
261
267
|
2. If you were using any of the removed plugins (e.g. eslint-plugin-jest) you will have to add it to the eslint config.
|
|
262
|
-
3.
|
|
268
|
+
3. This new config has a stricter set of rules applied, especially in the typescript files. Also, some rules might have been removed (removed plugins) or changed. So you might see new lint errors after migrating. But it's highlighting possible problems in the code so spend some time fixing the errors. Disabling rules should only be done when you have good reasons.
|
|
263
269
|
|
|
264
270
|
Example of migration:
|
|
265
271
|
|
|
266
272
|
old config:
|
|
267
273
|
|
|
268
274
|
```js
|
|
275
|
+
// @ts-check
|
|
276
|
+
import qlik from "@qlik/eslint-config";
|
|
277
|
+
import pluginQuery from "@tanstack/eslint-plugin-query";
|
|
278
|
+
|
|
279
|
+
export default qlik.compose(
|
|
280
|
+
...qlik.configs.react,
|
|
281
|
+
...qlik.configs.vitest,
|
|
282
|
+
pluginQuery.configs["flat/recommended"],
|
|
283
|
+
{
|
|
284
|
+
rules: {
|
|
285
|
+
// Override rules if needed
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
// In its own object so it's global
|
|
289
|
+
{
|
|
290
|
+
ignores: ["dist", "node_modules", "script"],
|
|
291
|
+
},
|
|
292
|
+
);
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
1. add `import { defineConfig } from "eslint/config";`
|
|
296
|
+
2. replace `qlik.compose` with `defineConfig`
|
|
297
|
+
3. replace `extend` with `extends` (if present)
|
|
298
|
+
|
|
299
|
+
new config:
|
|
300
|
+
|
|
301
|
+
```js
|
|
302
|
+
// @ts-check
|
|
303
|
+
import qlik from "@qlik/eslint-config";
|
|
304
|
+
import pluginQuery from "@tanstack/eslint-plugin-query";
|
|
305
|
+
import { defineConfig } from "eslint/config";
|
|
306
|
+
|
|
307
|
+
export default defineConfig(
|
|
308
|
+
...qlik.configs.react,
|
|
309
|
+
...qlik.configs.vitest,
|
|
310
|
+
pluginQuery.configs["flat/recommended"],
|
|
311
|
+
{
|
|
312
|
+
rules: {
|
|
313
|
+
// Override rules if needed
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
// In its own object so it's global
|
|
317
|
+
{
|
|
318
|
+
ignores: ["dist", "node_modules", "script"],
|
|
319
|
+
},
|
|
320
|
+
);
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
If you are using jest the `eslint-plugin-jest` has been removed, so you may want to add it to your config.
|
|
324
|
+
Add `eslint-plugin-jest` to your npm dependencies and simply add a new section targeting your jest files with the plugin added.
|
|
325
|
+
Look at the [plugin's documentation](https://www.npmjs.com/package/eslint-plugin-jest)
|
|
326
|
+
|
|
327
|
+
Same things applies to `eslint-plugin-playwright`
|
|
328
|
+
|
|
329
|
+
### AI Prompt
|
|
330
|
+
|
|
331
|
+
Use this prompt for migrating:
|
|
332
|
+
|
|
333
|
+
```text
|
|
334
|
+
I want to migrate this project from ESLint v9 to ESLint v10 and update `@qlik/eslint-config` to v2 which supports ESLint v10.
|
|
335
|
+
|
|
336
|
+
The changes in `@qlik/eslint-config` from v1 -> v2 are mainly changes of which plugins are used.
|
|
337
|
+
|
|
338
|
+
- `eslint-plugin-jsx-a11y` - Removed
|
|
339
|
+
- `eslint-plugin-jest` - Removed
|
|
340
|
+
- `eslint-plugin-playwright` - Removed
|
|
341
|
+
- `eslint-plugin-svelte` - Removed
|
|
342
|
+
- `eslint-plugin-react` - Replaced with [@eslint-react/eslint-plugin](https://github.com/Rel1cx/eslint-react)
|
|
343
|
+
- `eslint-plugin-react-hooks` - Replaced with [@eslint-react/eslint-plugin](https://github.com/Rel1cx/eslint-react)
|
|
344
|
+
|
|
345
|
+
The default settings now also include stricter typescript rules.
|
|
346
|
+
|
|
347
|
+
Follow these steps carefully and explain changes where non-trivial:
|
|
348
|
+
|
|
349
|
+
1. Update dependencies:
|
|
350
|
+
- Set `eslint` to the latest version (v10)
|
|
351
|
+
- Set `@qlik/eslint-config` to the latest version (v2)
|
|
352
|
+
|
|
353
|
+
2. Install dependencies and ensure there are no version conflicts.
|
|
354
|
+
|
|
355
|
+
3. Remove or update any constraints that block ESLint or upgrades:
|
|
356
|
+
- `resolutions`, `overrides`, or pinned versions in `package.json`
|
|
357
|
+
- `.ncurc.json` rules preventing upgrades
|
|
358
|
+
|
|
359
|
+
4. Migrate ESLint config to be compatible with ESLint 10:
|
|
360
|
+
- Ensure flat config format is used (`eslint.config.js/ts`)
|
|
361
|
+
- Import `defineConfig` from `"eslint/config"`
|
|
362
|
+
- Replace any usage of `qlik.compose` with `defineConfig` where applicable
|
|
363
|
+
- Replace any usage of `extend` with `extends`
|
|
364
|
+
- Ensure plugins and configs are compatible with ESLint 10
|
|
365
|
+
|
|
366
|
+
5. Run `npx eslint . --fix`
|
|
367
|
+
|
|
368
|
+
6. Handle remaining issues:
|
|
369
|
+
- Prefer code fixes over disabling rules
|
|
370
|
+
- Only disable rules if absolutely necessary
|
|
371
|
+
- For every disabled rule, add a comment explaining why
|
|
372
|
+
|
|
373
|
+
7. Validation:
|
|
374
|
+
- ESLint runs without errors
|
|
375
|
+
- No critical rules are disabled silently
|
|
376
|
+
- The project builds and tests still pass
|
|
377
|
+
|
|
378
|
+
8. Output:
|
|
379
|
+
- Summary of changes made
|
|
380
|
+
- List of rules disabled (if any) with justification
|
|
381
|
+
- Any potential risks or follow-ups
|
|
269
382
|
|
|
383
|
+
Important:
|
|
384
|
+
- Do not make changes that alter runtime behavior or business logic.
|
|
385
|
+
- If uncertain, ask before making destructive or unclear changes.
|
|
270
386
|
```
|
|
271
387
|
|
|
272
388
|
<!-- prettier-ignore-end -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlik/eslint-config",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Qlik's ESLint configs",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "git@github.com:qlik-oss/dev-tools-js.git",
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"registry": "https://registry.npmjs.org/"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@eslint-react/eslint-plugin": "^4.2.
|
|
22
|
+
"@eslint-react/eslint-plugin": "^4.2.3",
|
|
23
23
|
"@eslint/js": "^10.0.1",
|
|
24
|
-
"@typescript-eslint/utils": "^8.58.
|
|
25
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
24
|
+
"@typescript-eslint/utils": "^8.58.2",
|
|
25
|
+
"@vitest/eslint-plugin": "^1.6.16",
|
|
26
26
|
"confusing-browser-globals": "^1.0.11",
|
|
27
27
|
"eslint-config-prettier": "^10.1.8",
|
|
28
28
|
"eslint-import-resolver-node": "^0.3.10",
|
|
29
29
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
30
30
|
"eslint-plugin-import-x": "^4.16.2",
|
|
31
31
|
"eslint-plugin-testing-library": "^7.16.2",
|
|
32
|
-
"globals": "^17.
|
|
33
|
-
"typescript-eslint": "^8.58.
|
|
32
|
+
"globals": "^17.5.0",
|
|
33
|
+
"typescript-eslint": "^8.58.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/confusing-browser-globals": "^1.0.3",
|
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"check-types": "tsc --noEmit",
|
|
47
|
+
"format:check": "oxfmt --check .",
|
|
48
|
+
"format:write": "oxfmt .",
|
|
47
49
|
"test": "vitest run && ./test/verify-configs.sh"
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -104,6 +104,10 @@ const rules = {
|
|
|
104
104
|
// https://eslint.org/docs/rules/no-proto
|
|
105
105
|
"no-proto": "error",
|
|
106
106
|
|
|
107
|
+
// disallow declaring the same variable more than once
|
|
108
|
+
// https://eslint.org/docs/rules/no-redeclare
|
|
109
|
+
"no-redeclare": "error",
|
|
110
|
+
|
|
107
111
|
// disallow certain object properties
|
|
108
112
|
// https://eslint.org/docs/rules/no-restricted-properties
|
|
109
113
|
"no-restricted-properties": [
|
|
@@ -271,6 +275,16 @@ const rules = {
|
|
|
271
275
|
},
|
|
272
276
|
],
|
|
273
277
|
|
|
278
|
+
// disallow specific imports
|
|
279
|
+
// https://eslint.org/docs/rules/no-restricted-imports
|
|
280
|
+
"no-restricted-imports": [
|
|
281
|
+
"off",
|
|
282
|
+
{
|
|
283
|
+
paths: [],
|
|
284
|
+
patterns: [],
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
|
|
274
288
|
// disallow useless computed property keys
|
|
275
289
|
// https://eslint.org/docs/rules/no-useless-computed-key
|
|
276
290
|
"no-useless-computed-key": "error",
|
|
@@ -9,12 +9,151 @@ import eslintCoreRules from "./eslint-core.js";
|
|
|
9
9
|
const rules = {
|
|
10
10
|
// modify/add rules from typescript-eslint package here additionally to the recommended rules
|
|
11
11
|
|
|
12
|
+
// note some eslint core rules are disabled by tsconfig https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended-raw.ts
|
|
12
13
|
// turn off core rules superseded by @typescript-eslint equivalents
|
|
14
|
+
|
|
15
|
+
// enforce consistent type imports
|
|
16
|
+
// https://typescript-eslint.io/rules/consistent-type-imports
|
|
17
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
18
|
+
|
|
19
|
+
// enforce default parameters to be last
|
|
20
|
+
// https://typescript-eslint.io/rules/default-param-last
|
|
21
|
+
"default-param-last": "off",
|
|
22
|
+
"@typescript-eslint/default-param-last": eslintCoreRules["default-param-last"],
|
|
23
|
+
|
|
24
|
+
// enforce method signatures has the same style
|
|
25
|
+
// https://typescript-eslint.io/rules/method-signature-style
|
|
26
|
+
"@typescript-eslint/method-signature-style": "error",
|
|
27
|
+
|
|
28
|
+
// don't use the delete operator on dynamic properties
|
|
29
|
+
// https://typescript-eslint.io/rules/no-dynamic-delete
|
|
30
|
+
"@typescript-eslint/no-dynamic-delete": "error",
|
|
31
|
+
|
|
32
|
+
// use top-level type imports
|
|
33
|
+
// https://typescript-eslint.io/rules/no-import-type-side-effects
|
|
34
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
35
|
+
|
|
36
|
+
// don't use void where it shouldn't be used
|
|
37
|
+
// https://typescript-eslint.io/rules/no-invalid-void-type
|
|
38
|
+
"@typescript-eslint/no-invalid-void-type": "error",
|
|
39
|
+
|
|
40
|
+
// don't do weird things in loops
|
|
41
|
+
// https://typescript-eslint.io/rules/no-loop-func
|
|
42
|
+
"no-loop-func": "off",
|
|
43
|
+
"@typescript-eslint/no-loop-func": eslintCoreRules["no-loop-func"],
|
|
44
|
+
|
|
45
|
+
// disallow non-null assertions in the left operand of a nullish coalescing operator.
|
|
46
|
+
// https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing
|
|
47
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
|
|
48
|
+
|
|
49
|
+
// https://typescript-eslint.io/rules/no-non-null-assertion
|
|
50
|
+
"@typescript-eslint/no-non-null-assertion": "error",
|
|
51
|
+
|
|
52
|
+
// don't allow redeclaration of variables
|
|
53
|
+
// https://typescript-eslint.io/rules/no-redeclare
|
|
54
|
+
"no-redeclare": "off",
|
|
55
|
+
"@typescript-eslint/no-redeclare": eslintCoreRules["no-redeclare"],
|
|
56
|
+
|
|
57
|
+
// add forbidden imports if needed
|
|
58
|
+
// https://typescript-eslint.io/rules/no-restricted-imports
|
|
59
|
+
"no-restricted-imports": "off",
|
|
60
|
+
"@typescript-eslint/no-restricted-imports": eslintCoreRules["no-restricted-imports"],
|
|
61
|
+
|
|
62
|
+
// add forbidden types if needed
|
|
63
|
+
// https://typescript-eslint.io/rules/no-restricted-types
|
|
64
|
+
"@typescript-eslint/no-restricted-types": ["error", {}],
|
|
65
|
+
|
|
13
66
|
// shadows from outer scopes are not allowed
|
|
14
67
|
// https://typescript-eslint.io/rules/no-shadow
|
|
15
68
|
"no-shadow": "off",
|
|
16
69
|
"@typescript-eslint/no-shadow": eslintCoreRules["no-shadow"],
|
|
17
70
|
|
|
71
|
+
// no unnecessary assignment of constructor property parameter.
|
|
72
|
+
// https://typescript-eslint.io/rules/no-unnecessary-parameter-property-assignment
|
|
73
|
+
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
|
|
74
|
+
|
|
75
|
+
// don't use stuff that hasn't been defined
|
|
76
|
+
// https://typescript-eslint.io/rules/no-useless-constructor
|
|
77
|
+
"no-useless-constructor": "off",
|
|
78
|
+
"@typescript-eslint/no-useless-constructor": eslintCoreRules["no-useless-constructor"],
|
|
79
|
+
|
|
80
|
+
// yes, please initialize your enums
|
|
81
|
+
// https://typescript-eslint.io/rules/prefer-enum-initializers
|
|
82
|
+
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
83
|
+
|
|
84
|
+
// enums are not based on dynamic values
|
|
85
|
+
// https://typescript-eslint.io/rules/prefer-literal-enum-member
|
|
86
|
+
"@typescript-eslint/prefer-literal-enum-member": "error",
|
|
87
|
+
|
|
88
|
+
// disallow two overloads that could be unified into one with a union or an optional/rest parameter.
|
|
89
|
+
// https://typescript-eslint.io/rules/unified-signatures
|
|
90
|
+
"@typescript-eslint/unified-signatures": "error",
|
|
91
|
+
|
|
92
|
+
// enforce explicityly set type exports
|
|
93
|
+
// https://typescript-eslint.io/rules/consistent-type-exports
|
|
94
|
+
"@typescript-eslint/consistent-type-exports": "error",
|
|
95
|
+
|
|
96
|
+
// void should not be assigned to variables
|
|
97
|
+
// https://typescript-eslint.io/rules/no-confusing-void-expression
|
|
98
|
+
"@typescript-eslint/no-confusing-void-expression": "error",
|
|
99
|
+
|
|
100
|
+
// https://typescript-eslint.io/rules/no-floating-promises
|
|
101
|
+
"@typescript-eslint/no-floating-promises": [
|
|
102
|
+
"error",
|
|
103
|
+
{
|
|
104
|
+
ignoreIIFE: true,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
|
|
108
|
+
// remove void when it's not needed
|
|
109
|
+
// https://typescript-eslint.io/rules/no-meaningless-void-operator
|
|
110
|
+
"@typescript-eslint/no-meaningless-void-operator": "error",
|
|
111
|
+
|
|
112
|
+
// https://typescript-eslint.io/rules/no-misused-promises
|
|
113
|
+
"@typescript-eslint/no-misused-promises": [
|
|
114
|
+
"error",
|
|
115
|
+
{
|
|
116
|
+
checksConditionals: false,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
|
|
120
|
+
// use constistent enum types
|
|
121
|
+
// https://typescript-eslint.io/rules/no-mixed-enums
|
|
122
|
+
"@typescript-eslint/no-mixed-enums": "error",
|
|
123
|
+
|
|
124
|
+
// don't do silly comparisons
|
|
125
|
+
// https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
|
|
126
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
|
|
127
|
+
|
|
128
|
+
// no unnecessary namespace qualifiers.
|
|
129
|
+
// https://typescript-eslint.io/rules/no-unnecessary-qualifier
|
|
130
|
+
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
131
|
+
|
|
132
|
+
// Disallow conditionals where the type is always truthy or always falsy - https://typescript-eslint.io/rules/no-unnecessary-condition
|
|
133
|
+
"@typescript-eslint/no-unnecessary-condition": "error",
|
|
134
|
+
|
|
135
|
+
// no need for template literals if they just refer to a string
|
|
136
|
+
// https://typescript-eslint.io/rules/no-unnecessary-template-expression
|
|
137
|
+
"@typescript-eslint/no-unnecessary-template-expression": "error",
|
|
138
|
+
|
|
139
|
+
// don't use type arguments when they're not needed
|
|
140
|
+
// https://typescript-eslint.io/rules/no-unnecessary-type-arguments
|
|
141
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
|
142
|
+
|
|
143
|
+
// reducers should be typed correctly
|
|
144
|
+
// https://typescript-eslint.io/rules/prefer-reduce-type-parameter
|
|
145
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "error",
|
|
146
|
+
|
|
147
|
+
// https://typescript-eslint.io/rules/prefer-return-this-type
|
|
148
|
+
"@typescript-eslint/prefer-return-this-type": "error",
|
|
149
|
+
|
|
150
|
+
// Require switch-case statements to be exhaustive - https://typescript-eslint.io/rules/switch-exhaustiveness-check
|
|
151
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
152
|
+
|
|
153
|
+
// enforce typing arguments in Promise rejection callbacks as unknown
|
|
154
|
+
// https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
|
|
155
|
+
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
|
|
156
|
+
|
|
18
157
|
// Replace camelcase' rule with '@typescript-eslint/naming-convention'
|
|
19
158
|
// https://typescript-eslint.io/rules/naming-convention/
|
|
20
159
|
camelcase: "off",
|
package/src/configs/vitest.js
CHANGED
|
@@ -7,19 +7,48 @@ import { mergeConfigs } from "../utils/config.js";
|
|
|
7
7
|
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
8
8
|
* config for vitest https://github.com/vitest/eslint-plugin-vitest
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
10
|
+
const vitestJS = mergeConfigs(
|
|
11
11
|
// base it on the recommended vitest config
|
|
12
12
|
vitestPlugin.configs.recommended,
|
|
13
13
|
// add testing-library plugin recommended config for react
|
|
14
14
|
testingLibraryPlugin.configs["flat/react"],
|
|
15
15
|
// add qlik's recommended vitest config
|
|
16
16
|
{
|
|
17
|
-
name: "vitest",
|
|
18
|
-
files: ["**/__test__/**/*.{js,jsx
|
|
17
|
+
name: "vitest-js",
|
|
18
|
+
files: ["**/__test__/**/*.{js,jsx}", "**/__tests__/**/*.{js,jsx}", "mocks/**/*.js"],
|
|
19
19
|
rules: {
|
|
20
|
-
// modify rules
|
|
20
|
+
// turn off/modify rules that suitable for tests in JavaScript
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @type {import("../types/index.js").ESLintFlatConfig}
|
|
27
|
+
* TypeScript-only vitest overrides
|
|
28
|
+
*/
|
|
29
|
+
const vitestTS = mergeConfigs(
|
|
30
|
+
// base it on the recommended vitest config
|
|
31
|
+
vitestPlugin.configs.recommended,
|
|
32
|
+
// add testing-library plugin recommended config for react
|
|
33
|
+
testingLibraryPlugin.configs["flat/react"],
|
|
34
|
+
// add qlik's recommended vitest config
|
|
35
|
+
{
|
|
36
|
+
name: "vitest-ts",
|
|
37
|
+
files: ["**/__test__/**/*.{ts,tsx}", "**/__tests__/**/*.{ts,tsx}", "mocks/**/*.ts"],
|
|
38
|
+
rules: {
|
|
39
|
+
// turn off/modify rules that suitable for tests in TypeScript
|
|
40
|
+
|
|
41
|
+
// turn off all the rules that are too strict for tests, and warn on any explicit any types
|
|
42
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
43
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
44
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
45
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
46
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
47
|
+
"@typescript-eslint/unbound-method": "off",
|
|
48
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
49
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export default [vitestJS, vitestTS];
|