@w5s/eslint-config 3.16.0 → 3.17.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/eslint-config",
3
- "version": "3.16.0",
3
+ "version": "3.17.0",
4
4
  "description": "ESLint configuration presets",
5
5
  "keywords": [
6
6
  "eslint",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@e18e/eslint-plugin": "^0.5.0",
40
- "@eslint-react/eslint-plugin": "5.11.2",
40
+ "@eslint-react/eslint-plugin": "5.17.1",
41
41
  "@eslint/js": "^10.0.0",
42
42
  "@eslint/markdown": "^8.0.0",
43
43
  "@next/eslint-plugin-next": "^16.0.0",
@@ -45,17 +45,18 @@
45
45
  "@typescript-eslint/eslint-plugin": "^8.0.0",
46
46
  "@typescript-eslint/parser": "^8.0.0",
47
47
  "@vitest/eslint-plugin": "~1.6.20",
48
- "@w5s/dev": "^3.7.0",
49
- "@w5s/eslint-config-ignore": "^1.6.0",
50
- "@w5s/prettier-config": "^3.1.20",
48
+ "@w5s/dev": "^3.8.0",
49
+ "@w5s/eslint-config-ignore": "^1.7.0",
50
+ "@w5s/prettier-config": "^3.2.0",
51
51
  "eslint-merge-processors": "^2.0.0",
52
52
  "eslint-plugin-import": "~2.32.0",
53
53
  "eslint-plugin-jsdoc": "~63.0.0",
54
- "eslint-plugin-jsonc": "~3.2.0",
54
+ "eslint-plugin-jsonc": "~3.3.0",
55
55
  "eslint-plugin-n": "~18.2.0",
56
- "eslint-plugin-perfectionist": "~5.9.1",
57
- "eslint-plugin-unicorn": "~69.0.0",
58
- "eslint-plugin-yml": "~3.5.0",
56
+ "eslint-plugin-perfectionist": "~5.10.0",
57
+ "eslint-plugin-unicorn": "~71.1.0",
58
+ "eslint-plugin-unused-imports": "~4.4.1",
59
+ "eslint-plugin-yml": "~3.6.0",
59
60
  "globals": "^17.0.0",
60
61
  "jsonc-eslint-parser": "^3.0.0",
61
62
  "parse-gitignore": "^2.0.0",
@@ -84,5 +85,5 @@
84
85
  "access": "public"
85
86
  },
86
87
  "sideEffect": false,
87
- "gitHead": "488ae0c9dcf081e3bf443c0cbc410a0fa8f10b12"
88
+ "gitHead": "8a983003d499b2d34ff7ce0bd9e4294549f7642b"
88
89
  }
@@ -6,7 +6,7 @@ import type { RuleOptions } from '../typegen/markdown.js';
6
6
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
7
  import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
8
8
 
9
- const defaultFiles = [`**/${Project.extensionsToGlob(Project.queryExtensions(['markdown']))}`, '**/CHANGELOG.md', '**/CODE_OF_CONDUCT.md'];
9
+ const defaultFiles = [`**/${Project.extensionsToGlob(Project.queryExtensions(['markdown']))}`];
10
10
 
