eslint-config-deepcrawl 16.0.5 → 17.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.
Files changed (3) hide show
  1. package/README.md +62 -0
  2. package/index.js +30 -11
  3. package/package.json +12 -11
package/README.md CHANGED
@@ -61,6 +61,68 @@ Apart from ESLint, it is recommended to use the following Prettier configuration
61
61
 
62
62
  with `lint-staged` pre-commit hook done via `husky`.
63
63
 
64
+ ## Migrating from v16
65
+
66
+ v17 replaces `eslint-plugin-jest` with `@vitest/eslint-plugin`. To upgrade:
67
+
68
+ 1. Rename every `jest/*` rule reference in your `eslint.config.*` to
69
+ `vitest/*`. For example, `"jest/expect-expect"` becomes
70
+ `"vitest/expect-expect"`. ESLint silently ignores unknown rule names
71
+ set to `"off"`, so if you miss a rename, your override stops working
72
+ without an error.
73
+ 2. If you still use Jest, the same rules lint Jest tests, because the test
74
+ APIs are largely compatible. However, these rules are gone:
75
+ `no-deprecated-functions`, `no-export` and `no-jasmine-globals` have no
76
+ Vitest equivalent, and `vitest/no-done-callback` is deprecated because
77
+ Vitest does not support `done` callbacks. The Jest-only globals (`jest`,
78
+ `fit`, `xit`, `xtest`, `xdescribe`) are no longer declared either.
79
+ 3. `@typescript-eslint/unbound-method` is replaced by
80
+ `vitest/unbound-method` in TypeScript files. The Vitest rule reports
81
+ the same problems but allows passing a method to `expect()` (for
82
+ example `expect(client.getAccount).toHaveBeenCalled()`) and to
83
+ `vi.mocked()`. Rename any `eslint-disable` comments and config overrides
84
+ for `@typescript-eslint/unbound-method` to `vitest/unbound-method`.
85
+ Remove the disable comments that only worked around mock expectations.
86
+ Old disable comments are reported as unused.
87
+ 4. Vitest globals are required. `vitest/no-importing-vitest-globals`
88
+ reports imports of `describe`, `it`, `expect`, `vi` and the other
89
+ globals from `vitest`. Type imports such as `Mock` are still allowed.
90
+ Enable globals in your Vitest config and add the global types to your
91
+ `tsconfig.json`:
92
+
93
+ ```ts
94
+ // vitest.config.ts
95
+ export default defineConfig({ test: { globals: true } });
96
+ ```
97
+
98
+ ```json
99
+ { "compilerOptions": { "types": ["vitest/globals"] } }
100
+ ```
101
+
102
+ `eslint --fix` removes the imports.
103
+
104
+ 5. Tests must use `it`, not `test`, both at the top level and inside
105
+ `describe` (`vitest/consistent-test-it`). `eslint --fix` renames them.
106
+ 6. These rules are new. Most of them can be fixed with `eslint --fix`:
107
+ - From the Vitest recommended preset: `vitest/no-import-node-test`,
108
+ `vitest/no-unneeded-async-expect-function`,
109
+ `vitest/prefer-called-exactly-once-with` and
110
+ `vitest/require-local-test-context-for-concurrent-snapshots`.
111
+ - Added by this config: `vitest/no-test-return-statement`,
112
+ `vitest/prefer-comparison-matcher`, `vitest/prefer-equality-matcher`,
113
+ `vitest/prefer-hooks-in-order`, `vitest/prefer-hooks-on-top`,
114
+ `vitest/prefer-mock-promise-shorthand`, `vitest/prefer-to-contain`,
115
+ `vitest/prefer-to-have-length`, `vitest/prefer-todo`,
116
+ `vitest/prefer-vi-mocked` and `vitest/require-awaited-expect-poll`.
117
+
118
+ ## Migrating from v15
119
+
120
+ v16.0.0 fixed the `@stylistic/max-len` ignore pattern, which had been
121
+ exempting every line, so long lines started to report errors. v16.0.1 then
122
+ removed `@stylistic/max-len` altogether and left line length to Prettier.
123
+ If you upgrade straight to v16.0.1 or later, you don't need to change
124
+ anything. If you added overrides to work around v16.0.0, you can remove them.
125
+
64
126
  ## Migrating from v14
65
127
 
66
128
  v15 upgrades to ESLint 10 and replaces `eslint-plugin-import` with its
package/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import eslintJs from "@eslint/js";
2
2
  import stylisticPlugin from "@stylistic/eslint-plugin";
3
+ import vitestPlugin from "@vitest/eslint-plugin";
3
4
  import { defineConfig } from "eslint/config";
4
5
  import eslintConfigPrettier from "eslint-config-prettier/flat";
5
6
  import arrayFuncPlugin from "eslint-plugin-array-func";
6
7
  import importXPlugin from "eslint-plugin-import-x";
7
- import jestPlugin from "eslint-plugin-jest";
8
8
  import nodePlugin from "eslint-plugin-n";
9
9
  import noLoopsPlugin from "eslint-plugin-no-loops";
10
10
  import packageJsonPlugin from "eslint-plugin-package-json";
