eslint-config-webpack 4.0.10 → 4.1.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.
@@ -2,6 +2,7 @@ import globals from "globals";
2
2
  import javascriptConfig from "@eslint/js";
3
3
  import unicornPlugin from "eslint-plugin-unicorn";
4
4
  import importPlugin from "eslint-plugin-import";
5
+ import { allExtensions } from "./utils/extensions.js";
5
6
 
6
7
  const possibleProblems = {
7
8
  "array-callback-return": [
@@ -403,7 +404,9 @@ const suggestions = {
403
404
  },
404
405
  ],
405
406
 
406
- "no-implicit-globals": "error",
407
+ // No need
408
+ // Make sense only for `browser` configuration for old browsers
409
+ // "no-implicit-globals": "off",
407
410
 
408
411
  "no-implied-eval": "error",
409
412
 
@@ -1078,7 +1081,7 @@ const importRules = {
1078
1081
  // From recommended
1079
1082
  "import/no-unresolved": [
1080
1083
  "error",
1081
- { ignore: ["^eslint/config$"], commonjs: true },
1084
+ { ignore: ["^eslint/config$", "^typescript-eslint$"], commonjs: true },
1082
1085
  ],
1083
1086
 
1084
1087
  // No need
@@ -1152,10 +1155,6 @@ const importRules = {
1152
1155
  // "import/prefer-default-export": "off",
1153
1156
  };
1154
1157
 
1155
- const typeScriptExtensions = [".ts", ".cts", ".mts", ".tsx"];
1156
- const javascriptExtensions = [".js", ".jsx", ".mjs", ".cjs"];
1157
- const allExtensions = [...typeScriptExtensions, ...javascriptExtensions];
1158
-
1159
1158
  /**
1160
1159
  * @param {number} esVersion es version
1161
1160
  * @returns {Record<string, string | number>} config
@@ -1164,7 +1163,7 @@ function getConfig(esVersion) {
1164
1163
  const config = {
1165
1164
  ...javascriptConfig.configs.recommended,
1166
1165
  name: `javascript/es${esVersion}`,
1167
- files: ["**/*.{js,jsx,mjs,cjs}"],
1166
+ files: [`**/*.{${allExtensions.map((item) => item.slice(1)).join(",")}}`],
1168
1167
  settings: {
1169
1168
  "import/extensions": allExtensions,
1170
1169
  "import/ignore": [
@@ -1173,7 +1172,7 @@ function getConfig(esVersion) {
1173
1172
  ],
1174
1173
  "import/resolver": {
1175
1174
  node: {
1176
- extensions: allExtensions,
1175
+ extensions: [...allExtensions],
1177
1176
  },
1178
1177
  },
1179
1178
  },
@@ -11,10 +11,6 @@ async function getMarkdownRecommendedConfig() {
11
11
  // Nothing
12
12
  }
13
13
 
14
- if (!markdownPlugin) {
15
- return [];
16
- }
17
-
18
14
  return [
19
15
  {
20
16
  name: "markdown/code-blocks",
package/configs/node.js CHANGED
@@ -115,17 +115,19 @@ const commonRules = {
115
115
  // "n/process-exit-as-throw": "error",
116
116
  };
117
117
 
118
+ let nodePlugin;
119
+
118
120
  /**
119
121
  * @returns {Promise<Record<string, string>>} config
120
122
  */
121
123
  async function getCommonJSConfig() {
122
- let nodePlugin;
123
-
124
- try {
125
- nodePlugin = (await import("eslint-plugin-n")).default;
126
- // eslint-disable-next-line unicorn/prefer-optional-catch-binding
127
- } catch (_err) {
128
- // Nothing
124
+ if (!nodePlugin) {
125
+ try {
126
+ nodePlugin = (await import("eslint-plugin-n")).default;
127
+ // eslint-disable-next-line unicorn/prefer-optional-catch-binding
128
+ } catch (_err) {
129
+ // Nothing
130
+ }
129
131
  }
130
132
 
131
133
  const nodeConfig =
@@ -142,7 +144,19 @@ async function getCommonJSConfig() {
142
144
  ...commonRules,
143
145
  "n/exports-style": "error",
144
146
  "n/no-path-concat": "error",
145
- "import/extensions": ["error", "never", { ignorePackages: true }],
147
+ "import/extensions": [
148
+ "error",
149
+ "never",
150
+ {
151
+ ignorePackages: true,
152
+ pattern: {
153
+ ts: "always",
154
+ cts: "always",
155
+ mts: "always",
156
+ tsx: "always",
157
+ },
158
+ },
159
+ ],
146
160
  },
147
161
  };
148
162
  }
@@ -153,11 +167,13 @@ async function getCommonJSConfig() {
153
167
  async function getModuleConfig() {
154
168
  let nodePlugin;
155
169
 
156
- try {
157
- nodePlugin = (await import("eslint-plugin-n")).default;
158
- // eslint-disable-next-line unicorn/prefer-optional-catch-binding
159
- } catch (_err) {
160
- // Nothing
170
+ if (!nodePlugin) {
171
+ try {
172
+ nodePlugin = (await import("eslint-plugin-n")).default;
173
+ // eslint-disable-next-line unicorn/prefer-optional-catch-binding
174
+ } catch (_err) {
175
+ // Nothing
176
+ }
161
177
  }
162
178
 
163
179
  const nodeConfig =
@@ -172,22 +188,31 @@ async function getModuleConfig() {
172
188
  },
173
189
  rules: {
174
190
  ...commonRules,
175
- "import/extensions": ["error", "always", { ignorePackages: true }],
191
+ "import/extensions": [
192
+ "error",
193
+ "always",
194
+ { ignorePackages: true, checkTypeImports: true },
195
+ ],
176
196
  },
177
197
  };
178
198
  }
179
199
 
200
+ const commonjsConfig = await getCommonJSConfig();
201
+ const moduleConfig = await getModuleConfig();
202
+
180
203
  /**
181
204
  * @returns {Promise<Record<string, string>>} config
182
205
  */
183
206
  async function getDirtyConfig() {
184
207
  let nodePlugin;
185
208
 
186
- try {
187
- nodePlugin = (await import("eslint-plugin-n")).default;
188
- // eslint-disable-next-line unicorn/prefer-optional-catch-binding
189
- } catch (_err) {
190
- // Nothing
209
+ if (!nodePlugin) {
210
+ try {
211
+ nodePlugin = (await import("eslint-plugin-n")).default;
212
+ // eslint-disable-next-line unicorn/prefer-optional-catch-binding
213
+ } catch (_err) {
214
+ // Nothing
215
+ }
191
216
  }
192
217
 
193
218
  return {
@@ -211,59 +236,62 @@ async function getDirtyConfig() {
211
236
  },
212
237
  },
213
238
  rules: {
214
- ...(await getCommonJSConfig()).rules,
215
- ...(await getModuleConfig()).rules,
239
+ ...commonjsConfig.rules,
240
+ ...moduleConfig.rules,
241
+
216
242
  // Disable for dirty modules
217
243
  "import/extensions": ["off"],
218
244
  },
219
245
  };
220
246
  }
221
247
 
248
+ const dirtyConfig = await getDirtyConfig();
249
+
222
250
  export default {
223
- "node/dirty": await getDirtyConfig(),
224
- "node/commonjs": await getCommonJSConfig(),
225
- "node/module": await getModuleConfig(),
226
- "node/recommended": await getModuleConfig(),
251
+ "node/dirty": dirtyConfig,
252
+ "node/commonjs": commonjsConfig,
253
+ "node/module": moduleConfig,
254
+ "node/recommended": moduleConfig,
227
255
  "node/mixed-dirty": [
228
256
  {
229
- files: ["**/*.{js,jsx}"],
230
- ...(await getDirtyConfig()),
257
+ files: ["**/*.{js,jsx,ts,tsx}"],
258
+ ...dirtyConfig,
231
259
  },
232
260
  {
233
- files: ["**/*.cjs"],
234
- ...(await getCommonJSConfig()),
261
+ files: ["**/*.{cjs,cts}"],
262
+ ...commonjsConfig,
235
263
  },
236
264
  {
237
- files: ["**/*.mjs"],
238
- ...(await getModuleConfig()),
265
+ files: ["**/*.{mjs,mts}"],
266
+ ...moduleConfig,
239
267
  },
240
268
  ],
241
269
  "node/mixed-module-and-commonjs": [
242
270
  {
243
- files: ["**/*.{js,jsx}"],
244
- ...(await getModuleConfig()),
271
+ files: ["**/*.{js,jsx,ts,tsx}"],
272
+ ...moduleConfig,
245
273
  },
246
274
  {
247
- files: ["**/*.cjs"],
248
- ...(await getCommonJSConfig()),
275
+ files: ["**/*.{cjs,cts}"],
276
+ ...commonjsConfig,
249
277
  },
250
278
  {
251
- files: ["**/*.mjs"],
252
- ...(await getModuleConfig()),
279
+ files: ["**/*.{mjs,mts}"],
280
+ ...moduleConfig,
253
281
  },
254
282
  ],
255
283
  "node/mixed-commonjs-and-module": [
256
284
  {
257
- files: ["**/*.{js,jsx}"],
258
- ...(await getCommonJSConfig()),
285
+ files: ["**/*.{js,jsx,ts,tsx}"],
286
+ ...commonjsConfig,
259
287
  },
260
288
  {
261
- files: ["**/*.cjs"],
262
- ...(await getCommonJSConfig()),
289
+ files: ["**/*.{cjs,cts}"],
290
+ ...commonjsConfig,
263
291
  },
264
292
  {
265
- files: ["**/*.mjs"],
266
- ...(await getModuleConfig()),
293
+ files: ["**/*.{mjs,mts}"],
294
+ ...moduleConfig,
267
295
  },
268
296
  ],
269
297
  };
@@ -1,7 +1,12 @@
1
+ import {
2
+ javascriptExtensions,
3
+ typescriptExtensions,
4
+ } from "./utils/extensions.js";
5
+
1
6
  /**
2
7
  * @returns {Promise<Record<string, string>>} config
3
8
  */
4
- async function getRecommendedJSDocConfig() {
9
+ async function getTypescriptJSDocRecommendedConfig() {
5
10
  let jsdocPlugin;
6
11
 
7
12
  try {
@@ -19,6 +24,9 @@ async function getRecommendedJSDocConfig() {
19
24
  return {
20
25
  ...jsdocConfig,
21
26
  name: "typescript/jsdoc",
27
+ files: [
28
+ `**/*.{${javascriptExtensions.map((item) => item.slice(1)).join(",")}}`,
29
+ ],
22
30
  settings: {
23
31
  jsdoc: {
24
32
  mode: "typescript",
@@ -266,6 +274,459 @@ async function getRecommendedJSDocConfig() {
266
274
  };
267
275
  }
268
276
 
277
+ /**
278
+ * @returns {Promise<Record<string, string>>} config
279
+ */
280
+ async function getTypescriptRecommendedConfig() {
281
+ let typescriptPlugin;
282
+
283
+ try {
284
+ typescriptPlugin = (await import("typescript-eslint")).default;
285
+ // eslint-disable-next-line unicorn/prefer-optional-catch-binding
286
+ } catch (_err) {
287
+ // Nothing
288
+ }
289
+
290
+ const { configs } = typescriptPlugin || {
291
+ configs: {
292
+ base: { languageOptions: {} },
293
+ eslintRecommended: {},
294
+ recommended: [{ name: "typescript-eslint/recommended", rules: {} }],
295
+ stylistic: [{ name: "typescript-eslint/stylistic", rules: {} }],
296
+ },
297
+ };
298
+ const baseConfig = configs.base;
299
+ const eslintRecommendedConfig = configs.eslintRecommended;
300
+ const recommendedConfig = configs.recommended.find(
301
+ (item) => item.name === "typescript-eslint/recommended",
302
+ );
303
+ const stylisticConfig = configs.stylistic.find(
304
+ (item) => item.name === "typescript-eslint/stylistic",
305
+ );
306
+
307
+ return {
308
+ ...baseConfig,
309
+ name: "typescript/recommended",
310
+ files: [
311
+ `**/*.{${typescriptExtensions.map((item) => item.slice(1)).join(",")}}`,
312
+ ],
313
+ languageOptions: {
314
+ parser: baseConfig.languageOptions.parser,
315
+ },
316
+ plugins: {
317
+ ...baseConfig.plugins,
318
+ },
319
+ rules: {
320
+ ...eslintRecommendedConfig.rules,
321
+ ...recommendedConfig.rules,
322
+ ...stylisticConfig.rules,
323
+
324
+ // From recommended
325
+ // "@typescript-eslint/adjacent-overload-signatures": "error",
326
+
327
+ // From recommended
328
+ // "@typescript-eslint/array-type": "error",
329
+
330
+ // No need
331
+ // "@typescript-eslint/await-thenable": "error",
332
+
333
+ // From recommended
334
+ // "@typescript-eslint/ban-ts-comment": "error",
335
+
336
+ // From recommended
337
+ // "@typescript-eslint/ban-tslint-comment": "error",
338
+
339
+ // From recommended
340
+ // "@typescript-eslint/class-literal-property-style": "error",
341
+
342
+ // No need
343
+ // "@typescript-eslint/class-methods-use-this": "error",
344
+
345
+ // From recommended
346
+ // "@typescript-eslint/consistent-generic-constructors": "error",
347
+
348
+ // From recommended
349
+ // "@typescript-eslint/consistent-indexed-object-style": "error",
350
+
351
+ // No need
352
+ // "@typescript-eslint/consistent-return": "error",
353
+
354
+ // From recommended
355
+ // "@typescript-eslint/consistent-type-assertions": "error",
356
+
357
+ // From recommended
358
+ // "@typescript-eslint/consistent-type-definitions": "error",
359
+
360
+ // No need
361
+ // "@typescript-eslint/consistent-type-exports": "error",
362
+
363
+ // No need
364
+ // "@typescript-eslint/consistent-type-imports": "error",
365
+
366
+ // The same as `default-param-last`
367
+ "default-param-last": "off",
368
+ "@typescript-eslint/default-param-last": "error",
369
+
370
+ // No need
371
+ // we have `dot-notation`
372
+ // "@typescript-eslint/dot-notation": "error",
373
+
374
+ // No need
375
+ // "@typescript-eslint/explicit-function-return-type": "error",
376
+
377
+ "@typescript-eslint/explicit-member-accessibility": [
378
+ "error",
379
+ { accessibility: "no-public" },
380
+ ],
381
+
382
+ // No need
383
+ // "@typescript-eslint/explicit-module-boundary-types": "error",
384
+
385
+ // No need
386
+ // "@typescript-eslint/init-declarations": "error",
387
+
388
+ // No need
389
+ // "@typescript-eslint/max-params": "error",
390
+
391
+ // No need
392
+ // "@typescript-eslint/member-ordering": "error",
393
+
394
+ // No need
395
+ // "@typescript-eslint/method-signature-style": "error",
396
+
397
+ // No need
398
+ // "@typescript-eslint/naming-convention": "error",
399
+
400
+ // From recommended
401
+ // "@typescript-eslint/no-array-constructor": "error",
402
+
403
+ // No need
404
+ // "@typescript-eslint/no-array-delete": "error",
405
+
406
+ // No need
407
+ // "@typescript-eslint/no-base-to-string": "error",
408
+
409
+ // From recommended
410
+ // "@typescript-eslint/no-confusing-non-null-assertion": "error",
411
+
412
+ // No need
413
+ // "@typescript-eslint/no-confusing-void-expression": "error",
414
+
415
+ // No need
416
+ // Good rule, but some packages can change their API often, and it will create noise in CI
417
+ // "@typescript-eslint/no-deprecated": "error",
418
+
419
+ // No need
420
+ // "@typescript-eslint/no-dupe-class-members": "error",
421
+
422
+ // From recommended
423
+ // "@typescript-eslint/no-duplicate-enum-values": "error",
424
+
425
+ // No need
426
+ // "@typescript-eslint/no-dynamic-delete": "error",
427
+
428
+ // From recommended
429
+ // "@typescript-eslint/no-empty-function": "error",
430
+
431
+ // From recommended
432
+ // "@typescript-eslint/no-empty-object-type": "error",
433
+
434
+ // From recommended
435
+ // "@typescript-eslint/no-explicit-any": "error",
436
+
437
+ // From recommended
438
+ // "@typescript-eslint/no-extra-non-null-assertion": "error",
439
+
440
+ // No need
441
+ // "@typescript-eslint/no-extraneous-class": "error",
442
+
443
+ // No need
444
+ // "@typescript-eslint/no-floating-promises": "error",
445
+
446
+ // No need
447
+ // "@typescript-eslint/no-for-in-array": "error",
448
+
449
+ // No need
450
+ // "@typescript-eslint/no-implied-eval": "error",
451
+
452
+ // No need
453
+ // "@typescript-eslint/no-import-type-side-effects": "error",
454
+
455
+ // From recommended
456
+ // "@typescript-eslint/no-inferrable-types": "error",
457
+
458
+ // No need
459
+ // "@typescript-eslint/no-invalid-this": "error",
460
+
461
+ // No need
462
+ // "@typescript-eslint/no-invalid-void-type": "error",
463
+
464
+ // The same as `no-loop-func`
465
+ "no-loop-func": "off",
466
+ "@typescript-eslint/no-loop-func": "error",
467
+
468
+ // No need
469
+ // "@typescript-eslint/no-magic-numbers": "error",
470
+
471
+ // No need
472
+ // "@typescript-eslint/no-meaningless-void-operator": "error",
473
+
474
+ // From recommended
475
+ // "@typescript-eslint/no-misused-new": "error",
476
+
477
+ // No need
478
+ // "@typescript-eslint/no-misused-promises": "error",
479
+
480
+ // No need
481
+ // "@typescript-eslint/no-misused-spread": "error",
482
+
483
+ // No need
484
+ // "@typescript-eslint/no-mixed-enums": "error",
485
+
486
+ // No need
487
+ // "@typescript-eslint/no-namespace": "error",
488
+
489
+ // No need
490
+ // "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
491
+
492
+ // From recommended
493
+ // "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
494
+
495
+ // No need
496
+ // "@typescript-eslint/no-non-null-assertion": "error",
497
+
498
+ // No need
499
+ // "@typescript-eslint/no-redeclare": "error",
500
+
501
+ // No need
502
+ // "@typescript-eslint/no-redundant-type-constituents": "error",
503
+
504
+ // Module system provided in `node/module`/`node/commonjs`/etc configurations
505
+ "@typescript-eslint/no-require-imports": "off",
506
+
507
+ // No need
508
+ // "@typescript-eslint/no-restricted-imports": "error",
509
+
510
+ // No need
511
+ // "@typescript-eslint/no-restricted-types": "error",
512
+
513
+ // No need
514
+ // "@typescript-eslint/no-shadow": "error",
515
+
516
+ // From recommended
517
+ // "@typescript-eslint/no-this-alias": "error",
518
+
519
+ // No need
520
+ // "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
521
+
522
+ // "@typescript-eslint/no-unnecessary-condition": "error",
523
+
524
+ "@typescript-eslint/no-unnecessary-parameter-property-assignment":
525
+ "error",
526
+
527
+ // No need
528
+ // "@typescript-eslint/no-unnecessary-qualifier": "error",
529
+
530
+ // No need
531
+ // "@typescript-eslint/no-unnecessary-template-expression": "error",
532
+
533
+ // No need
534
+ // "@typescript-eslint/no-unnecessary-type-arguments": "error",
535
+
536
+ // No need
537
+ // "@typescript-eslint/no-unnecessary-type-assertion": "error",
538
+
539
+ // From recommended
540
+ // "@typescript-eslint/no-unnecessary-type-constraint": "error",
541
+
542
+ // No need
543
+ // "@typescript-eslint/no-unnecessary-type-conversion": "error",
544
+
545
+ // No need
546
+ // "@typescript-eslint/no-unnecessary-type-parameters": "error",
547
+
548
+ // No need
549
+ // "@typescript-eslint/no-unsafe-argument": "error",
550
+
551
+ // No need
552
+ // "@typescript-eslint/no-unsafe-assignment": "error",
553
+
554
+ // No need
555
+ // "@typescript-eslint/no-unsafe-call": "error",
556
+
557
+ // From recommended
558
+ // "@typescript-eslint/no-unsafe-declaration-merging": "error",
559
+
560
+ // No need
561
+ // "@typescript-eslint/no-unsafe-enum-comparison": "error",
562
+
563
+ // From recommended
564
+ // "@typescript-eslint/no-unsafe-function-type": "error",
565
+
566
+ // No need
567
+ // "@typescript-eslint/no-unsafe-member-access": "error",
568
+
569
+ // No need
570
+ // "@typescript-eslint/no-unsafe-return": "error",
571
+
572
+ // No need
573
+ // "@typescript-eslint/no-unsafe-type-assertion": "error",
574
+
575
+ // No need
576
+ // "@typescript-eslint/no-unsafe-unary-minus": "error",
577
+
578
+ // From recommended
579
+ // "@typescript-eslint/no-unused-expressions": "error",
580
+
581
+ // Provide better options
582
+ "no-unused-vars": "off",
583
+ "@typescript-eslint/no-unused-vars": [
584
+ "error",
585
+ {
586
+ args: "after-used",
587
+ argsIgnorePattern: "^_",
588
+ caughtErrors: "all",
589
+ caughtErrorsIgnorePattern: "^_",
590
+ destructuredArrayIgnorePattern: "^_",
591
+ ignoreRestSiblings: true,
592
+ ignoreClassWithStaticInitBlock: false,
593
+ reportUsedIgnorePattern: false,
594
+ },
595
+ ],
596
+
597
+ // From recommended
598
+ // "@typescript-eslint/no-unused-vars": "error",
599
+
600
+ // The same as `no-use-before-define`
601
+ "no-use-before-define": "off",
602
+ "@typescript-eslint/no-use-before-define": [
603
+ "error",
604
+ {
605
+ functions: true,
606
+ classes: true,
607
+ variables: true,
608
+ enums: true,
609
+ typedefs: true,
610
+ },
611
+ ],
612
+
613
+ // No need
614
+ // "@typescript-eslint/no-useless-constructor": "error",
615
+
616
+ "@typescript-eslint/no-useless-empty-export": "error",
617
+
618
+ // From recommended
619
+ "@typescript-eslint/no-wrapper-object-types": "error",
620
+
621
+ // No need
622
+ // "@typescript-eslint/non-nullable-type-assertion-style": "error",
623
+
624
+ // No need
625
+ // "@typescript-eslint/only-throw-error": "error",
626
+
627
+ // No need
628
+ // "@typescript-eslint/parameter-properties": "error",
629
+
630
+ // From recommended
631
+ // "@typescript-eslint/prefer-as-const": "error",
632
+
633
+ // No need
634
+ // "@typescript-eslint/prefer-destructuring": "error",
635
+
636
+ // No need
637
+ // "@typescript-eslint/prefer-enum-initializers": "error",
638
+
639
+ // No need
640
+ // "@typescript-eslint/prefer-find": "error",
641
+
642
+ // From recommended
643
+ // "@typescript-eslint/prefer-for-of": "error",
644
+
645
+ // From recommended
646
+ // "@typescript-eslint/prefer-function-type": "error",
647
+
648
+ // No need
649
+ // "@typescript-eslint/prefer-includes": "error",
650
+
651
+ // No need
652
+ // "@typescript-eslint/prefer-literal-enum-member": "error",
653
+
654
+ // From recommended
655
+ // "@typescript-eslint/prefer-namespace-keyword": "error",
656
+
657
+ // No need
658
+ // "@typescript-eslint/prefer-nullish-coalescing": "error",
659
+
660
+ // No need
661
+ // "@typescript-eslint/prefer-optional-chain": "error",
662
+
663
+ // No need
664
+ // "@typescript-eslint/prefer-promise-reject-errors": "error",
665
+
666
+ // No need
667
+ // "@typescript-eslint/prefer-readonly": "error",
668
+
669
+ // No need
670
+ // "@typescript-eslint/prefer-readonly-parameter-types": "error",
671
+
672
+ // No need
673
+ // "@typescript-eslint/prefer-reduce-type-parameter": "error",
674
+
675
+ // No need
676
+ // "@typescript-eslint/prefer-regexp-exec": "error",
677
+
678
+ // No need
679
+ // "@typescript-eslint/prefer-return-this-type": "error",
680
+
681
+ // No need
682
+ // "@typescript-eslint/prefer-string-starts-ends-with": "error",
683
+
684
+ // No need
685
+ // "@typescript-eslint/promise-function-async": "error",
686
+
687
+ // No need
688
+ // "@typescript-eslint/related-getter-setter-pairs": "error",
689
+
690
+ // No need
691
+ // "@typescript-eslint/require-array-sort-compare": "error",
692
+
693
+ // No need
694
+ // "@typescript-eslint/require-await": "error",
695
+
696
+ // No need
697
+ // "@typescript-eslint/restrict-plus-operands": "error",
698
+
699
+ // No need
700
+ // "@typescript-eslint/restrict-template-expressions": "error",
701
+
702
+ // No need
703
+ // "@typescript-eslint/return-await": "error",
704
+
705
+ // No need
706
+ // "@typescript-eslint/strict-boolean-expressions": "error",
707
+
708
+ // No need
709
+ // "@typescript-eslint/switch-exhaustiveness-check": "error",
710
+
711
+ // From recommended
712
+ // "@typescript-eslint/triple-slash-reference": "error",
713
+
714
+ // No need
715
+ // "@typescript-eslint/unbound-method": "error",
716
+
717
+ // No need
718
+ // "@typescript-eslint/unified-signatures": "error",
719
+
720
+ // No need
721
+ // "use-unknown-in-catch-callback-variable": "error",
722
+
723
+ // TypeScript handles this for us
724
+ "import/no-unresolved": "off",
725
+ },
726
+ };
727
+ }
728
+
269
729
  export default {
270
- "typescript/jsdoc": await getRecommendedJSDocConfig(),
730
+ "typescript/recommended": await getTypescriptRecommendedConfig(),
731
+ "typescript/jsdoc": await getTypescriptJSDocRecommendedConfig(),
271
732
  };
@@ -0,0 +1,5 @@
1
+ const javascriptExtensions = [".js", ".cjs", ".mjs", ".jsx"];
2
+ const typescriptExtensions = [".ts", ".cts", ".mts", ".tsx"];
3
+ const allExtensions = [...javascriptExtensions, ...typescriptExtensions];
4
+
5
+ export { javascriptExtensions, typescriptExtensions, allExtensions };
package/configs.js CHANGED
@@ -60,10 +60,11 @@ const cache = new Cache();
60
60
  *
61
61
  * Don't cache the data.
62
62
  * @param {string} dir The path to a directory to read.
63
+ * @param {string} filename The filename.
63
64
  * @returns {import('type-fest').JsonObject|null} The read `package.json` data, or null.
64
65
  */
65
- function readPackageJson(dir) {
66
- const filePath = path.join(dir, "package.json");
66
+ function readJsonFile(dir, filename) {
67
+ const filePath = path.join(dir, filename);
67
68
  try {
68
69
  const text = fs.readFileSync(filePath, "utf8");
69
70
  const data = JSON.parse(text);
@@ -87,29 +88,30 @@ function readPackageJson(dir) {
87
88
  /**
88
89
  * Gets a `package.json` data.
89
90
  * The data is cached if found, then it's used after.
91
+ * @param {string} filename The filename.
90
92
  * @param {string=} startPath A file path to lookup.
91
93
  * @returns {import('type-fest').JsonObject | null} A found `package.json` data or `null`.
92
94
  * This object have additional property `filePath`.
93
95
  */
94
- function getPackageJson(startPath = "a.js") {
96
+ function getJsonFile(filename, startPath = "a.js") {
95
97
  const startDir = path.dirname(path.resolve(startPath));
96
98
  let dir = startDir;
97
99
  let prevDir = "";
98
100
  let data = null;
99
101
 
100
102
  do {
101
- data = cache.get(dir);
103
+ data = cache.get(dir + filename);
102
104
  if (data) {
103
105
  if (dir !== startDir) {
104
- cache.set(startDir, data);
106
+ cache.set(startDir + filename, data);
105
107
  }
106
108
  return data;
107
109
  }
108
110
 
109
- data = readPackageJson(dir);
111
+ data = readJsonFile(dir, filename);
110
112
  if (data) {
111
- cache.set(dir, data);
112
- cache.set(startDir, data);
113
+ cache.set(dir + filename, data);
114
+ cache.set(startDir + filename, data);
113
115
  return data;
114
116
  }
115
117
 
@@ -118,11 +120,11 @@ function getPackageJson(startPath = "a.js") {
118
120
  dir = path.resolve(dir, "..");
119
121
  } while (dir !== prevDir);
120
122
 
121
- cache.set(startDir, null);
123
+ cache.set(startDir + filename, null);
122
124
  return null;
123
125
  }
124
126
 
125
- const packageJson = getPackageJson();
127
+ const packageJson = getJsonFile("package.json");
126
128
  const isModule =
127
129
  packageJson !== null &&
128
130
  typeof packageJson === "object" &&
@@ -194,7 +196,7 @@ function getJavascriptConfig() {
194
196
  /**
195
197
  * @returns {Promise<Record<string, string>>} config
196
198
  */
197
- function getTypescriptJsdocConfig() {
199
+ function getTypescriptJSdocConfig() {
198
200
  if (packageJson === null) {
199
201
  return [];
200
202
  }
@@ -208,6 +210,37 @@ function getTypescriptJsdocConfig() {
208
210
  : [];
209
211
  }
210
212
 
213
+ /**
214
+ * @returns {Promise<Record<string, string>>} config
215
+ */
216
+ function getTypescriptConfig() {
217
+ if (packageJson === null) {
218
+ return [];
219
+ }
220
+
221
+ const dependencies = packageJson.dependencies || [];
222
+ const devDependencies = packageJson.devDependencies || [];
223
+
224
+ if (
225
+ typeof dependencies.typescript === "undefined" &&
226
+ typeof devDependencies.typescript === "undefined"
227
+ ) {
228
+ return [];
229
+ }
230
+
231
+ const tsconfigJson = getJsonFile("tsconfig.json");
232
+ const isStrict =
233
+ (tsconfigJson &&
234
+ tsconfigJson.compilerOptions &&
235
+ tsconfigJson.compilerOptions.strict) ||
236
+ true;
237
+
238
+ return [
239
+ configs["typescript/recommended"],
240
+ isStrict ? { rules: { strict: "off" } } : {},
241
+ ];
242
+ }
243
+
211
244
  /**
212
245
  * @returns {Promise<Record<string, string>>} config
213
246
  */
@@ -225,14 +258,20 @@ function getJestConfig() {
225
258
  : [];
226
259
  }
227
260
 
261
+ const javascriptConfig = getJavascriptConfig();
262
+ const typescriptJSDocConfig = getTypescriptJSdocConfig();
263
+ const typescriptConfig = getTypescriptConfig();
264
+ const jestConfig = getJestConfig();
265
+
228
266
  configs.recommended = [
229
267
  globalIgnores(ignorePaths),
230
268
  isModule
231
269
  ? configs["node/mixed-module-and-commonjs"]
232
270
  : configs["node/mixed-commonjs-and-module"],
233
- getJavascriptConfig(),
234
- getTypescriptJsdocConfig(),
235
- getJestConfig(),
271
+ javascriptConfig,
272
+ typescriptJSDocConfig,
273
+ typescriptConfig,
274
+ jestConfig,
236
275
  configs["markdown/recommended"],
237
276
  configs["stylistic/recommended"],
238
277
  ];
@@ -240,9 +279,10 @@ configs.recommended = [
240
279
  configs["recommended-module"] = [
241
280
  globalIgnores(ignorePaths),
242
281
  configs["node/mixed-module-and-commonjs"],
243
- getJavascriptConfig(),
244
- getTypescriptJsdocConfig(),
245
- getJestConfig(),
282
+ javascriptConfig,
283
+ typescriptJSDocConfig,
284
+ typescriptConfig,
285
+ jestConfig,
246
286
  configs["markdown/recommended"],
247
287
  configs["stylistic/recommended"],
248
288
  ];
@@ -250,9 +290,10 @@ configs["recommended-module"] = [
250
290
  configs["recommended-commonjs"] = [
251
291
  globalIgnores(ignorePaths),
252
292
  configs["node/mixed-commonjs-and-module"],
253
- getJavascriptConfig(),
254
- getTypescriptJsdocConfig(),
255
- getJestConfig(),
293
+ javascriptConfig,
294
+ typescriptJSDocConfig,
295
+ typescriptConfig,
296
+ jestConfig,
256
297
  configs["markdown/recommended"],
257
298
  configs["stylistic/recommended"],
258
299
  ];
@@ -260,9 +301,10 @@ configs["recommended-commonjs"] = [
260
301
  configs["recommended-dirty"] = [
261
302
  globalIgnores(ignorePaths),
262
303
  configs["node/mixed-dirty"],
263
- getJavascriptConfig(),
264
- getTypescriptJsdocConfig(),
265
- getJestConfig(),
304
+ javascriptConfig,
305
+ typescriptJSDocConfig,
306
+ typescriptConfig,
307
+ jestConfig,
266
308
  configs["markdown/recommended"],
267
309
  configs["stylistic/recommended"],
268
310
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-webpack",
3
- "version": "4.0.10",
3
+ "version": "4.1.1",
4
4
  "author": "Joshua Wiens (https://twitter.com/@d3viant0ne)",
5
5
  "license": "MIT",
6
6
  "description": "Provides Webpack's eslint rules as an extensible shared config",
@@ -38,7 +38,8 @@
38
38
  "jest": "^30.0.0",
39
39
  "prettier": "^3.5.3",
40
40
  "standard-version": "^9.5.0",
41
- "typescript": "^5.8.3"
41
+ "typescript": "^5.8.3",
42
+ "typescript-eslint": "^8.34.0"
42
43
  },
43
44
  "peerDependencies": {
44
45
  "@eslint/js": ">= 9.28.0",
@@ -53,7 +54,9 @@
53
54
  "eslint-plugin-prettier": ">= 5.4.1",
54
55
  "eslint-plugin-unicorn": ">= 59.0.1",
55
56
  "globals": ">= 16.2.0",
56
- "prettier": ">= 3.5.3"
57
+ "prettier": ">= 3.5.3",
58
+ "typescript": ">= 5.0.0",
59
+ "typescript-eslint": ">= 8.34.0"
57
60
  },
58
61
  "peerDependenciesMeta": {
59
62
  "@eslint/markdown": {
@@ -67,6 +70,12 @@
67
70
  },
68
71
  "eslint-plugin-n": {
69
72
  "optional": true
73
+ },
74
+ "typescript": {
75
+ "optional": true
76
+ },
77
+ "typescript-eslint": {
78
+ "optional": true
70
79
  }
71
80
  },
72
81
  "engines": {