@ntnyq/eslint-config 3.6.0 → 3.7.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
@@ -124,6 +124,8 @@ export interface ConfigOptions extends ConfigOptionsInternal {
124
124
 
125
125
  javascript?: ConfigJavaScriptOptions
126
126
 
127
+ specials?: ConfigSpecialsOptions
128
+
127
129
  sort?: boolean | ConfigSortOptions
128
130
 
129
131
  gitignore?: boolean | ConfigGitIgnoreOptions
package/dist/index.cjs CHANGED
@@ -61,6 +61,7 @@ __export(src_exports, {
61
61
  GLOB_TOML: () => GLOB_TOML,
62
62
  GLOB_TS: () => GLOB_TS,
63
63
  GLOB_TSX: () => GLOB_TSX,
64
+ GLOB_TYPES: () => GLOB_TYPES,
64
65
  GLOB_VUE: () => GLOB_VUE,
65
66
  GLOB_YAML: () => GLOB_YAML,
66
67
  antfu: () => antfu,
@@ -213,6 +214,7 @@ var GLOB_JSX = `${GLOB_JS}x`;
213
214
  var GLOB_TS = "**/*.?([cm])ts";
214
215
  var GLOB_TSX = `${GLOB_TS}x`;
215
216
  var GLOB_DTS = "**/*.d.?([cm])ts";
217
+ var GLOB_TYPES = [GLOB_DTS, `**/types/${GLOB_TS}`, `**/types.ts`];
216
218
  var GLOB_TEST = [
217
219
  `**/*.test.${GLOB_SRC_EXT}`,
218
220
  `**/*.spec.${GLOB_SRC_EXT}`,
@@ -395,12 +397,12 @@ var unCategorizedRules = {
395
397
  "vue/no-multiple-objects-in-class": "error",
396
398
  "vue/prefer-separate-static-class": "error",
397
399
  "vue/no-ref-object-reactivity-loss": "error",
398
- "vue/no-duplicate-attr-inheritance": "error",
399
400
  "vue/prefer-prop-type-boolean-first": "error",
400
401
  "vue/html-comment-indent": ["error", 2],
401
402
  "vue/next-tick-style": ["error", "promise"],
402
403
  "vue/v-for-delimiter-style": ["error", "in"],
403
404
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
405
+ "vue/slot-name-casing": ["error", "camelCase"],
404
406
  "vue/custom-event-name-casing": ["error", "camelCase"],
405
407
  "vue/define-props-declaration": ["error", "type-based"],
406
408
  "vue/define-emits-declaration": ["error", "type-literal"],
@@ -415,6 +417,12 @@ var unCategorizedRules = {
415
417
  reset: true
416
418
  }
417
419
  ],
420
+ "vue/no-duplicate-attr-inheritance": [
421
+ "error",
422
+ {
423
+ checkMultiRootNodes: true
424
+ }
425
+ ],
418
426
  "vue/block-order": [
419
427
  "error",
420
428
  {
@@ -698,7 +706,13 @@ var node = (options = {}) => [
698
706
  // src/configs/sort.ts
699
707
  var sort = (options = {}) => {
700
708
  const configs2 = [];
701
- if (options.tsconfig ?? true) {
709
+ const {
710
+ tsconfig: enableSortTsconfig = true,
711
+ packageJson: enableSortPackageJson = true,
712
+ i18nLocale: enableSortI18nLocale = true,
713
+ pnpmWorkspace: enableSortPnpmWorkspace = true
714
+ } = options;
715
+ if (enableSortTsconfig) {
702
716
  configs2.push({
703
717
  name: "ntnyq/sort/tsconfig",
704
718
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
@@ -814,7 +828,7 @@ var sort = (options = {}) => {
814
828
  }
815
829
  });
816
830
  }
817
- if (options.packageJson ?? true) {
831
+ if (enableSortPackageJson) {
818
832
  configs2.push({
819
833
  name: "ntnyq/sort/package-json",
820
834
  files: ["**/package.json"],
@@ -982,7 +996,7 @@ var sort = (options = {}) => {
982
996
  }
983
997
  });
984
998
  }
985
- if (options.i18nLocale ?? true) {
999
+ if (enableSortI18nLocale) {
986
1000
  configs2.push(
987
1001
  {
988
1002
  name: "ntnyq/sort/i18n-locale/json",
@@ -1012,7 +1026,7 @@ var sort = (options = {}) => {
1012
1026
  }
1013
1027
  );
1014
1028
  }
1015
- if (options.pnpmWorkspace ?? true) {
1029
+ if (enableSortPnpmWorkspace) {
1016
1030
  configs2.push({
1017
1031
  name: "ntnyq/sort/pnpm-workspace",
1018
1032
  files: ["**/pnpm-workspace.yaml"],
@@ -1438,51 +1452,51 @@ var unocss = (options = {}) => [
1438
1452
 
1439
1453
  // src/constants.ts
1440
1454
  var DEFAULT_PRETTIER_OPTIONS = {
1441
- // Maximum line length
1442
- printWidth: 100,
1443
1455
  // Specify the number of spaces per indentation-level
1444
1456
  tabWidth: 2,
1445
- // Indent lines with tabs instead of spaces
1446
- useTabs: false,
1447
1457
  // Use semicolons or not
1448
1458
  semi: false,
1459
+ // Format only a segment of a file.
1460
+ rangeStart: 0,
1461
+ // Indent lines with tabs instead of spaces
1462
+ useTabs: false,
1463
+ // Maximum line length
1464
+ printWidth: 100,
1465
+ // End of line
1466
+ endOfLine: "lf",
1449
1467
  // Use single quotes instead of double quotes
1450
1468
  singleQuote: true,
1451
- // Change when properties in objects are quoted
1452
- quoteProps: "as-needed",
1469
+ // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1470
+ insertPragma: false,
1453
1471
  // Use single quotes instead of double quotes in JSX
1454
1472
  jsxSingleQuote: true,
1455
1473
  // Print trailing commas wherever possible when multi-line
1456
1474
  trailingComma: "all",
1457
1475
  // Print spaces between brackets in object literals.
1458
1476
  bracketSpacing: true,
1459
- // Put the > of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being alone on the next line (does not apply to self closing elements)
1460
- bracketSameLine: false,
1461
1477
  // Include parentheses around a sole arrow function parameter
1462
1478
  arrowParens: "avoid",
1463
- // Format only a segment of a file.
1464
- rangeStart: 0,
1465
- rangeEnd: Number.POSITIVE_INFINITY,
1479
+ // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1480
+ requirePragma: false,
1466
1481
  // Specify which parser to use.
1467
1482
  // parser: undefined,
1468
1483
  // Specify the file name to use to infer which parser to use.
1469
1484
  // filepath: undefined,
1470
- // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1471
- requirePragma: false,
1472
- // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1473
- insertPragma: false,
1474
1485
  // By default, Prettier will wrap markdown text as-is since some services use a line-break-sensitive renderer, e.g. GitHub comment and Bitbucket.
1475
1486
  proseWrap: "preserve",
1476
- // Specify the global whitespace sensitivity for HTML files
1477
- htmlWhitespaceSensitivity: "css",
1487
+ // Put the > of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being alone on the next line (does not apply to self closing elements)
1488
+ bracketSameLine: false,
1489
+ // Change when properties in objects are quoted
1490
+ quoteProps: "as-needed",
1491
+ // Enforce single attribute per line in HTML, Vue and JSX
1492
+ singleAttributePerLine: true,
1478
1493
  // Whether or not to indent the code inside <script> and <style> tags in Vue files
1479
1494
  vueIndentScriptAndStyle: false,
1480
- // End of line
1481
- endOfLine: "lf",
1495
+ // Specify the global whitespace sensitivity for HTML files
1496
+ htmlWhitespaceSensitivity: "css",
1497
+ rangeEnd: Number.POSITIVE_INFINITY,
1482
1498
  // Control whether Prettier formats quoted code embedded in the file
1483
- embeddedLanguageFormatting: "auto",
1484
- // Enforce single attribute per line in HTML, Vue and JSX
1485
- singleAttributePerLine: true
1499
+ embeddedLanguageFormatting: "auto"
1486
1500
  };
1487
1501
 
1488
1502
  // src/utils/env.ts
@@ -1817,6 +1831,27 @@ var specials = (options = {}) => [
1817
1831
  ...options.overridesUserScriptsRules
1818
1832
  }
1819
1833
  },
1834
+ {
1835
+ name: "ntnyq/specials/config-file",
1836
+ files: [`**/*.config*.${GLOB_SRC_EXT}`],
1837
+ plugins: {
1838
+ import: import_eslint_plugin_import_x.default,
1839
+ perfectionist: import_eslint_plugin_perfectionist.default
1840
+ },
1841
+ rules: {
1842
+ "no-console": "off",
1843
+ "import/no-default-export": "off",
1844
+ "@typescript-eslint/explicit-function-return-type": "off",
1845
+ "perfectionist/sort-objects": [
1846
+ "error",
1847
+ {
1848
+ type: "line-length",
1849
+ order: "asc"
1850
+ }
1851
+ ],
1852
+ ...options.overridesConfigFileRules
1853
+ }
1854
+ },
1820
1855
  // More special case configs
1821
1856
  // So don't need to append configs to composer
1822
1857
  ...options.specialCaseConfigs ? options.specialCaseConfigs : []
@@ -2426,7 +2461,7 @@ var typescript = (options = {}) => {
2426
2461
  ] : [],
2427
2462
  {
2428
2463
  name: "ntnyq/ts/types",
2429
- files: [GLOB_DTS, "**/types/**/*.ts"],
2464
+ files: [...GLOB_TYPES],
2430
2465
  rules: {
2431
2466
  "no-use-before-define": "off",
2432
2467
  "no-restricted-syntax": "off",
@@ -2455,90 +2490,228 @@ var githubAction = (options = {}) => [
2455
2490
  ];
2456
2491
 
2457
2492
  // src/configs/perfectionist.ts
2458
- var perfectionist = (options = {}) => [
2459
- {
2460
- name: "ntnyq/perfectionist",
2461
- plugins: {
2462
- perfectionist: import_eslint_plugin_perfectionist.default
2463
- },
2464
- rules: {
2465
- "perfectionist/sort-imports": [
2466
- "error",
2467
- {
2468
- groups: [
2469
- // Side effect style imports (e.g. 'normalize.css')
2470
- "side-effect-style",
2471
- // Styles (e.g. *.{css,scss,less})
2472
- "style",
2473
- // Node.js built-in modules. (e.g. fs, path)
2474
- "builtin",
2475
- // External modules installed in the project (e.g. vue, lodash)
2476
- "external",
2477
- // Internal modules (e.g. @/utils, @/components)
2478
- "internal",
2479
- // Modules from parent directory (e.g. ../utils)
2480
- "parent",
2481
- // Modules from the same directory (e.g. ./utils)
2482
- "sibling",
2483
- // Main file from the current directory (e.g. ./index)
2484
- "index",
2485
- // TypeScript object-imports (e.g. import log = console.log)
2486
- "object",
2487
- // Side effect imports (e.g. import 'babel-polyfill')
2488
- "side-effect",
2489
- /**
2490
- * Type import at the end
2491
- */
2492
- "builtin-type",
2493
- "external-type",
2494
- "internal-type",
2495
- "parent-type",
2496
- "sibling-type",
2497
- "index-type",
2498
- "type",
2499
- /**
2500
- * Imports that don’t fit into any other group
2501
- */
2502
- "unknown"
2503
- ],
2504
- order: options.imports?.order || "asc",
2505
- type: options.imports?.type || "natural",
2506
- ignoreCase: true,
2507
- internalPattern: ["^~/.+", "^@/.+", "^#.+"],
2508
- newlinesBetween: "ignore"
2509
- }
2510
- ],
2511
- "perfectionist/sort-exports": [
2512
- "error",
2513
- {
2514
- order: options.exports?.order || "asc",
2515
- type: options.exports?.type || "line-length"
2516
- }
2517
- ],
2518
- "perfectionist/sort-named-exports": [
2519
- "error",
2520
- {
2521
- type: options.namedExports?.type || "alphabetical",
2522
- order: options.namedExports?.order || "asc",
2523
- ignoreCase: true,
2524
- groupKind: "values-first"
2525
- }
2526
- ],
2527
- "perfectionist/sort-named-imports": [
2528
- "error",
2529
- {
2530
- type: options.namedImports?.type || "alphabetical",
2531
- order: options.namedImports?.order || "asc",
2532
- ignoreCase: true,
2533
- ignoreAlias: false,
2534
- groupKind: "values-first"
2535
- }
2536
- ],
2537
- // Overrides rules
2538
- ...options.overrides
2493
+ var perfectionist = (options = {}) => {
2494
+ const {
2495
+ sortEnums: enableSortEnums = true,
2496
+ sortTypes: enableSortTypes = true,
2497
+ sortConstants: enableSortConstants = true
2498
+ } = options;
2499
+ const configs2 = [
2500
+ {
2501
+ name: "ntnyq/perfectionist/common",
2502
+ plugins: {
2503
+ perfectionist: import_eslint_plugin_perfectionist.default
2504
+ },
2505
+ rules: {
2506
+ "perfectionist/sort-imports": [
2507
+ "error",
2508
+ {
2509
+ groups: [
2510
+ // Side effect style imports (e.g. 'normalize.css')
2511
+ "side-effect-style",
2512
+ // Styles (e.g. *.{css,scss,less})
2513
+ "style",
2514
+ // Node.js built-in modules. (e.g. fs, path)
2515
+ "builtin",
2516
+ // External modules installed in the project (e.g. vue, lodash)
2517
+ "external",
2518
+ // Internal modules (e.g. @/utils, @/components)
2519
+ "internal",
2520
+ // Modules from parent directory (e.g. ../utils)
2521
+ "parent",
2522
+ // Modules from the same directory (e.g. ./utils)
2523
+ "sibling",
2524
+ // Main file from the current directory (e.g. ./index)
2525
+ "index",
2526
+ // TypeScript object-imports (e.g. import log = console.log)
2527
+ "object",
2528
+ // Side effect imports (e.g. import 'babel-polyfill')
2529
+ "side-effect",
2530
+ /**
2531
+ * Type import at the end
2532
+ */
2533
+ "builtin-type",
2534
+ "external-type",
2535
+ "internal-type",
2536
+ "parent-type",
2537
+ "sibling-type",
2538
+ "index-type",
2539
+ "type",
2540
+ /**
2541
+ * Imports that don’t fit into any other group
2542
+ */
2543
+ "unknown"
2544
+ ],
2545
+ order: "asc",
2546
+ type: "natural",
2547
+ ignoreCase: true,
2548
+ internalPattern: ["^~/.+", "^@/.+", "^#.+"],
2549
+ newlinesBetween: "ignore"
2550
+ }
2551
+ ],
2552
+ "perfectionist/sort-exports": [
2553
+ "error",
2554
+ {
2555
+ order: "asc",
2556
+ type: "line-length"
2557
+ }
2558
+ ],
2559
+ "perfectionist/sort-named-exports": [
2560
+ "error",
2561
+ {
2562
+ type: "alphabetical",
2563
+ order: "asc",
2564
+ ignoreCase: true,
2565
+ groupKind: "values-first"
2566
+ }
2567
+ ],
2568
+ "perfectionist/sort-named-imports": [
2569
+ "error",
2570
+ {
2571
+ type: "alphabetical",
2572
+ order: "asc",
2573
+ ignoreCase: true,
2574
+ ignoreAlias: false,
2575
+ groupKind: "values-first"
2576
+ }
2577
+ ],
2578
+ // Overrides rules
2579
+ ...options.overrides
2580
+ }
2539
2581
  }
2582
+ ];
2583
+ if (enableSortEnums) {
2584
+ configs2.push({
2585
+ name: "ntnyq/perfectionist/enums",
2586
+ files: [`**/enums/${GLOB_SRC}`, `**/enums.${GLOB_SRC_EXT}`],
2587
+ plugins: {
2588
+ perfectionist: import_eslint_plugin_perfectionist.default
2589
+ },
2590
+ rules: {
2591
+ "perfectionist/sort-enums": [
2592
+ "error",
2593
+ {
2594
+ type: "line-length",
2595
+ order: "asc"
2596
+ }
2597
+ ],
2598
+ "perfectionist/sort-modules": [
2599
+ "error",
2600
+ {
2601
+ type: "line-length",
2602
+ order: "asc"
2603
+ }
2604
+ ],
2605
+ // Overrides rules
2606
+ ...options.overridesEnumsRules
2607
+ }
2608
+ });
2540
2609
  }
2541
- ];
2610
+ if (enableSortTypes) {
2611
+ configs2.push({
2612
+ name: "ntnyq/perfectionist/types",
2613
+ files: [...GLOB_TYPES],
2614
+ plugins: {
2615
+ perfectionist: import_eslint_plugin_perfectionist.default
2616
+ },
2617
+ rules: {
2618
+ "perfectionist/sort-heritage-clauses": [
2619
+ "error",
2620
+ {
2621
+ type: "alphabetical",
2622
+ order: "asc"
2623
+ }
2624
+ ],
2625
+ // 'perfectionist/sort-interfaces': [
2626
+ // 'error',
2627
+ // {
2628
+ // type: 'alphabetical',
2629
+ // order: 'asc',
2630
+ // },
2631
+ // ],
2632
+ "perfectionist/sort-intersection-types": [
2633
+ "error",
2634
+ {
2635
+ type: "alphabetical",
2636
+ order: "asc",
2637
+ groups: [
2638
+ "intersection",
2639
+ "named",
2640
+ "conditional",
2641
+ "function",
2642
+ "import",
2643
+ "keyword",
2644
+ "literal",
2645
+ "object",
2646
+ "operator",
2647
+ "tuple",
2648
+ "union",
2649
+ "nullish"
2650
+ ]
2651
+ }
2652
+ ],
2653
+ "perfectionist/sort-modules": [
2654
+ "error",
2655
+ {
2656
+ type: "line-length",
2657
+ order: "asc"
2658
+ }
2659
+ ],
2660
+ "perfectionist/sort-object-types": [
2661
+ "error",
2662
+ {
2663
+ type: "alphabetical",
2664
+ order: "asc"
2665
+ }
2666
+ ],
2667
+ "perfectionist/sort-union-types": [
2668
+ "error",
2669
+ {
2670
+ type: "line-length",
2671
+ order: "asc"
2672
+ }
2673
+ ],
2674
+ // Overrides rules
2675
+ ...options.overridesTypesRules
2676
+ }
2677
+ });
2678
+ }
2679
+ if (enableSortConstants) {
2680
+ configs2.push({
2681
+ name: "ntnyq/perfectionist/constants",
2682
+ files: [`**/constants/${GLOB_SRC}`, `**/constants.${GLOB_SRC_EXT}`],
2683
+ plugins: {
2684
+ perfectionist: import_eslint_plugin_perfectionist.default
2685
+ },
2686
+ rules: {
2687
+ "perfectionist/sort-maps": [
2688
+ "error",
2689
+ {
2690
+ type: "alphabetical",
2691
+ order: "asc"
2692
+ }
2693
+ ],
2694
+ "perfectionist/sort-objects": [
2695
+ "error",
2696
+ {
2697
+ type: "line-length",
2698
+ order: "asc"
2699
+ }
2700
+ ],
2701
+ "perfectionist/sort-sets": [
2702
+ "error",
2703
+ {
2704
+ type: "line-length",
2705
+ order: "asc"
2706
+ }
2707
+ ],
2708
+ // Overrides rules
2709
+ ...options.overridesConstantsRules
2710
+ }
2711
+ });
2712
+ }
2713
+ return configs2;
2714
+ };
2542
2715
 
2543
2716
  // src/configs/unusedImports.ts
2544
2717
  var unusedImports = (options = {}) => [
@@ -2798,6 +2971,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
2798
2971
  GLOB_TOML,
2799
2972
  GLOB_TS,
2800
2973
  GLOB_TSX,
2974
+ GLOB_TYPES,
2801
2975
  GLOB_VUE,
2802
2976
  GLOB_YAML,
2803
2977
  antfu,