@@ -17,7 +17,8 @@ export default defineConfig([
17
17
  eslintJs.configs.recommended,
18
18
  importXPlugin.flatConfigs.recommended,
19
19
  importXPlugin.flatConfigs.typescript,
20
- jestPlugin.configs["flat/recommended"],
20
+ vitestPlugin.configs.recommended,
21
+ vitestPlugin.configs.env,
21
22
  nodePlugin.configs["flat/recommended"],
22
23
  promisePlugin.configs["flat/recommended"],
23
24
  {
@@ -168,7 +169,9 @@ export default defineConfig([
168
169
  "@typescript-eslint/require-array-sort-compare": "error",
169
170
  "@typescript-eslint/restrict-template-expressions": "off",
170
171
  "@typescript-eslint/return-await": "error",
172
+ "@typescript-eslint/unbound-method": "off",
171
173
  "@typescript-eslint/unified-signatures": "error",
174
+ "vitest/unbound-method": "error",
172
175
  },
173
176
  },
174
177
  {
@@ -193,15 +196,6 @@ export default defineConfig([
193
196
  groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
194
197
  },
195
198
  ],
196
- "jest/expect-expect": "error",
197
- "jest/padding-around-after-all-blocks": "error",
198
- "jest/padding-around-after-each-blocks": "error",
199
- "jest/padding-around-before-all-blocks": "error",
200
- "jest/padding-around-before-each-blocks": "error",
201
- "jest/padding-around-describe-blocks": "error",
202
- "jest/padding-around-test-blocks": "error",
203
- "jest/prefer-expect-resolves": "error",
204
- "jest/prefer-to-be": "error",
205
199
  "max-classes-per-file": ["error", 1],
206
200
  "max-lines-per-function": ["warn", { max: 40, skipBlankLines: true, skipComments: true, IIFEs: true }],
207
201
  "max-params": ["error", 7],
@@ -226,6 +220,31 @@ export default defineConfig([
226
220
  "object-shorthand": "error",
227
221
  "prefer-template": "error",
228
222
  "promise/prefer-await-to-then": "error",
223
+ "vitest/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
224
+ "vitest/expect-expect": "error",
225
+ "vitest/no-alias-methods": "error",
226
+ "vitest/no-commented-out-tests": "warn",
227
+ "vitest/no-importing-vitest-globals": "error",
228
+ "vitest/no-test-prefixes": "error",
229
+ "vitest/no-test-return-statement": "error",
230
+ "vitest/padding-around-after-all-blocks": "error",
231
+ "vitest/padding-around-after-each-blocks": "error",
232
+ "vitest/padding-around-before-all-blocks": "error",
233
+ "vitest/padding-around-before-each-blocks": "error",
234
+ "vitest/padding-around-describe-blocks": "error",
235
+ "vitest/padding-around-test-blocks": "error",
236
+ "vitest/prefer-comparison-matcher": "error",
237
+ "vitest/prefer-equality-matcher": "error",
238
+ "vitest/prefer-expect-resolves": "error",
239
+ "vitest/prefer-hooks-in-order": "error",
240
+ "vitest/prefer-hooks-on-top": "error",
241
+ "vitest/prefer-mock-promise-shorthand": "error",
242
+ "vitest/prefer-to-be": "error",
243
+ "vitest/prefer-to-contain": "error",
244
+ "vitest/prefer-to-have-length": "error",
245
+ "vitest/prefer-todo": "error",
246
+ "vitest/prefer-vi-mocked": "error",
247
+ "vitest/require-awaited-expect-poll": "error",
229
248
  },
230
249
  },
231
250
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-deepcrawl",
3
- "version": "16.0.5",
3
+ "version": "17.0.0",
4
4
  "description": "ESLint rules recommended by Lumar (formerly DeepCrawl).",
5
5
  "homepage": "https://github.com/deepcrawl/eslint-config",
6
6
  "bugs": {
@@ -24,27 +24,28 @@
24
24
  "dependencies": {
25
25
  "@eslint/js": "^10.0.1",
26
26
  "@stylistic/eslint-plugin": "^5.10.0",
27
+ "@typescript-eslint/eslint-plugin": "^8.71.0",
28
+ "@vitest/eslint-plugin": "^1.6.27",
27
29
  "eslint-config-prettier": "^10.1.8",
28
- "eslint-import-resolver-typescript": "^4.4.4",
30
+ "eslint-import-resolver-typescript": "^4.4.5",
29
31
  "eslint-plugin-array-func": "^5.1.1",
30
- "eslint-plugin-import-x": "^4.16.2",
31
- "eslint-plugin-jest": "^29.15.2",
32
- "eslint-plugin-n": "^18.0.1",
32
+ "eslint-plugin-import-x": "^4.17.1",
33
+ "eslint-plugin-n": "^18.4.0",
33
34
  "eslint-plugin-no-loops": "^0.4.0",
34
- "eslint-plugin-package-json": "^1.1.0",
35
+ "eslint-plugin-package-json": "^1.10.1",
35
36
  "eslint-plugin-promise": "^7.3.0",
36
- "eslint-plugin-sonarjs": "^4.0.3",
37
- "typescript-eslint": "^8.59.4"
37
+ "eslint-plugin-sonarjs": "^4.2.2",
38
+ "typescript-eslint": "^8.71.0"
38
39
  },
39
40
  "devDependencies": {
40
- "prettier": "3.8.3",
41
+ "prettier": "3.9.9",
41
42
  "prettier-plugin-packagejson": "3.0.2"
42
43
  },
43
44
  "peerDependencies": {
44
45
  "eslint": "^10.0.0",
45
- "typescript": ">=5.8"
46
+ "typescript": ">=5.9"
46
47
  },
47
- "packageManager": "yarn@4.14.1",
48
+ "packageManager": "yarn@4.18.1",
48
49
  "publishConfig": {
49
50
  "registry": "https://registry.npmjs.org/"
50
51
  }