eslint-config-webpack 4.15.0 → 5.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 (35) hide show
  1. package/README.md +48 -4
  2. package/configs/browser.js +70 -7
  3. package/configs/index.js +7 -6
  4. package/configs/javascript.js +746 -151
  5. package/configs/json.js +72 -0
  6. package/configs/markdown.js +111 -6
  7. package/configs/node.js +78 -23
  8. package/configs/performance.js +8 -0
  9. package/configs/react.js +7 -19
  10. package/configs/stylistic.js +17 -0
  11. package/configs/{jest.js → test.js} +65 -5
  12. package/configs/typescript.js +39 -10
  13. package/configs/utils/code-files.js +20 -0
  14. package/configs/utils/get-es-version-from-node.js +9 -4
  15. package/configs/utils/get-json-file.js +1 -5
  16. package/configs/utils/is-jest-installed.js +20 -0
  17. package/configs/utils/is-typescript-installed.js +3 -3
  18. package/configs.js +47 -31
  19. package/package.json +31 -26
  20. package/plugins/package-json/index.js +0 -5
  21. package/plugins/package-json/rules/order-properties.js +8 -18
  22. package/plugins/performance/index.js +60 -0
  23. package/plugins/performance/rules/no-case-insensitive-unicode-range.js +214 -0
  24. package/plugins/performance/rules/require-precompiled-schema.js +414 -0
  25. package/plugins/webpack/index.js +0 -1
  26. package/plugins/webpack/rules/comment-length.js +1 -3
  27. package/plugins/webpack/rules/format-schema.js +18 -16
  28. package/plugins/webpack/rules/inherit-jsdoc.js +2 -3
  29. package/plugins/webpack/rules/no-duplicate-import-tag.js +3 -4
  30. package/plugins/webpack/rules/no-unused-import-tag.js +8 -11
  31. package/plugins/webpack/rules/prefer-import-tag.js +1 -2
  32. package/plugins/webpack/rules/require-license-comment.js +3 -5
  33. package/plugins/webpack/rules/valid-schema.js +9 -13
  34. package/plugins/webpack/utils/import-tags.js +4 -3
  35. package/configs/package-json.js +0 -8
@@ -0,0 +1,72 @@
1
+ import jsonPlugin from "@eslint/json";
2
+ import unicornPlugin from "eslint-plugin-unicorn";
3
+ import packagePlugin from "../plugins/package-json/index.js";
4
+
5
+ /**
6
+ * @returns {Promise<import("eslint").Linter.Config[]>} config
7
+ */
8
+ async function getJsonRecommendedConfig() {
9
+ return [
10
+ {
11
+ name: "json/recommended",
12
+ files: ["**/*.json"],
13
+ ignores: ["**/package-lock.json"],
14
+ plugins: {
15
+ json: jsonPlugin,
16
+ unicorn: unicornPlugin,
17
+ package: packagePlugin,
18
+ },
19
+ language: "json/json",
20
+ rules: {
21
+ ...jsonPlugin.configs.recommended.rules,
22
+
23
+ // From recommended
24
+ // "json/no-duplicate-keys": "error",
25
+
26
+ // From recommended
27
+ // "json/no-empty-keys": "error",
28
+
29
+ // From recommended
30
+ // "json/no-unnormalized-keys": "error",
31
+
32
+ // From recommended
33
+ // "json/no-unsafe-values": "error",
34
+
35
+ // No need
36
+ // "json/sort-keys": "off",
37
+
38
+ "json/top-level-interop": "error",
39
+
40
+ // `package.json` rules
41
+
42
+ "package/order-properties": "error",
43
+
44
+ // `unicorn` rules that support JSON and that we use for
45
+
46
+ "unicorn/escape-case": "error",
47
+
48
+ "unicorn/no-abusive-eslint-disable": "error",
49
+
50
+ "unicorn/no-empty-file": "error",
51
+
52
+ "unicorn/no-leading-empty-lines": "error",
53
+
54
+ "unicorn/no-zero-fractions": "error",
55
+
56
+ "unicorn/prefer-escaped-irregular-whitespace": "error",
57
+
58
+ "unicorn/prefer-https": "error",
59
+
60
+ "unicorn/prefer-literal-ascii": "error",
61
+
62
+ "unicorn/prefer-short-escape-sequences": "error",
63
+
64
+ "unicorn/no-loss-of-precision": "error",
65
+ },
66
+ },
67
+ ];
68
+ }
69
+
70
+ export default {
71
+ "json/recommended": await getJsonRecommendedConfig(),
72
+ };
@@ -1,19 +1,124 @@
1
+ import markdownPlugin from "@eslint/markdown";
2
+ import unicornPlugin from "eslint-plugin-unicorn";
1
3
  import isTypescriptInstalled from "./utils/is-typescript-installed.js";
