@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/dist/index.js CHANGED
@@ -72,6 +72,7 @@ var GLOB_JSX = `${GLOB_JS}x`;
72
72
  var GLOB_TS = "**/*.?([cm])ts";
73
73
  var GLOB_TSX = `${GLOB_TS}x`;
74
74
  var GLOB_DTS = "**/*.d.?([cm])ts";
75
+ var GLOB_TYPES = [GLOB_DTS, `**/types/${GLOB_TS}`, `**/types.ts`];
75
76
  var GLOB_TEST = [
76
77
  `**/*.test.${GLOB_SRC_EXT}`,
77
78
  `**/*.spec.${GLOB_SRC_EXT}`,
@@ -254,12 +255,12 @@ var unCategorizedRules = {
254
255
  "vue/no-multiple-objects-in-class": "error",
255
256
  "vue/prefer-separate-static-class": "error",
256
257
  "vue/no-ref-object-reactivity-loss": "error",
257
- "vue/no-duplicate-attr-inheritance": "error",
258
258
  "vue/prefer-prop-type-boolean-first": "error",
259
259
  "vue/html-comment-indent": ["error", 2],
260
260
  "vue/next-tick-style": ["error", "promise"],
261
261
  "vue/v-for-delimiter-style": ["error", "in"],
262
262
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
263
+ "vue/slot-name-casing": ["error", "camelCase"],
263
264
  "vue/custom-event-name-casing": ["error", "camelCase"],
264
265
  "vue/define-props-declaration": ["error", "type-based"],
265
266
  "vue/define-emits-declaration": ["error", "type-literal"],
@@ -274,6 +275,12 @@ var unCategorizedRules = {
274
275
  reset: true
275
276
  }
276
277
  ],
278
+ "vue/no-duplicate-attr-inheritance": [
279
+ "error",
280
+ {
281
+ checkMultiRootNodes: true
282
+ }
283
+ ],
277
284
  "vue/block-order": [
278
285
  "error",
279
286
  {
@@ -557,7 +564,13 @@ var node = (options = {}) => [
557
564
  // src/configs/sort.ts
558
565
  var sort = (options = {}) => {
559
566
  const configs2 = [];
560
- if (options.tsconfig ?? true) {
567
+ const {
568
+ tsconfig: enableSortTsconfig = true,
569
+ packageJson: enableSortPackageJson = true,
570
+ i18nLocale: enableSortI18nLocale = true,
571
+ pnpmWorkspace: enableSortPnpmWorkspace = true
572
+ } = options;
573
+ if (enableSortTsconfig) {
561
574
  configs2.push({
562
575
  name: "ntnyq/sort/tsconfig",
563
576
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
@@ -673,7 +686,7 @@ var sort = (options = {}) => {
673
686
  }
674
687
  });
675
688
  }
676
- if (options.packageJson ?? true) {
689
+ if (enableSortPackageJson) {
677
690
  configs2.push({
678
691
  name: "ntnyq/sort/package-json",
679
692
  files: ["**/package.json"],
@@ -841,7 +854,7 @@ var sort = (options = {}) => {
841
854
  }
842
855
  });
843
856
  }
844
- if (options.i18nLocale ?? true) {
857
+ if (enableSortI18nLocale) {
845
858
  configs2.push(
846
859
  {
847
860
  name: "ntnyq/sort/i18n-locale/json",
@@ -871,7 +884,7 @@ var sort = (options = {}) => {
871
884
  }
872
885
  );
873
886
  }
874
- if (options.pnpmWorkspace ?? true) {
887
+ if (enableSortPnpmWorkspace) {
875
888
  configs2.push({
876
889
  name: "ntnyq/sort/pnpm-workspace",
877
890
  files: ["**/pnpm-workspace.yaml"],
@@ -1297,51 +1310,51 @@ var unocss = (options = {}) => [
1297
1310
 
1298
1311
  // src/constants.ts
1299
1312
  var DEFAULT_PRETTIER_OPTIONS = {
1300
- // Maximum line length
1301
- printWidth: 100,
1302
1313
  // Specify the number of spaces per indentation-level
1303
1314
  tabWidth: 2,
1304
- // Indent lines with tabs instead of spaces
1305
- useTabs: false,
1306
1315
  // Use semicolons or not
1307
1316
  semi: false,
1317
+ // Format only a segment of a file.
1318
+ rangeStart: 0,
1319
+ // Indent lines with tabs instead of spaces
1320
+ useTabs: false,
1321
+ // Maximum line length
1322
+ printWidth: 100,
1323
+ // End of line
1324
+ endOfLine: "lf",
1308
1325
  // Use single quotes instead of double quotes
1309
1326
  singleQuote: true,
1310
- // Change when properties in objects are quoted
1311
- quoteProps: "as-needed",
1327
+ // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1328
+ insertPragma: false,
1312
1329
  // Use single quotes instead of double quotes in JSX
1313
1330
  jsxSingleQuote: true,
1314
1331
  // Print trailing commas wherever possible when multi-line
1315
1332
  trailingComma: "all",
1316
1333
  // Print spaces between brackets in object literals.
1317
1334
  bracketSpacing: true,
1318
- // 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)
1319
- bracketSameLine: false,
1320
1335
  // Include parentheses around a sole arrow function parameter
1321
1336
  arrowParens: "avoid",
1322
- // Format only a segment of a file.
1323
- rangeStart: 0,
1324
- rangeEnd: Number.POSITIVE_INFINITY,
1337
+ // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1338
+ requirePragma: false,
1325
1339
  // Specify which parser to use.
1326
1340
  // parser: undefined,
1327
1341
  // Specify the file name to use to infer which parser to use.
1328
1342
  // filepath: undefined,
1329
- // Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
1330
- requirePragma: false,
1331
- // Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
1332
- insertPragma: false,
1333
1343
  // By default, Prettier will wrap markdown text as-is since some services use a line-break-sensitive renderer, e.g. GitHub comment and Bitbucket.
1334
1344
  proseWrap: "preserve",
1335
- // Specify the global whitespace sensitivity for HTML files
1336
- htmlWhitespaceSensitivity: "css",
1345
+ // 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)
1346
+ bracketSameLine: false,
1347
+ // Change when properties in objects are quoted
1348
+ quoteProps: "as-needed",
1349
+ // Enforce single attribute per line in HTML, Vue and JSX
1350
+ singleAttributePerLine: true,
1337
1351
  // Whether or not to indent the code inside <script> and <style> tags in Vue files
1338
1352
  vueIndentScriptAndStyle: false,
1339
- // End of line
1340
- endOfLine: "lf",
1353
+ // Specify the global whitespace sensitivity for HTML files
1354
+ htmlWhitespaceSensitivity: "css",
1355
+ rangeEnd: Number.POSITIVE_INFINITY,
1341
1356
  // Control whether Prettier formats quoted code embedded in the file
1342
- embeddedLanguageFormatting: "auto",
1343
- // Enforce single attribute per line in HTML, Vue and JSX
1344
- singleAttributePerLine: true
1357
+ embeddedLanguageFormatting: "auto"
1345
1358
  };
1346
1359
 
1347
1360
  // src/utils/env.ts
@@ -1676,6 +1689,27 @@ var specials = (options = {}) => [
1676
1689
  ...options.overridesUserScriptsRules
1677
1690
  }
1678
1691
  },
1692
+ {
1693
+ name: "ntnyq/specials/config-file",
1694
+ files: [`**/*.config*.${GLOB_SRC_EXT}`],
1695
+ plugins: {
1696
+ import: default14,
1697
+ perfectionist: default19
1698
+ },
1699
+ rules: {
1700
+ "no-console": "off",
1701
+ "import/no-default-export": "off",
1702
+ "@typescript-eslint/explicit-function-return-type": "off",
1703
+ "perfectionist/sort-objects": [
1704
+ "error",
1705
+ {
1706
+ type: "line-length",
1707
+ order: "asc"
1708
+ }
1709
+ ],
1710
+ ...options.overridesConfigFileRules
1711
+ }
1712
+ },
1679
1713
  // More special case configs
1680
1714
  // So don't need to append configs to composer
1681
1715
  ...options.specialCaseConfigs ? options.specialCaseConfigs : []
@@ -2285,7 +2319,7 @@ var typescript = (options = {}) => {
2285
2319
  ] : [],
2286
2320
  {
2287
2321
  name: "ntnyq/ts/types",
2288
- files: [GLOB_DTS, "**/types/**/*.ts"],
2322
+ files: [...GLOB_TYPES],
2289
2323
  rules: {
2290
2324
  "no-use-before-define": "off",
2291
2325
  "no-restricted-syntax": "off",
@@ -2314,90 +2348,228 @@ var githubAction = (options = {}) => [
2314
2348
  ];
2315
2349
 
2316
2350
  // src/configs/perfectionist.ts
2317
- var perfectionist = (options = {}) => [
2318
- {
2319
- name: "ntnyq/perfectionist",
2320
- plugins: {
2321
- perfectionist: default19
2322
- },
2323
- rules: {
2324
- "perfectionist/sort-imports": [
2325
- "error",
2326
- {
2327
- groups: [
2328
- // Side effect style imports (e.g. 'normalize.css')
2329
- "side-effect-style",
2330
- // Styles (e.g. *.{css,scss,less})
2331
- "style",
2332
- // Node.js built-in modules. (e.g. fs, path)
2333
- "builtin",
2334
- // External modules installed in the project (e.g. vue, lodash)
2335
- "external",
2336
- // Internal modules (e.g. @/utils, @/components)
2337
- "internal",
2338
- // Modules from parent directory (e.g. ../utils)
2339
- "parent",
2340
- // Modules from the same directory (e.g. ./utils)
2341
- "sibling",
2342
- // Main file from the current directory (e.g. ./index)
2343
- "index",
2344
- // TypeScript object-imports (e.g. import log = console.log)
2345
- "object",
2346
- // Side effect imports (e.g. import 'babel-polyfill')
2347
- "side-effect",
2348
- /**
2349
- * Type import at the end
2350
- */
2351
- "builtin-type",
2352
- "external-type",
2353
- "internal-type",
2354
- "parent-type",
2355
- "sibling-type",
2356
- "index-type",
2357
- "type",
2358
- /**
2359
- * Imports that don’t fit into any other group
2360
- */
2361
- "unknown"
2362
- ],
2363
- order: options.imports?.order || "asc",
2364
- type: options.imports?.type || "natural",
2365
- ignoreCase: true,
2366
- internalPattern: ["^~/.+", "^@/.+", "^#.+"],
2367
- newlinesBetween: "ignore"
2368
- }
2369
- ],
2370
- "perfectionist/sort-exports": [
2371
- "error",
2372
- {
2373
- order: options.exports?.order || "asc",
2374
- type: options.exports?.type || "line-length"
2375
- }
2376
- ],
2377
- "perfectionist/sort-named-exports": [
2378
- "error",
2379
- {
2380
- type: options.namedExports?.type || "alphabetical",
2381
- order: options.namedExports?.order || "asc",
2382
- ignoreCase: true,
2383
- groupKind: "values-first"
2384
- }
2385
- ],
2386
- "perfectionist/sort-named-imports": [
2387
- "error",
2388
- {
2389
- type: options.namedImports?.type || "alphabetical",
2390
- order: options.namedImports?.order || "asc",
2391
- ignoreCase: true,
2392
- ignoreAlias: false,
2393
- groupKind: "values-first"
2394
- }
2395
- ],
2396
- // Overrides rules
2397
- ...options.overrides
2351
+ var perfectionist = (options = {}) => {
2352
+ const {
2353
+ sortEnums: enableSortEnums = true,
2354
+ sortTypes: enableSortTypes = true,
2355
+ sortConstants: enableSortConstants = true
2356
+ } = options;
2357
+ const configs2 = [
2358
+ {
2359
+ name: "ntnyq/perfectionist/common",
2360
+ plugins: {
2361
+ perfectionist: default19
2362
+ },
2363
+ rules: {
2364
+ "perfectionist/sort-imports": [
2365
+ "error",
2366
+ {
2367
+ groups: [
2368
+ // Side effect style imports (e.g. 'normalize.css')
2369
+ "side-effect-style",
2370
+ // Styles (e.g. *.{css,scss,less})
2371
+ "style",
2372
+ // Node.js built-in modules. (e.g. fs, path)
2373
+ "builtin",
2374
+ // External modules installed in the project (e.g. vue, lodash)
2375
+ "external",
2376
+ // Internal modules (e.g. @/utils, @/components)
2377
+ "internal",
2378
+ // Modules from parent directory (e.g. ../utils)
2379
+ "parent",
2380
+ // Modules from the same directory (e.g. ./utils)
2381
+ "sibling",
2382
+ // Main file from the current directory (e.g. ./index)
2383
+ "index",
2384
+ // TypeScript object-imports (e.g. import log = console.log)
2385
+ "object",
2386
+ // Side effect imports (e.g. import 'babel-polyfill')
2387
+ "side-effect",
2388
+ /**
2389
+ * Type import at the end
2390
+ */
2391
+ "builtin-type",
2392
+ "external-type",
2393
+ "internal-type",
2394
+ "parent-type",
2395
+ "sibling-type",
2396
+ "index-type",
2397
+ "type",
2398
+ /**
2399
+ * Imports that don’t fit into any other group
2400
+ */
2401
+ "unknown"
2402
+ ],
2403
+ order: "asc",
2404
+ type: "natural",
2405
+ ignoreCase: true,
2406
+ internalPattern: ["^~/.+", "^@/.+", "^#.+"],
2407
+ newlinesBetween: "ignore"
2408
+ }
2409
+ ],
2410
+ "perfectionist/sort-exports": [
2411
+ "error",
2412
+ {
2413
+ order: "asc",
2414
+ type: "line-length"
2415
+ }
2416
+ ],
2417
+ "perfectionist/sort-named-exports": [
2418
+ "error",
2419
+ {
2420
+ type: "alphabetical",
2421
+ order: "asc",
2422
+ ignoreCase: true,
2423
+ groupKind: "values-first"
2424
+ }
2425
+ ],
2426
+ "perfectionist/sort-named-imports": [
2427
+ "error",
2428
+ {
2429
+ type: "alphabetical",
2430
+ order: "asc",
2431
+ ignoreCase: true,
2432
+ ignoreAlias: false,
2433
+ groupKind: "values-first"
2434
+ }
2435
+ ],
2436
+ // Overrides rules
2437
+ ...options.overrides
2438
+ }
2398
2439
  }
2440
+ ];
2441
+ if (enableSortEnums) {
2442
+ configs2.push({
2443
+ name: "ntnyq/perfectionist/enums",
2444
+ files: [`**/enums/${GLOB_SRC}`, `**/enums.${GLOB_SRC_EXT}`],
2445
+ plugins: {
2446
+ perfectionist: default19
2447
+ },
2448
+ rules: {
2449
+ "perfectionist/sort-enums": [
2450
+ "error",
2451
+ {
2452
+ type: "line-length",
2453
+ order: "asc"
2454
+ }
2455
+ ],
2456
+ "perfectionist/sort-modules": [
2457
+ "error",
2458
+ {
2459
+ type: "line-length",
2460
+ order: "asc"
2461
+ }
2462
+ ],
2463
+ // Overrides rules
2464
+ ...options.overridesEnumsRules
2465
+ }
2466
+ });
2399
2467
  }
2400
- ];
2468
+ if (enableSortTypes) {
2469
+ configs2.push({
2470
+ name: "ntnyq/perfectionist/types",
2471
+ files: [...GLOB_TYPES],
2472
+ plugins: {
2473
+ perfectionist: default19
2474
+ },
2475
+ rules: {
2476
+ "perfectionist/sort-heritage-clauses": [
2477
+ "error",
2478
+ {
2479
+ type: "alphabetical",
2480
+ order: "asc"
2481
+ }
2482
+ ],
2483
+ // 'perfectionist/sort-interfaces': [
2484
+ // 'error',
2485
+ // {
2486
+ // type: 'alphabetical',
2487
+ // order: 'asc',
2488
+ // },
2489
+ // ],
2490
+ "perfectionist/sort-intersection-types": [
2491
+ "error",
2492
+ {
2493
+ type: "alphabetical",
2494
+ order: "asc",
2495
+ groups: [
2496
+ "intersection",
2497
+ "named",
2498
+ "conditional",
2499
+ "function",
2500
+ "import",
2501
+ "keyword",
2502
+ "literal",
2503
+ "object",
2504
+ "operator",
2505
+ "tuple",
2506
+ "union",
2507
+ "nullish"
2508
+ ]
2509
+ }
2510
+ ],
2511
+ "perfectionist/sort-modules": [
2512
+ "error",
2513
+ {
2514
+ type: "line-length",
2515
+ order: "asc"
2516
+ }
2517
+ ],
2518
+ "perfectionist/sort-object-types": [
2519
+ "error",
2520
+ {
2521
+ type: "alphabetical",
2522
+ order: "asc"
2523
+ }
2524
+ ],
2525
+ "perfectionist/sort-union-types": [
2526
+ "error",
2527
+ {
2528
+ type: "line-length",
2529
+ order: "asc"
2530
+ }
2531
+ ],
2532
+ // Overrides rules
2533
+ ...options.overridesTypesRules
2534
+ }
2535
+ });
2536
+ }
2537
+ if (enableSortConstants) {
2538
+ configs2.push({
2539
+ name: "ntnyq/perfectionist/constants",
2540
+ files: [`**/constants/${GLOB_SRC}`, `**/constants.${GLOB_SRC_EXT}`],
2541
+ plugins: {
2542
+ perfectionist: default19
2543
+ },
2544
+ rules: {
2545
+ "perfectionist/sort-maps": [
2546
+ "error",
2547
+ {
2548
+ type: "alphabetical",
2549
+ order: "asc"
2550
+ }
2551
+ ],
2552
+ "perfectionist/sort-objects": [
2553
+ "error",
2554
+ {
2555
+ type: "line-length",
2556
+ order: "asc"
2557
+ }
2558
+ ],
2559
+ "perfectionist/sort-sets": [
2560
+ "error",
2561
+ {
2562
+ type: "line-length",
2563
+ order: "asc"
2564
+ }
2565
+ ],
2566
+ // Overrides rules
2567
+ ...options.overridesConstantsRules
2568
+ }
2569
+ });
2570
+ }
2571
+ return configs2;
2572
+ };
2401
2573
 
2402
2574
  // src/configs/unusedImports.ts
2403
2575
  var unusedImports = (options = {}) => [
@@ -2656,6 +2828,7 @@ export {
2656
2828
  GLOB_TOML,
2657
2829
  GLOB_TS,
2658
2830
  GLOB_TSX,
2831
+ GLOB_TYPES,
2659
2832
  GLOB_VUE,
2660
2833
  GLOB_YAML,
2661
2834
  antfu,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@ntnyq/eslint-config",
3
3
  "type": "module",
4
- "version": "3.6.0",
5
- "packageManager": "pnpm@9.14.2",
4
+ "version": "3.7.0",
5
+ "packageManager": "pnpm@9.14.4",
6
6
  "description": "An opinionated ESLint config preset of ntnyq",
7
7
  "keywords": [
8
8
  "eslint",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
60
- "@eslint/js": "^9.15.0",
60
+ "@eslint/js": "^9.16.0",
61
61
  "@eslint/markdown": "^6.2.1",
62
62
  "@stylistic/eslint-plugin": "^2.11.0",
63
63
  "@unocss/eslint-plugin": "^0.64.1",
@@ -67,20 +67,20 @@
67
67
  "eslint-merge-processors": "^0.1.0",
68
68
  "eslint-plugin-antfu": "^2.7.0",
69
69
  "eslint-plugin-command": "^0.2.6",
70
- "eslint-plugin-format": "^0.1.2",
71
- "eslint-plugin-github-action": "^0.0.4",
70
+ "eslint-plugin-format": "^0.1.3",
71
+ "eslint-plugin-github-action": "^0.0.6",
72
72
  "eslint-plugin-import-x": "^4.4.3",
73
73
  "eslint-plugin-jsdoc": "^50.6.0",
74
74
  "eslint-plugin-jsonc": "^2.18.2",
75
75
  "eslint-plugin-n": "^17.14.0",
76
- "eslint-plugin-ntnyq": "^0.7.0",
76
+ "eslint-plugin-ntnyq": "^0.7.1",
77
77
  "eslint-plugin-perfectionist": "^4.1.2",
78
78
  "eslint-plugin-prettier": "^5.2.1",
79
79
  "eslint-plugin-regexp": "^2.7.0",
80
80
  "eslint-plugin-toml": "^0.11.1",
81
81
  "eslint-plugin-unicorn": "^56.0.1",
82
82
  "eslint-plugin-unused-imports": "^4.1.4",
83
- "eslint-plugin-vue": "^9.31.0",
83
+ "eslint-plugin-vue": "^9.32.0",
84
84
  "eslint-plugin-yml": "^1.15.0",
85
85
  "eslint-processor-vue-blocks": "^0.1.2",
86
86
  "globals": "^15.12.0",
@@ -96,10 +96,10 @@
96
96
  "@ntnyq/prettier-config": "^1.22.0",
97
97
  "@types/node": "^22.10.1",
98
98
  "bumpp": "^9.8.1",
99
- "eslint": "^9.15.0",
99
+ "eslint": "^9.16.0",
100
100
  "eslint-typegen": "^0.3.2",
101
101
  "husky": "^9.1.7",
102
- "jiti": "^2.4.0",
102
+ "jiti": "^2.4.1",
103
103
  "nano-staged": "^0.8.0",
104
104
  "npm-run-all2": "^7.0.1",
105
105
  "rimraf": "^6.0.1",
@@ -107,7 +107,7 @@
107
107
  "tsx": "^4.19.2",
108
108
  "typescript": "^5.7.2",
109
109
  "vitest": "^2.1.6",
110
- "zx": "^8.2.3"
110
+ "zx": "^8.2.4"
111
111
  },
112
112
  "engines": {
113
113
  "node": ">=18.18.0"