11
11
  export async function markdown(options: markdown.Options = {}) {
12
12
  const [markdownPlugin] = await Promise.all([interopDefault(import('@eslint/markdown'))] as const);
@@ -0,0 +1,51 @@
1
+ import { interopDefault } from '@w5s/dev';
2
+
3
+ import type { RuleOptions } from '../typegen/unused-imports.js';
4
+
5
+ import { sourceGlob } from '../glob.js';
6
+ import { type Config, type PluginOptionsBase } from '../type.js';
7
+
8
+ export async function unusedImports(options: unusedImports.Options = {}) {
9
+ const [unusedImportPlugin] = await Promise.all([
10
+ interopDefault(import('eslint-plugin-unused-imports')),
11
+ ] as const);
12
+ const { files = [sourceGlob], recommended = true, rules = {} } = options;
13
+
14
+ return [
15
+ {
16
+ name: 'w5s/unused-imports/setup',
17
+ plugins: {
18
+ 'unused-imports': unusedImportPlugin,
19
+ },
20
+ },
21
+ {
22
+ files,
23
+ name: 'w5s/unused-imports/rules',
24
+ rules: {
25
+ ...(recommended
26
+ ? {
27
+ 'no-unused-vars': 'off', // disable the base rule as it can report incorrect errors
28
+ 'ts/no-unused-vars': 'off', // disable the base rule as it can report incorrect errors
29
+ 'unused-imports/no-unused-imports': 'error',
30
+ 'unused-imports/no-unused-vars': [
31
+ 'error',
32
+ {
33
+ args: 'after-used',
34
+ argsIgnorePattern: '^_',
35
+ vars: 'all',
36
+ varsIgnorePattern: '^_',
37
+ },
38
+ ],
39
+ }
40
+ : {}),
41
+ ...rules,
42
+ },
43
+ },
44
+ ] as [Config, Config] satisfies Array<Config>;
45
+ }
46
+
47
+ export namespace unusedImports {
48
+ export interface Options extends PluginOptionsBase<Rules> {}
49
+
50
+ export type Rules = RuleOptions;
51
+ }
package/src/config.ts CHANGED
@@ -14,4 +14,5 @@ export * from './config/stylistic.js';
14
14
  export * from './config/test.js';
15
15
  export * from './config/ts.js';
16
16
  export * from './config/unicorn.js';
17
+ export * from './config/unused-imports.js';
17
18
  export * from './config/yml.js';
@@ -21,6 +21,7 @@ import {
21
21
  test,
22
22
  ts,
23
23
  unicorn,
24
+ unusedImports,
24
25
  yml,
25
26
  } from './config.js';
26
27
 
@@ -29,22 +30,23 @@ export interface DefineConfigOptions extends ignores.Options {
29
30
  * Plugins configuration
30
31
  */
31
32
  plugins?: {
32
- e18e?: boolean | e18e.Options;
33
- es?: boolean | es.Options;
34
- import?: boolean | imports.Options;
35
- jsdoc?: boolean | jsdoc.Options;
36
- jsonc?: boolean | jsonc.Options;
37
- jsx?: boolean | jsx.Options;
38
- markdown?: boolean | markdown.Options;
39
- next?: boolean | next.Options;
40
- node?: boolean | node.Options;
41
- perfectionist?: boolean | perfectionist.Options;
42
- react?: boolean | react.Options;
43
- stylistic?: boolean | stylistic.Options;
44
- test?: boolean | test.Options;
45
- ts?: boolean | ts.Options;
46
- unicorn?: boolean | unicorn.Options;
47
- yml?: boolean | yml.Options;
33
+ 'e18e'?: boolean | e18e.Options;
34
+ 'es'?: boolean | es.Options;
35
+ 'import'?: boolean | imports.Options;
36
+ 'jsdoc'?: boolean | jsdoc.Options;
37
+ 'jsonc'?: boolean | jsonc.Options;
38
+ 'jsx'?: boolean | jsx.Options;
39
+ 'markdown'?: boolean | markdown.Options;
40
+ 'next'?: boolean | next.Options;
41
+ 'node'?: boolean | node.Options;
42
+ 'perfectionist'?: boolean | perfectionist.Options;
43
+ 'react'?: boolean | react.Options;
44
+ 'stylistic'?: boolean | stylistic.Options;
45
+ 'test'?: boolean | test.Options;
46
+ 'ts'?: boolean | ts.Options;
47
+ 'unicorn'?: boolean | unicorn.Options;
48
+ 'unused-imports'?: boolean | unusedImports.Options;
49
+ 'yml'?: boolean | yml.Options;
48
50
  };
49
51
 
50
52
  /**
@@ -90,6 +92,8 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
90
92
  ...includeEnabled(unicorn, toOption(plugins.unicorn)),
91
93
  ...includeEnabled(yml, toOption(plugins.yml)),
92
94
  ...includeEnabled(test, toOption(plugins.test)),
95
+ // Unused imports plugin is a special case because it needs to be included in the config even if it's disabled, to ensure that the rules are applied correctly.
96
+ ...includeEnabled(unusedImports, toOption(plugins['unused-imports'])),
93
97
  ...(rules ? [{ rules }] : []),
94
98
  );
95
99
  }
@@ -426,11 +426,13 @@ type JsoncSortArrayValues = [{
426
426
  type?: ("asc" | "desc")
427
427
  caseSensitive?: boolean
428
428
  natural?: boolean
429
+ key?: string
429
430
  }
430
431
  })[] | {
431
432
  type?: ("asc" | "desc")
432
433
  caseSensitive?: boolean
433
434
  natural?: boolean
435
+ key?: string
434
436
  })
435
437
  minValues?: number
436
438
  }, ...({
@@ -441,11 +443,13 @@ type JsoncSortArrayValues = [{
441
443
  type?: ("asc" | "desc")
442
444
  caseSensitive?: boolean
443
445
  natural?: boolean
446
+ key?: string
444
447
  }
445
448
  })[] | {
446
449
  type?: ("asc" | "desc")
447
450
  caseSensitive?: boolean
448
451
  natural?: boolean
452
+ key?: string
449
453
  })
450
454
  minValues?: number
451
455
  })[]]
@@ -306,7 +306,7 @@ type PerfectionistSortArrayIncludes = {
306
306
  partitionByNewLine?: boolean
307
307
  }[]
308
308
  // ----- perfectionist/sort-arrays -----
309
- type PerfectionistSortArrays = {
309
+ type PerfectionistSortArrays = [{
310
310
 
311
311
  fallbackSort?: {
312
312
 
@@ -482,7 +482,183 @@ type PerfectionistSortArrays = {
482
482
  })
483
483
 
484
484
  partitionByNewLine?: boolean
485
- }[]
485
+ }, ...({
486
+
487
+ fallbackSort?: {
488
+
489
+ type: ("alphabetical" | "natural" | "line-length" | "custom" | "unsorted" | "subgroup-order")
490
+
491
+ order?: ("asc" | "desc")
492
+ }
493
+
494
+ type?: ("alphabetical" | "natural" | "line-length" | "custom" | "unsorted" | "subgroup-order")
495
+
496
+ specialCharacters?: ("remove" | "trim" | "keep")
497
+
498
+ ignoreCase?: boolean
499
+
500
+ alphabet?: string
501
+
502
+ locales?: (string | string[])
503
+
504
+ order?: ("asc" | "desc")
505
+
506
+ customGroups?: ({
507
+
508
+ fallbackSort?: {
509
+
510
+ type: ("alphabetical" | "natural" | "line-length" | "custom" | "unsorted" | "subgroup-order")
511
+
512
+ order?: ("asc" | "desc")
513
+ }
514
+
515
+ type?: ("alphabetical" | "natural" | "line-length" | "custom" | "unsorted" | "subgroup-order")
516
+
517
+ groupName: string
518
+ newlinesInside?: ("ignore" | number)
519
+
520
+ order?: ("asc" | "desc")
521
+
522
+ anyOf: [{
523
+
524
+ elementNamePattern?: (({
525
+
526
+ pattern: string
527
+
528
+ flags?: string
529
+ } | string)[] | ({
530
+
531
+ pattern: string
532
+
533
+ flags?: string
534
+ } | string))
535
+
536
+ selector?: "literal"
537
+ }, ...({
538
+
539
+ elementNamePattern?: (({
540
+
541
+ pattern: string
542
+
543
+ flags?: string
544
+ } | string)[] | ({
545
+
546
+ pattern: string
547
+
548
+ flags?: string
549
+ } | string))
550
+
551
+ selector?: "literal"
552
+ })[]]
553
+ } | {
554
+
555
+ fallbackSort?: {
556
+
557
+ type: ("alphabetical" | "natural" | "line-length" | "custom" | "unsorted" | "subgroup-order")
558
+
559
+ order?: ("asc" | "desc")
560
+ }
561
+
562
+ type?: ("alphabetical" | "natural" | "line-length" | "custom" | "unsorted" | "subgroup-order")
563
+
564
+ groupName: string
565
+ newlinesInside?: ("ignore" | number)
566
+
567
+ order?: ("asc" | "desc")
568
+
569
+ elementNamePattern?: (({
570
+
571
+ pattern: string
572
+
573
+ flags?: string
574
+ } | string)[] | ({
575
+
576
+ pattern: string
577
+
578
+ flags?: string
579
+ } | string))
580
+
581
+ selector?: "literal"
582
+ })[]
583
+ newlinesInside?: (("ignore" | number) | "newlinesBetween")
584
+
585
+ groups?: (string | [string, ...(string)[]] | {
586
+ newlinesBetween: ("ignore" | number)
587
+ } | {
588
+ group: (string | [string, ...(string)[]])
589
+
590
+ fallbackSort?: {
591
+
592
+ type: ("alphabetical" | "natural" | "line-length" | "custom" | "unsorted" | "subgroup-order")
593
+
594
+ order?: ("asc" | "desc")
595
+ }
596
+
597
+ commentAbove?: string
598
+
599
+ type?: ("alphabetical" | "natural" | "line-length" | "custom" | "unsorted" | "subgroup-order")
600
+ newlinesInside?: ("ignore" | number)
601
+
602
+ order?: ("asc" | "desc")
603
+ })[]
604
+ newlinesBetween?: ("ignore" | number)
605
+
606
+ useConfigurationIf: {
607
+
608
+ allNamesMatchPattern?: (({
609
+
610
+ pattern: string
611
+
612
+ flags?: string
613
+ } | string)[] | ({
614
+
615
+ pattern: string
616
+
617
+ flags?: string
618
+ } | string))
619
+
620
+ matchesAstSelector?: string
621
+ }
622
+
623
+ partitionByComment?: (boolean | (({
624
+
625
+ pattern: string
626
+
627
+ flags?: string
628
+ } | string)[] | ({
629
+
630
+ pattern: string
631
+
632
+ flags?: string
633
+ } | string)) | {
634
+
635
+ block?: (boolean | (({
636
+
637
+ pattern: string
638
+
639
+ flags?: string
640
+ } | string)[] | ({
641
+
642
+ pattern: string
643
+
644
+ flags?: string
645
+ } | string)))
646
+
647
+ line?: (boolean | (({
648
+
649
+ pattern: string
650
+
651
+ flags?: string
652
+ } | string)[] | ({
653
+
654
+ pattern: string
655
+
656
+ flags?: string
657
+ } | string)))
658
+ })
659
+
660
+ partitionByNewLine?: boolean
661
+ })[]]
486
662
  // ----- perfectionist/sort-classes -----
487
663
  type PerfectionistSortClasses = {
488
664
 
@@ -1071,6 +1247,8 @@ type PerfectionistSortEnums = {
1071
1247
  })[]
1072
1248
  newlinesBetween?: ("ignore" | number)
1073
1249
 
1250
+ sortByValue?: ("always" | "ifNumericEnum" | "never")
1251
+
1074
1252
  useConfigurationIf?: {
1075
1253
 
1076
1254
  allNamesMatchPattern?: (({
@@ -1088,8 +1266,6 @@ type PerfectionistSortEnums = {
1088
1266
  matchesAstSelector?: string
1089
1267
  }
1090
1268
 
1091
- sortByValue?: ("always" | "ifNumericEnum" | "never")
1092
-
1093
1269
  useExperimentalDependencyDetection?: boolean
1094
1270
 
1095
1271
  partitionByComment?: (boolean | (({
@@ -2450,6 +2626,7 @@ type PerfectionistSortIntersectionTypes = {
2450
2626
  })
2451
2627
 
2452
2628
  partitionByNewLine?: boolean
2629
+ ignoreCallableTypes?: boolean
2453
2630
  }[]
2454
2631
  // ----- perfectionist/sort-jsx-props -----
2455
2632
  type PerfectionistSortJsxProps = {
@@ -105,7 +105,7 @@ export interface RuleOptions {
105
105
  */
106
106
  'react/globals'?: Linter.RuleEntry<[]>
107
107
  /**
108
- * Validates against mutating props, state, and other values that are immutable.
108
+ * Validates against passing functions that mutate captured local variables into frozen contexts such as JSX props, hook arguments, and hook return values.
109
109
  * @see https://eslint-react.xyz/docs/rules/immutability
110
110
  */
111
111
  'react/immutability'?: Linter.RuleEntry<[]>
@@ -460,7 +460,7 @@ export interface RuleOptions {
460
460
  */
461
461
  'react/x-globals'?: Linter.RuleEntry<[]>
462
462
  /**
463
- * Validates against mutating props, state, and other values that are immutable.
463
+ * Validates against passing functions that mutate captured local variables into frozen contexts such as JSX props, hook arguments, and hook return values.
464
464
  * @see https://eslint-react.xyz/docs/rules/immutability
465
465
  */
466
466
  'react/x-immutability'?: Linter.RuleEntry<[]>
@@ -483,7 +483,7 @@ type TestNoFocusedTests = []|[{
483
483
  // ----- test/no-hooks -----
484
484
  type TestNoHooks = []|[{
485
485
 
486
- allow?: ("beforeAll" | "beforeEach" | "afterAll" | "afterEach")[]
486
+ allow?: ("beforeAll" | "beforeEach" | "afterAll" | "afterEach" | "aroundAll" | "aroundEach")[]
487
487
  }]
488
488
  // ----- test/no-large-snapshots -----
489
489
  type TestNoLargeSnapshots = []|[{
@@ -517,6 +517,8 @@ type TestPreferExpectAssertions = []|[{
517
517
  onlyFunctionsWithExpectInLoop?: boolean
518
518
 
519
519
  onlyFunctionsWithExpectInCallback?: boolean
520
+
521
+ disallowHasAssertions?: boolean
520
522
  }]
521
523
  // ----- test/prefer-import-in-mock -----
522
524
  type TestPreferImportInMock = []|[{
@@ -248,6 +248,7 @@ export interface RuleOptions {
248
248
  /**
249
249
  * Disallow function declarations that contain unsafe references inside loop statements
250
250
  * @see https://typescript-eslint.io/rules/no-loop-func
251
+ * @deprecated
251
252
  */
252
253
  'ts/no-loop-func'?: Linter.RuleEntry<[]>
253
254
  /**