2
4
 
5
+ /** @typedef {import("eslint").Linter.Processor} Processor */
6
+ /** @typedef {import("eslint").Linter.LintMessage & { probe?: { block: number, line: number } }} Message */
7
+
3
8
  /**
4
9
  * @returns {Promise<import("eslint").Linter.Config[]>} config
5
10
  */
6
11
  async function getMarkdownRecommendedConfig() {
7
- const markdownPlugin = (await import("@eslint/markdown")).default;
12
+ const {
13
+ configs: { recommended },
14
+ } =
15
+ /** @type {{ configs: { recommended: import("eslint").Linter.Config[] } }} */ (
16
+ /** @type {unknown} */ (markdownPlugin)
17
+ );
8
18
 
9
19
  return [
10
20
  {
11
- name: "markdown/code-blocks",
21
+ name: "markdown/recommended",
12
22
  files: ["**/*.md"],
13
- processor: "markdown/markdown",
23
+ // GitHub renders our Markdown, so tables, task lists and the like are valid
24
+ language: "markdown/gfm",
14
25
  plugins: {
15
- // @ts-expect-error bad types
16
26
  markdown: markdownPlugin,
27
+ unicorn: unicornPlugin,
28
+ },
29
+ // Same as for JavaScript, so a `<!-- eslint-disable -->` comment that
30
+ // disables nothing fails the lint
31
+ linterOptions: {
32
+ reportUnusedDisableDirectives: "error",
33
+ reportUnusedInlineConfigs: "error",
34
+ },
35
+ rules: {
36
+ ...recommended.find((config) => config.name === "markdown/recommended")
37
+ ?.rules,
38
+
39
+ // From recommended
40
+ // "markdown/fenced-code-language": "error",
41
+
42
+ // No need
43
+ "markdown/fenced-code-meta": "off",
44
+
45
+ // From recommended
46
+ // "markdown/heading-increment": "error",
47
+
48
+ // No need
49
+ "markdown/no-bare-urls": "off",
50
+
51
+ // From recommended
52
+ // "markdown/no-duplicate-definitions": "error",
53
+
54
+ "markdown/no-duplicate-headings": [
55
+ "error",
56
+ { checkSiblingsOnly: true },
57
+ ],
58
+
59
+ // From recommended
60
+ // "markdown/no-empty-definitions": "error",
61
+
62
+ // From recommended
63
+ // "markdown/no-empty-images": "error",
64
+
65
+ // From recommended
66
+ // "markdown/no-empty-links": "error",
67
+
68
+ // No need
69
+ "markdown/no-html": "off",
70
+
71
+ // From recommended
72
+ // "markdown/no-invalid-label-refs": "error",
73
+
74
+ // From recommended
75
+ // "markdown/no-missing-atx-heading-space": "error",
76
+
77
+ // From recommended
78
+ "markdown/no-missing-label-refs": [
79
+ "error",
80
+ { allowLabels: ["!REQUIRED"] },
81
+ ],
82
+
83
+ // From recommended
84
+ // "markdown/no-missing-link-fragments": "error",
85
+
86
+ // From recommended
87
+ // "markdown/no-multiple-h1": "error",
88
+
89
+ // From recommended
90
+ // "markdown/no-reference-like-urls": "error",
91
+
92
+ // From recommended
93
+ // "markdown/no-reversed-media-syntax": "error",
94
+
95
+ // From recommended
96
+ // "markdown/no-space-in-emphasis": "error",
97
+
98
+ // From recommended
99
+ // "markdown/no-unused-definitions": "error",
100
+
101
+ // From recommended
102
+ // TODO enable in future
103
+ "markdown/require-alt-text": "off",
104
+
105
+ "markdown/table-column-count": ["error", { checkMissingCells: true }],
106
+
107
+ // `unicorn` rules that support Markdown and that we use for
108
+
109
+ "unicorn/no-abusive-eslint-disable": "error",
110
+
111
+ "unicorn/no-empty-file": "error",
112
+
113
+ "unicorn/no-empty-link-text": "error",
114
+
115
+ "unicorn/no-leading-empty-lines": "error",
116
+
117
+ "unicorn/no-javascript-url": "error",
118
+
119
+ "unicorn/relative-url-style": ["error", "always"],
120
+
121
+ "unicorn/prefer-https": "error",
17
122
  },
18
123
  },
19
124
  {
@@ -83,9 +188,9 @@ async function getMarkdownRecommendedConfig() {
83
188
  // Useful for documentation
84
189
  "n/no-process-exit": "off",
85
190
 
86
- "import/no-unresolved": "off",
191
+ "import-x/no-unresolved": "off",
87
192
 
88
- "import/no-extraneous-dependencies": "off",
193
+ "import-x/no-extraneous-dependencies": "off",
89
194
 
90
195
  "jsdoc/require-jsdoc": "off",
91
196
 
package/configs/node.js CHANGED
@@ -1,5 +1,9 @@
1
- import importPlugin from "eslint-plugin-import";
1
+ import importPlugin from "eslint-plugin-import-x";
2
+ import unicornPlugin from "eslint-plugin-unicorn";
2
3
  import globals from "globals";
4
+ import semver from "semver";
5
+ import { codeFiles, codeIgnores } from "./utils/code-files.js";
6
+ import getJsonFile from "./utils/get-json-file.js";
3
7
  import isTypescriptInstalled from "./utils/is-typescript-installed.js";
4
8
 
5
9
  /** @type {import("eslint").Linter.Config["rules"]} */
@@ -10,7 +14,7 @@ const commonRules = {
10
14
  // Depends on `sourceType` and enabled below only for commonjs
11
15
  // "n/exports-style": "error",
12
16
 
13
- // We have the `import/extensions` rule
17
+ // We have the `import-x/extensions` rule
14
18
  "n/file-extension-in-import": "off",
15
19
 
16
20
  // There is no need, as in some cases we want to load a module lazily.
@@ -31,19 +35,19 @@ const commonRules = {
31
35
  // From recommended
32
36
  // "n/no-exports-assign": "error",
33
37
 
34
- // We have `import/no-extraneous-dependencies` rule
38
+ // We have `import-x/no-extraneous-dependencies` rule
35
39
  "n/no-extraneous-import": "off",
36
40
 
37
- // We have `import/no-extraneous-dependencies` rule
41
+ // We have `import-x/no-extraneous-dependencies` rule
38
42
  "n/no-extraneous-require": "off",
39
43
 
40
44
  // Deprecated
41
45
  // "n/no-hide-core-modules": "error",
42
46
 
43
- // We have `import/no-unresolved` rule
47
+ // We have `import-x/no-unresolved` rule
44
48
  "n/no-missing-import": "off",
45
49
 
46
- // We have `import/no-unresolved` rule
50
+ // We have `import-x/no-unresolved` rule
47
51
  "n/no-missing-require": "off",
48
52
 
49
53
  // No need
@@ -160,8 +164,13 @@ const commonRules = {
160
164
 
161
165
  "n/prefer-global/url-search-params": ["error", "always"],
162
166
 
167
+ "n/prefer-import/assert-strict": "error",
168
+
163
169
  "n/prefer-node-protocol": "error",
164
170
 
171
+ // No need
172
+ // "n/prefer-process-get-builtin-module",
173
+
165
174
  // No need
166
175
  // "n/prefer-promises/dns": "error",
167
176
 
@@ -174,6 +183,28 @@ const commonRules = {
174
183
 
175
184
  const ignores = ["**/*.d.ts"];
176
185
 
186
+ /**
187
+ * @param {string} range the Node.js versions that have a feature
188
+ * @returns {boolean} true when every Node.js version `engines.node` allows has it,
189
+ * or when there is no `engines.node`
190
+ */
191
+ function isSupportedByEngines(range) {
192
+ const packageJson = getJsonFile("package.json");
193
+ const engines =
194
+ packageJson &&
195
+ /** @type {{ engines?: { node?: string } }} */ (packageJson).engines;
196
+
197
+ if (!engines || typeof engines.node !== "string") {
198
+ return true;
199
+ }
200
+
201
+ try {
202
+ return semver.subset(engines.node, range);
203
+ } catch {
204
+ return false;
205
+ }
206
+ }
207
+
177
208
  /**
178
209
  * @returns {Promise<import("eslint").Linter.Config>} config
179
210
  */
@@ -187,14 +218,18 @@ async function getCommonJSConfig() {
187
218
  ignores,
188
219
  plugins: {
189
220
  ...nodeConfig.plugins,
190
- import: importPlugin,
221
+ "import-x": importPlugin,
222
+ unicorn: unicornPlugin,
191
223
  },
192
224
  rules: {
193
225
  ...nodeConfig.rules,
194
226
  ...commonRules,
227
+ // No top-level `await` in CommonJS; off explicitly, because
228
+ // `browser/recommended` enables it before this config in `universal-recommended`
229
+ "unicorn/prefer-top-level-await": "off",
195
230
  "n/exports-style": "error",
196
231
  "n/no-path-concat": "error",
197
- "import/extensions": [
232
+ "import-x/extensions": [
198
233
  "error",
199
234
  "always",
200
235
  {
@@ -220,6 +255,8 @@ async function getCommonJSConfig() {
220
255
  };
221
256
  }
222
257
 
258
+ const commonjsConfig = await getCommonJSConfig();
259
+
223
260
  /**
224
261
  * @returns {Promise<import("eslint").Linter.Config>} config
225
262
  */
@@ -233,18 +270,28 @@ async function getModuleConfig() {
233
270
  ignores,
234
271
  plugins: {
235
272
  ...nodeConfig.plugins,
236
- import: importPlugin,
273
+ "import-x": importPlugin,
274
+ unicorn: unicornPlugin,
237
275
  },
238
276
  rules: {
239
277
  ...nodeConfig.rules,
240
278
  ...commonRules,
279
+ // `import.meta.dirname` and `import.meta.filename` landed in Node.js 20.11
280
+ // and 21.2, so 21.0 and 21.1 don't have them
281
+ "unicorn/prefer-import-meta-properties": isSupportedByEngines(
282
+ "^20.11.0 || >=21.2.0",
283
+ )
284
+ ? "error"
285
+ : "off",
286
+ // Disabled for ECMAScript < 2022 in `javascript/*`
287
+ "unicorn/prefer-top-level-await": "error",
241
288
  "n/no-unsupported-features/es-syntax": [
242
289
  "error",
243
290
  {
244
291
  ignores: ["modules", "error-cause"],
245
292
  },
246
293
  ],
247
- "import/extensions": [
294
+ "import-x/extensions": [
248
295
  "error",
249
296
  "always",
250
297
  { ignorePackages: true, checkTypeImports: true },
@@ -253,7 +300,6 @@ async function getModuleConfig() {
253
300
  };
254
301
  }
255
302
 
256
- const commonjsConfig = await getCommonJSConfig();
257
303
  const moduleConfig = await getModuleConfig();
258
304
 
259
305
  /**
@@ -266,7 +312,8 @@ async function getDirtyConfig() {
266
312
  name: "node/dirty",
267
313
  plugins: {
268
314
  n: nodePlugin,
269
- import: importPlugin,
315
+ "import-x": importPlugin,
316
+ unicorn: unicornPlugin,
270
317
  },
271
318
  ignores: [
272
319
  ...new Set([
@@ -293,7 +340,10 @@ async function getDirtyConfig() {
293
340
  ...moduleConfig.rules,
294
341
 
295
342
  // Disable for dirty modules
296
- "import/extensions": ["off"],
343
+ "import-x/extensions": ["off"],
344
+
345
+ // A dirty file can be CommonJS, which has no top-level `await`
346
+ "unicorn/prefer-top-level-await": "off",
297
347
  },
298
348
  };
299
349
  }
@@ -311,14 +361,18 @@ const mjsExtensions = isTypescriptInstalled()
311
361
  : ["*.{mjs,jsx}", "**/*.{mjs,jsx}"];
312
362
 
313
363
  export default {
314
- "node/dirty": dirtyConfig,
315
- "node/commonjs": commonjsConfig,
316
- "node/module": moduleConfig,
317
- "node/recommended": moduleConfig,
318
- "node/mixed-dirty": [
364
+ // `files` is set here and not on the objects, which the mixed configs
365
+ // below reuse with their own `files`
366
+ "node/commonjs": {
367
+ ...commonjsConfig,
368
+ files: codeFiles,
369
+ ignores: codeIgnores,
370
+ },
371
+ "node/module": { ...moduleConfig, files: codeFiles, ignores: codeIgnores },
372
+ "node/mixed-module-and-commonjs": [
319
373
  {
320
374
  files: jsExtensions,
321
- ...dirtyConfig,
375
+ ...moduleConfig,
322
376
  },
323
377
  {
324
378
  files: cjsExtensions,
@@ -329,10 +383,10 @@ export default {
329
383
  ...moduleConfig,
330
384
  },
331
385
  ],
332
- "node/mixed-module-and-commonjs": [
386
+ "node/mixed-commonjs-and-module": [
333
387
  {
334
388
  files: jsExtensions,
335
- ...moduleConfig,
389
+ ...commonjsConfig,
336
390
  },
337
391
  {
338
392
  files: cjsExtensions,
@@ -343,10 +397,11 @@ export default {
343
397
  ...moduleConfig,
344
398
  },
345
399
  ],
346
- "node/mixed-commonjs-and-module": [
400
+ "node/dirty": { ...dirtyConfig, files: codeFiles, ignores: codeIgnores },
401
+ "node/mixed-dirty": [
347
402
  {
348
403
  files: jsExtensions,
349
- ...commonjsConfig,
404
+ ...dirtyConfig,
350
405
  },
351
406
  {
352
407
  files: cjsExtensions,
@@ -0,0 +1,8 @@
1
+ import { configs } from "../plugins/performance/index.js";
2
+
3
+ /** @type {import("eslint").Linter.Config} */
4
+ const recommendedPerformanceConfig = configs.recommended;
5
+
6
+ export default {
7
+ "performance/recommended": recommendedPerformanceConfig,
8
+ };
package/configs/react.js CHANGED
@@ -17,45 +17,33 @@ async function getReactRecommendedConfig() {
17
17
  const devDependencies = packageJson.devDependencies || {};
18
18
 
19
19
  if (
20
- typeof dependencies.react === "undefined" &&
21
- typeof dependencies.preact === "undefined" &&
22
- typeof devDependencies.react === "undefined" &&
23
- typeof devDependencies.preact === "undefined"
20
+ dependencies.react === undefined &&
21
+ dependencies.preact === undefined &&
22
+ devDependencies.react === undefined &&
23
+ devDependencies.preact === undefined
24
24
  ) {
25
25
  return {
26
26
  name: "react/please-install-react-to-enable-it",
27
27
  };
28
28
  }
29
29
 
30
- const reactPlugin = (await import("eslint-plugin-react")).default;
31
- const { recommended, "jsx-runtime": jsxRuntime } = reactPlugin.configs.flat;
32
-
33
- const reactHooksPlugin = (await import("eslint-plugin-react-hooks")).default;
34
- const { recommended: recommendedHooks } = reactHooksPlugin.configs.flat;
30
+ const reactPlugin = (await import("@eslint-react/eslint-plugin")).default;
31
+ const { recommended } = reactPlugin.configs;
35
32
 
36
33
  return {
37
- ...recommended,
38
- ...recommendedHooks,
39
34
  name: "react/recommended",
40
35
  plugins: {
41
36
  ...recommended.plugins,
42
- ...recommendedHooks.plugins,
43
37
  },
44
38
  files: ["**/*.{jsx,tsx}"],
45
39
  settings: {
46
- react: {
47
- version: "detect",
48
- defaultVersion: "19",
49
- },
40
+ ...recommended.settings,
50
41
  },
51
42
  languageOptions: {
52
43
  ...recommended.languageOptions,
53
- ...jsxRuntime.languageOptions,
54
44
  },
55
45
  rules: {
56
46
  ...recommended.rules,
57
- ...jsxRuntime.rules,
58
- ...recommendedHooks.rules,
59
47
  },
60
48
  };
61
49
  }
@@ -1,20 +1,33 @@
1
1
  import stylisticPlugin from "@stylistic/eslint-plugin";
2
2
  import prettierPlugin from "eslint-plugin-prettier";
3
+ import { codeFiles, codeIgnores } from "./utils/code-files.js";
3
4
 
4
5
  /** @type {import("eslint").Linter.Config} */
5
6
  const recommendedConfig = {
6
7
  name: "stylistic/recommended",
8
+ files: codeFiles,
9
+ ignores: codeIgnores,
7
10
  plugins: {
8
11
  "@stylistic": stylisticPlugin,
9
12
  },
10
13
  rules: {
11
14
  curly: ["error", "multi-line", "consistent"],
15
+
16
+ // We use prettier
17
+ // Set by default false all stylistics rules
18
+ ...Object.fromEntries(
19
+ // @ts-expect-error bad types
20
+ Object.keys(stylisticPlugin.configs.all.rules).map((key) => [key, "off"]),
21
+ ),
22
+
12
23
  "@stylistic/lines-between-class-members": "error",
24
+
13
25
  "@stylistic/quotes": [
14
26
  "error",
15
27
  "double",
16
28
  { avoidEscape: true, allowTemplateLiterals: "never" },
17
29
  ],
30
+
18
31
  "@stylistic/spaced-comment": [
19
32
  "error",
20
33
  "always",
@@ -32,6 +45,7 @@ const recommendedConfig = {
32
45
  },
33
46
  },
34
47
  ],
48
+
35
49
  "@stylistic/padding-line-between-statements": [
36
50
  "error",
37
51
  { blankLine: "always", prev: ["cjs-export"], next: "*" },
@@ -68,6 +82,7 @@ const recommendedConfig = {
68
82
  // Require newline after directives
69
83
  { blankLine: "always", prev: ["directive"], next: "*" },
70
84
  ],
85
+
71
86
  "@stylistic/lines-around-comment": [
72
87
  "error",
73
88
  {
@@ -86,6 +101,8 @@ const recommendedConfig = {
86
101
  /** @type {import("eslint").Linter.Config} */
87
102
  const prettierConfig = {
88
103
  name: "stylistic/prettier",
104
+ files: codeFiles,
105
+ ignores: codeIgnores,
89
106
  plugins: {
90
107
  prettier: prettierPlugin,
91
108
  },
@@ -1,4 +1,5 @@
1
1
  import globals from "globals";
2
+ import { codeFiles, codeIgnores } from "./utils/code-files.js";
2
3
  import getJsonFile from "./utils/get-json-file.js";
3
4
 
4
5
  /** @type {import("type-fest").PackageJson | null} */
@@ -17,10 +18,7 @@ async function getJestRecommendedConfig() {
17
18
  const dependencies = packageJson.dependencies || {};
18
19
  const devDependencies = packageJson.devDependencies || {};
19
20
 
20
- if (
21
- typeof dependencies.jest === "undefined" &&
22
- typeof devDependencies.jest === "undefined"
23
- ) {
21
+ if (dependencies.jest === undefined && devDependencies.jest === undefined) {
24
22
  return {
25
23
  name: "jest/please-install-jest-to-enable-it",
26
24
  };
@@ -68,7 +66,7 @@ async function getJestRecommendedConfig() {
68
66
 
69
67
  // No need
70
68
  // Makes too much noise, testing conditions can often be different
71
- "jest/no-conditional-expect": "off",
69
+ "jest/no-conditional-expect": "error",
72
70
 
73
71
  // No need
74
72
  // "jest/no-conditional-in-test": "off",
@@ -154,6 +152,9 @@ async function getJestRecommendedConfig() {
154
152
  // No need
155
153
  // "jest/prefer-each": "error",
156
154
 
155
+ // No need
156
+ "jest/prefer-ending-with-an-expect": "off",
157
+
157
158
  "jest/prefer-equality-matcher": "error",
158
159
 
159
160
  // No need
@@ -230,6 +231,18 @@ async function getJestRecommendedConfig() {
230
231
  },
231
232
  ],
232
233
 
234
+ // Needs type information
235
+ // "jest/no-error-equal": "off",
236
+
237
+ // Needs type information
238
+ // "jest/no-unnecessary-assertion": "off",
239
+
240
+ // Needs type information
241
+ // "jest/unbound-method": "off",
242
+
243
+ // Needs type information
244
+ // "jest/valid-expect-with-promise": "off",
245
+
233
246
  // Disable it for tests, because often you can use `a`, `b`, `c` and etc variables
234
247
  "id-length": "off",
235
248
 
@@ -260,6 +273,53 @@ async function getJestRecommendedConfig() {
260
273
  };
261
274
  }
262
275
 
276
+ /**
277
+ * @returns {Promise<import("eslint").Linter.Config>} config
278
+ */
279
+ async function getNodeTestRecommendedConfig() {
280
+ const nodeTestPlugin = (await import("eslint-node-test")).default;
281
+ const recommendedConfig = /** @type {import("eslint").Linter.Config} */ (
282
+ nodeTestPlugin.configs.recommended
283
+ );
284
+
285
+ return {
286
+ ...recommendedConfig,
287
+ name: "node-test/recommended",
288
+ files: codeFiles,
289
+ ignores: codeIgnores,
290
+ rules: {
291
+ ...recommendedConfig.rules,
292
+
293
+ "node-test/consistent-modifier-style": "error",
294
+
295
+ // TODO enable in future
296
+ // "node-test/consistent-test-filename": "error",
297
+
298
+ "node-test/consistent-test-it": "error",
299
+
300
+ "node-test/no-commented-tests": "error",
301
+
302
+ "node-test/no-skip-without-reason": "error",
303
+
304
+ "node-test/no-sleep-in-test": "error",
305
+
306
+ "node-test/no-snapshot-in-loop": "error",
307
+
308
+ "node-test/no-unneeded-async-rejects-callback": "error",
309
+
310
+ "node-test/prefer-diagnostic": "error",
311
+
312
+ // Allow to use `MyClass` title in describe for class testing
313
+ "node-test/prefer-lowercase-title": ["error", { ignore: ["describe"] }],
314
+
315
+ "node-test/require-top-level-describe": "error",
316
+
317
+ "node-test/no-conditional-assertion": "off",
318
+ },
319
+ };
320
+ }
321
+
263
322
  export default {
264
323
  "jest/recommended": await getJestRecommendedConfig(),
324
+ "node-test/recommended": await getNodeTestRecommendedConfig(),
265
325
  };