@qlik/eslint-config 2.0.0-next.1 → 2.0.1

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
@@ -253,13 +253,19 @@ 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` - Replacd with [@eslint-react/eslint-plugin](https://github.com/Rel1cx/eslint-react)
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. Some rules might have changed, been added or removed so you will likely get new errors/warnings that needs to be addressed
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
 
@@ -288,8 +294,7 @@ export default qlik.compose(
288
294
 
289
295
  1. add `import { defineConfig } from "eslint/config";`
290
296
  2. replace `qlik.compose` with `defineConfig`
291
- 3. remove the `...` from the imported configs
292
- 4. replace `extend` with `extends` (if present)
297
+ 3. replace `extend` with `extends` (if present)
293
298
 
294
299
  new config:
295
300
 
@@ -315,4 +320,69 @@ export default defineConfig(
315
320
  );
316
321
  ```
317
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
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.
386
+ ```
387
+
318
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-next.1",
3
+ "version": "2.0.1",
4
4
  "description": "Qlik's ESLint configs",
5
5
  "license": "ISC",
6
6
  "repository": "git@github.com:qlik-oss/dev-tools-js.git",
@@ -21,16 +21,16 @@
21
21
  "dependencies": {
22
22
  "@eslint-react/eslint-plugin": "^4.2.3",
23
23
  "@eslint/js": "^10.0.1",
24
- "@typescript-eslint/utils": "^8.58.0",
25
- "@vitest/eslint-plugin": "^1.6.14",
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.4.0",
33
- "typescript-eslint": "^8.58.0"
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
  }
@@ -1,5 +1,6 @@
1
1
  import js from "@eslint/js";
2
- import { importX } from "eslint-plugin-import-x";
2
+ import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
3
+ import { createNodeResolver, importX } from "eslint-plugin-import-x";
3
4
  import globals from "globals";
4
5
  import tsconfig from "typescript-eslint";
5
6
  import { mergeConfigs } from "../../utils/config.js";
@@ -70,6 +71,12 @@ const baseConfigTS = mergeConfigs(
70
71
  projectService: true,
71
72
  },
72
73
  },
74
+ settings: {
75
+ // Use import-x resolver-next for TypeScript and keep node resolution as fallback.
76
+ "import-x/resolver-next": [createTypeScriptImportResolver({ alwaysTryTypes: true }), createNodeResolver()],
77
+ // Disable legacy resolver config from the import-x TypeScript preset.
78
+ "import-x/resolver": false,
79
+ },
73
80
  rules: {
74
81
  ...typescriptRules,
75
82
  // add qlik's recommended typescript config for typescript here if needed
@@ -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 vitest = mergeConfigs(
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,ts,tsx}", "**/__tests__/**/*.{js,jsx,ts,tsx}"],
17
+ name: "vitest-js",
18
+ files: ["**/__test__/**/*.{js,jsx}", "**/__tests__/**/*.{js,jsx}", "mocks/**/*.js"],
19
19
  rules: {
20
- // modify rules from eslint-plugin-vitest here
20
+ // turn off/modify rules that suitable for tests in JavaScript
21
21
  },
22
22
  },
23
23
  );
24
24
 
25
- export default [vitest];
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];