@ntnyq/eslint-config 3.7.1 → 3.8.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/README.md CHANGED
@@ -116,7 +116,7 @@ export interface ConfigOptions extends ConfigOptionsInternal {
116
116
 
117
117
  ignores?: ConfigIgnoresOptions
118
118
 
119
- imports?: ConfigImportsOptions
119
+ importX?: ConfigImportsOptions
120
120
 
121
121
  command?: ConfigCommandOptions
122
122
 
package/dist/index.cjs CHANGED
@@ -67,6 +67,9 @@ __export(src_exports, {
67
67
  antfu: () => antfu,
68
68
  command: () => command,
69
69
  comments: () => comments,
70
+ defaultSortInterfacesGroups: () => defaultSortInterfacesGroups,
71
+ defaultSortIntersectionTypesGroups: () => defaultSortIntersectionTypesGroups,
72
+ defaultSortObjectTypesGroups: () => defaultSortObjectTypesGroups,
70
73
  defineESLintConfig: () => defineESLintConfig,
71
74
  format: () => format,
72
75
  getOverrides: () => getOverrides,
@@ -77,7 +80,7 @@ __export(src_exports, {
77
80
  hasVitest: () => hasVitest,
78
81
  hasVue: () => hasVue,
79
82
  ignores: () => ignores,
80
- imports: () => imports,
83
+ importX: () => importX,
81
84
  interopDefault: () => interopDefault,
82
85
  javascript: () => javascript,
83
86
  jsdoc: () => jsdoc,
@@ -100,7 +103,7 @@ __export(src_exports, {
100
103
  pluginComments: () => import_eslint_plugin_eslint_comments.default,
101
104
  pluginFormat: () => import_eslint_plugin_format.default,
102
105
  pluginGitHubAction: () => import_eslint_plugin_github_action.default,
103
- pluginImport: () => import_eslint_plugin_import_x.default,
106
+ pluginImportX: () => import_eslint_plugin_import_x.default,
104
107
  pluginJsdoc: () => import_eslint_plugin_jsdoc.default,
105
108
  pluginJsonc: () => import_eslint_plugin_jsonc.default,
106
109
  pluginMarkdown: () => import_markdown.default,
@@ -189,8 +192,8 @@ var import_typescript_eslint2 = require("typescript-eslint");
189
192
  var import_eslint_plugin_format = __toESM(require("eslint-plugin-format"), 1);
190
193
  var import_eslint_plugin = __toESM(require("@unocss/eslint-plugin"), 1);
191
194
  var import_eslint_plugin2 = __toESM(require("@vitest/eslint-plugin"), 1);
192
- var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
193
195
  var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
196
+ var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
194
197
  var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
195
198
  var import_eslint_plugin3 = __toESM(require("@stylistic/eslint-plugin"), 1);
196
199
  var import_eslint_plugin_github_action = __toESM(require("eslint-plugin-github-action"), 1);
@@ -1154,7 +1157,6 @@ var jsdoc = (options = {}) => [
1154
1157
  "jsdoc/check-line-alignment": "error",
1155
1158
  "jsdoc/check-param-names": "error",
1156
1159
  "jsdoc/check-property-names": "error",
1157
- "jsdoc/check-tag-names": "error",
1158
1160
  "jsdoc/check-types": "error",
1159
1161
  "jsdoc/empty-tags": "error",
1160
1162
  "jsdoc/multiline-blocks": "error",
@@ -1165,6 +1167,16 @@ var jsdoc = (options = {}) => [
1165
1167
  "jsdoc/no-multi-asterisks": "error",
1166
1168
  "jsdoc/require-asterisk-prefix": "error",
1167
1169
  "jsdoc/require-hyphen-before-param-description": "error",
1170
+ "jsdoc/check-tag-names": [
1171
+ "error",
1172
+ {
1173
+ definedTags: [
1174
+ // magic-comments
1175
+ "vite-ignore",
1176
+ "unocss-include"
1177
+ ]
1178
+ }
1179
+ ],
1168
1180
  // TODO: this after investigate
1169
1181
  // 'jsdoc/sort-tags': [
1170
1182
  // 'error',
@@ -1667,31 +1679,31 @@ var ignores = (customIgnores = []) => [
1667
1679
  }
1668
1680
  ];
1669
1681
 
1670
- // src/configs/imports.ts
1671
- var imports = (options = {}) => [
1682
+ // src/configs/importX.ts
1683
+ var importX = (options = {}) => [
1672
1684
  {
1673
- name: "ntnyq/imports",
1685
+ name: "ntnyq/import-x",
1674
1686
  plugins: {
1675
- import: import_eslint_plugin_import_x.default
1687
+ "import-x": import_eslint_plugin_import_x.default
1676
1688
  },
1677
1689
  settings: {
1678
- "import/resolver": {
1690
+ "import-x/resolver": {
1679
1691
  node: { extensions: [".js", ".mjs", ".ts", ".mts", ".d.ts"] }
1680
1692
  }
1681
1693
  },
1682
1694
  rules: {
1683
- "import/no-unresolved": "off",
1684
- "import/no-absolute-path": "off",
1685
- "import/no-named-as-default-member": "off",
1686
- "import/no-named-default": "off",
1695
+ "import-x/no-unresolved": "off",
1696
+ "import-x/no-absolute-path": "off",
1697
+ "import-x/no-named-as-default-member": "off",
1698
+ "import-x/no-named-default": "off",
1687
1699
  // disabled in favor or `perfectionist/sort-imports`
1688
- "import/order": "off",
1689
- "import/first": "error",
1690
- "import/export": "error",
1691
- "import/no-self-import": "error",
1692
- "import/no-duplicates": "error",
1693
- "import/no-mutable-exports": "error",
1694
- "import/newline-after-import": "error",
1700
+ "import-x/order": "off",
1701
+ "import-x/first": "error",
1702
+ "import-x/export": "error",
1703
+ "import-x/no-self-import": "error",
1704
+ "import-x/no-duplicates": "error",
1705
+ "import-x/no-mutable-exports": "error",
1706
+ "import-x/newline-after-import": "error",
1695
1707
  // Overrides rules
1696
1708
  ...options.overrides
1697
1709
  }
@@ -1835,12 +1847,12 @@ var specials = (options = {}) => [
1835
1847
  name: "ntnyq/specials/config-file",
1836
1848
  files: [`**/*.config*.${GLOB_SRC_EXT}`],
1837
1849
  plugins: {
1838
- import: import_eslint_plugin_import_x.default,
1850
+ "import-x": import_eslint_plugin_import_x.default,
1839
1851
  perfectionist: import_eslint_plugin_perfectionist.default
1840
1852
  },
1841
1853
  rules: {
1842
1854
  "no-console": "off",
1843
- "import/no-default-export": "off",
1855
+ "import-x/no-default-export": "off",
1844
1856
  "@typescript-eslint/explicit-function-return-type": "off",
1845
1857
  "perfectionist/sort-objects": [
1846
1858
  "error",
@@ -1922,7 +1934,7 @@ var markdown = (options = {}) => {
1922
1934
  "no-restricted-imports": "off",
1923
1935
  "node/prefer-global/buffer": "off",
1924
1936
  "node/prefer-global/process": "off",
1925
- "import/no-unresolved": "off",
1937
+ "import-x/no-unresolved": "off",
1926
1938
  "unused-imports/no-unused-imports": "off",
1927
1939
  "unused-imports/no-unused-vars": "off",
1928
1940
  "@typescript-eslint/comma-dangle": "off",
@@ -2465,8 +2477,8 @@ var typescript = (options = {}) => {
2465
2477
  rules: {
2466
2478
  "no-use-before-define": "off",
2467
2479
  "no-restricted-syntax": "off",
2468
- "import/no-duplicates": "off",
2469
- "import/newline-after-import": "off",
2480
+ "import-x/no-duplicates": "off",
2481
+ "import-x/newline-after-import": "off",
2470
2482
  "@typescript-eslint/no-use-before-define": "off"
2471
2483
  }
2472
2484
  }
@@ -2474,22 +2486,97 @@ var typescript = (options = {}) => {
2474
2486
  };
2475
2487
 
2476
2488
  // src/configs/githubAction.ts
2477
- var githubAction = (options = {}) => [
2478
- {
2489
+ var import_eslint_plugin_github_action2 = require("eslint-plugin-github-action");
2490
+ var githubAction = (options = {}) => {
2491
+ const {
2492
+ // Support common overrides rules
2493
+ overrides: overridesRules = {},
2494
+ // Flat config options
2495
+ ...restOptions
2496
+ } = options;
2497
+ const recommendedConfig = (0, import_eslint_plugin_github_action2.createRecommendedConfig)({
2479
2498
  name: "ntnyq/github-action",
2480
2499
  files: [GLOB_GITHUB_ACTION],
2481
- plugins: {
2482
- "github-action": import_eslint_plugin_github_action.default
2483
- },
2484
- rules: {
2485
- "github-action/require-action-name": "error",
2486
- // Overrides rules
2487
- ...options.overrides
2500
+ ...restOptions
2501
+ });
2502
+ return [
2503
+ {
2504
+ ...recommendedConfig,
2505
+ rules: {
2506
+ ...recommendedConfig.rules,
2507
+ // Overrides rules
2508
+ ...overridesRules
2509
+ }
2488
2510
  }
2489
- }
2490
- ];
2511
+ ];
2512
+ };
2491
2513
 
2492
2514
  // src/configs/perfectionist.ts
2515
+ var sharedGroups = [
2516
+ "required-property",
2517
+ "optional-property",
2518
+ "required-method",
2519
+ "optional-method",
2520
+ "required-multiline-property",
2521
+ "optional-multiline-property",
2522
+ "required-multiline-method",
2523
+ "optional-multiline-method",
2524
+ "unknown",
2525
+ "index-signature",
2526
+ "multiline-index-signature"
2527
+ ];
2528
+ var defaultSortInterfacesGroups = [...sharedGroups];
2529
+ var defaultSortObjectTypesGroups = [...sharedGroups];
2530
+ var defaultSortIntersectionTypesGroups = [
2531
+ /**
2532
+ * eg. 'foobar', 24, false
2533
+ */
2534
+ "literal",
2535
+ /**
2536
+ * eg. number, string
2537
+ */
2538
+ "keyword",
2539
+ /**
2540
+ * eg. FooBar
2541
+ */
2542
+ "named",
2543
+ /**
2544
+ * eg. Foo & Bar
2545
+ */
2546
+ "intersection",
2547
+ /**
2548
+ * eg. Foobar extends string ? Foo : Bar
2549
+ */
2550
+ "conditional",
2551
+ /**
2552
+ * eg. (...args: any[]) => void
2553
+ */
2554
+ "function",
2555
+ /**
2556
+ * eg. import('eslint').Linter
2557
+ */
2558
+ "import",
2559
+ /**
2560
+ * eg. { foo: string; bar: number; }
2561
+ */
2562
+ "object",
2563
+ /**
2564
+ * eg. keyof T
2565
+ */
2566
+ "operator",
2567
+ /**
2568
+ * eg. [string, number]
2569
+ */
2570
+ "tuple",
2571
+ /**
2572
+ * eg. Foo | Bar
2573
+ */
2574
+ "union",
2575
+ /**
2576
+ * eg. null | undefined
2577
+ */
2578
+ "nullish"
2579
+ ];
2493
2580
  var perfectionist = (options = {}) => {
2494
2581
  const {
2495
2582
  sortEnums: enableSortEnums = true,
@@ -2592,7 +2679,8 @@ var perfectionist = (options = {}) => {
2592
2679
  "error",
2593
2680
  {
2594
2681
  type: "alphabetical",
2595
- order: "asc"
2682
+ order: "asc",
2683
+ partitionByComment: true
2596
2684
  }
2597
2685
  ],
2598
2686
  "perfectionist/sort-modules": [
@@ -2623,32 +2711,22 @@ var perfectionist = (options = {}) => {
2623
2711
  order: "asc"
2624
2712
  }
2625
2713
  ],
2626
- // 'perfectionist/sort-interfaces': [
2627
- // 'error',
2628
- // {
2629
- // type: 'alphabetical',
2630
- // order: 'asc',
2631
- // },
2632
- // ],
2714
+ "perfectionist/sort-interfaces": [
2715
+ "error",
2716
+ {
2717
+ type: "alphabetical",
2718
+ order: "asc",
2719
+ partitionByComment: true,
2720
+ groups: defaultSortInterfacesGroups
2721
+ }
2722
+ ],
2633
2723
  "perfectionist/sort-intersection-types": [
2634
2724
  "error",
2635
2725
  {
2636
2726
  type: "alphabetical",
2637
2727
  order: "asc",
2638
- groups: [
2639
- "intersection",
2640
- "named",
2641
- "conditional",
2642
- "function",
2643
- "import",
2644
- "keyword",
2645
- "literal",
2646
- "object",
2647
- "operator",
2648
- "tuple",
2649
- "union",
2650
- "nullish"
2651
- ]
2728
+ partitionByComment: true,
2729
+ groups: [...defaultSortIntersectionTypesGroups]
2652
2730
  }
2653
2731
  ],
2654
2732
  "perfectionist/sort-modules": [
@@ -2663,14 +2741,17 @@ var perfectionist = (options = {}) => {
2663
2741
  "error",
2664
2742
  {
2665
2743
  type: "alphabetical",
2666
- order: "asc"
2744
+ order: "asc",
2745
+ partitionByComment: true,
2746
+ groups: []
2667
2747
  }
2668
2748
  ],
2669
2749
  "perfectionist/sort-union-types": [
2670
2750
  "error",
2671
2751
  {
2672
2752
  type: "alphabetical",
2673
- order: "asc"
2753
+ order: "asc",
2754
+ partitionByComment: true
2674
2755
  }
2675
2756
  ],
2676
2757
  // Overrides rules
@@ -2690,21 +2771,24 @@ var perfectionist = (options = {}) => {
2690
2771
  "error",
2691
2772
  {
2692
2773
  type: "alphabetical",
2693
- order: "asc"
2774
+ order: "asc",
2775
+ partitionByComment: true
2694
2776
  }
2695
2777
  ],
2696
2778
  "perfectionist/sort-objects": [
2697
2779
  "error",
2698
2780
  {
2699
2781
  type: "alphabetical",
2700
- order: "asc"
2782
+ order: "asc",
2783
+ partitionByComment: true
2701
2784
  }
2702
2785
  ],
2703
2786
  "perfectionist/sort-sets": [
2704
2787
  "error",
2705
2788
  {
2706
2789
  type: "alphabetical",
2707
- order: "asc"
2790
+ order: "asc",
2791
+ partitionByComment: true
2708
2792
  }
2709
2793
  ],
2710
2794
  "perfectionist/sort-modules": [
@@ -2803,8 +2887,8 @@ function defineESLintConfig(options = {}, ...userConfigs) {
2803
2887
  ...command({
2804
2888
  ...resolveSubOptions(options, "command")
2805
2889
  }),
2806
- ...imports({
2807
- overrides: getOverrides(options, "imports")
2890
+ ...importX({
2891
+ overrides: getOverrides(options, "importX")
2808
2892
  }),
2809
2893
  ...jsdoc({
2810
2894
  typescript: !!enableTypeScript,
@@ -2987,6 +3071,9 @@ function defineESLintConfig(options = {}, ...userConfigs) {
2987
3071
  antfu,
2988
3072
  command,
2989
3073
  comments,
3074
+ defaultSortInterfacesGroups,
3075
+ defaultSortIntersectionTypesGroups,
3076
+ defaultSortObjectTypesGroups,
2990
3077
  defineESLintConfig,
2991
3078
  format,
2992
3079
  getOverrides,
@@ -2997,7 +3084,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
2997
3084
  hasVitest,
2998
3085
  hasVue,
2999
3086
  ignores,
3000
- imports,
3087
+ importX,
3001
3088
  interopDefault,
3002
3089
  javascript,
3003
3090
  jsdoc,
@@ -3020,7 +3107,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
3020
3107
  pluginComments,
3021
3108
  pluginFormat,
3022
3109
  pluginGitHubAction,
3023
- pluginImport,
3110
+ pluginImportX,
3024
3111
  pluginJsdoc,
3025
3112
  pluginJsonc,
3026
3113
  pluginMarkdown,