@ntnyq/eslint-config 3.6.0 → 3.7.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.
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 = {
1455
+ // Include parentheses around a sole arrow function parameter
1456
+ arrowParens: "avoid",
1457
+ // 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)
1458
+ bracketSameLine: false,
1459
+ // Print spaces between brackets in object literals.
1460
+ bracketSpacing: true,
1461
+ // Control whether Prettier formats quoted code embedded in the file
1462
+ embeddedLanguageFormatting: "auto",
1463
+ // End of line
1464
+ endOfLine: "lf",
1465
+ // Specify the global whitespace sensitivity for HTML files
1466
+ htmlWhitespaceSensitivity: "css",
1467
+ // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1468
+ insertPragma: false,
1469
+ // Use single quotes instead of double quotes in JSX
1470
+ jsxSingleQuote: true,
1441
1471
  // Maximum line length
1442
1472
  printWidth: 100,
1443
- // Specify the number of spaces per indentation-level
1444
- tabWidth: 2,
1445
- // Indent lines with tabs instead of spaces
1446
- useTabs: false,
1447
- // Use semicolons or not
1448
- semi: false,
1449
- // Use single quotes instead of double quotes
1450
- singleQuote: true,
1473
+ // By default, Prettier will wrap markdown text as-is since some services use a line-break-sensitive renderer, e.g. GitHub comment and Bitbucket.
1474
+ proseWrap: "preserve",
1451
1475
  // Change when properties in objects are quoted
1452
1476
  quoteProps: "as-needed",
1453
- // Use single quotes instead of double quotes in JSX
1454
- jsxSingleQuote: true,
1455
- // Print trailing commas wherever possible when multi-line
1456
- trailingComma: "all",
1457
- // Print spaces between brackets in object literals.
1458
- 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
- // Include parentheses around a sole arrow function parameter
1462
- arrowParens: "avoid",
1477
+ rangeEnd: Number.POSITIVE_INFINITY,
1463
1478
  // Format only a segment of a file.
1464
1479
  rangeStart: 0,
1465
- rangeEnd: Number.POSITIVE_INFINITY,
1466
1480
  // Specify which parser to use.
1467
1481
  // parser: undefined,
1468
1482
  // Specify the file name to use to infer which parser to use.
1469
1483
  // filepath: undefined,
1470
1484
  // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1471
1485
  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
- // 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
- proseWrap: "preserve",
1476
- // Specify the global whitespace sensitivity for HTML files
1477
- htmlWhitespaceSensitivity: "css",
1478
- // Whether or not to indent the code inside <script> and <style> tags in Vue files
1479
- vueIndentScriptAndStyle: false,
1480
- // End of line
1481
- endOfLine: "lf",
1482
- // Control whether Prettier formats quoted code embedded in the file
1483
- embeddedLanguageFormatting: "auto",
1486
+ // Use semicolons or not
1487
+ semi: false,
1484
1488
  // Enforce single attribute per line in HTML, Vue and JSX
1485
- singleAttributePerLine: true
1489
+ singleAttributePerLine: true,
1490
+ // Use single quotes instead of double quotes
1491
+ singleQuote: true,
1492
+ // Specify the number of spaces per indentation-level
1493
+ tabWidth: 2,
1494
+ // Print trailing commas wherever possible when multi-line
1495
+ trailingComma: "all",
1496
+ // Indent lines with tabs instead of spaces
1497
+ useTabs: false,
1498
+ // Whether or not to indent the code inside <script> and <style> tags in Vue files
1499
+ vueIndentScriptAndStyle: false
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: "alphabetical",
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,238 @@ 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: "alphabetical",
2595
+ order: "asc"
2596
+ }
2597
+ ],
2598
+ "perfectionist/sort-modules": [
2599
+ "error",
2600
+ {
2601
+ type: "alphabetical",
2602
+ order: "asc",
2603
+ partitionByComment: true
2604
+ }
2605
+ ],
2606
+ // Overrides rules
2607
+ ...options.overridesEnumsRules
2608
+ }
2609
+ });
2540
2610
  }
2541
- ];
2611
+ if (enableSortTypes) {
2612
+ configs2.push({
2613
+ name: "ntnyq/perfectionist/types",
2614
+ files: [...GLOB_TYPES],
2615
+ plugins: {
2616
+ perfectionist: import_eslint_plugin_perfectionist.default
2617
+ },
2618
+ rules: {
2619
+ "perfectionist/sort-heritage-clauses": [
2620
+ "error",
2621
+ {
2622
+ type: "alphabetical",
2623
+ order: "asc"
2624
+ }
2625
+ ],
2626
+ // 'perfectionist/sort-interfaces': [
2627
+ // 'error',
2628
+ // {
2629
+ // type: 'alphabetical',
2630
+ // order: 'asc',
2631
+ // },
2632
+ // ],
2633
+ "perfectionist/sort-intersection-types": [
2634
+ "error",
2635
+ {
2636
+ type: "alphabetical",
2637
+ 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
+ ]
2652
+ }
2653
+ ],
2654
+ "perfectionist/sort-modules": [
2655
+ "error",
2656
+ {
2657
+ type: "alphabetical",
2658
+ order: "asc",
2659
+ partitionByComment: true
2660
+ }
2661
+ ],
2662
+ "perfectionist/sort-object-types": [
2663
+ "error",
2664
+ {
2665
+ type: "alphabetical",
2666
+ order: "asc"
2667
+ }
2668
+ ],
2669
+ "perfectionist/sort-union-types": [
2670
+ "error",
2671
+ {
2672
+ type: "alphabetical",
2673
+ order: "asc"
2674
+ }
2675
+ ],
2676
+ // Overrides rules
2677
+ ...options.overridesTypesRules
2678
+ }
2679
+ });
2680
+ }
2681
+ if (enableSortConstants) {
2682
+ configs2.push({
2683
+ name: "ntnyq/perfectionist/constants",
2684
+ files: [`**/constants/${GLOB_SRC}`, `**/constants.${GLOB_SRC_EXT}`],
2685
+ plugins: {
2686
+ perfectionist: import_eslint_plugin_perfectionist.default
2687
+ },
2688
+ rules: {
2689
+ "perfectionist/sort-maps": [
2690
+ "error",
2691
+ {
2692
+ type: "alphabetical",
2693
+ order: "asc"
2694
+ }
2695
+ ],
2696
+ "perfectionist/sort-objects": [
2697
+ "error",
2698
+ {
2699
+ type: "alphabetical",
2700
+ order: "asc"
2701
+ }
2702
+ ],
2703
+ "perfectionist/sort-sets": [
2704
+ "error",
2705
+ {
2706
+ type: "alphabetical",
2707
+ order: "asc"
2708
+ }
2709
+ ],
2710
+ "perfectionist/sort-modules": [
2711
+ "error",
2712
+ {
2713
+ type: "alphabetical",
2714
+ order: "asc",
2715
+ partitionByComment: true
2716
+ }
2717
+ ],
2718
+ // Overrides rules
2719
+ ...options.overridesConstantsRules
2720
+ }
2721
+ });
2722
+ }
2723
+ return configs2;
2724
+ };
2542
2725
 
2543
2726
  // src/configs/unusedImports.ts
2544
2727
  var unusedImports = (options = {}) => [
@@ -2798,6 +2981,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
2798
2981
  GLOB_TOML,
2799
2982
  GLOB_TS,
2800
2983
  GLOB_TSX,
2984
+ GLOB_TYPES,
2801
2985
  GLOB_VUE,
2802
2986
  GLOB_YAML,
2803
2987
  antfu,