@lincy/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
@@ -133,9 +133,9 @@ export default lincy({
133
133
  // 是否启用 stylistic 格式化规则
134
134
  stylistic: true, // 默认值: true, 可选: false | { indent: number | 'tab', quotes: 'single' | 'double', jsx: boolean}
135
135
  // 是否启用 typescript 规则
136
- typescript: true, // 默认值: 检测是否安装typescript依赖, 可选: false
136
+ typescript: true, // 默认值: 检测是否安装typescript依赖, 可选: false | true
137
137
  // 是否启用 vue 规则
138
- vue: true, // 默认值: 检测是否安装vue依赖, 可选: false
138
+ vue: true, // 默认值: 检测是否安装vue依赖, 可选: false | true
139
139
  // 是否启用 jsx 规则
140
140
  jsx: true, // 默认值: true, 可选: false
141
141
  // 是否启用 jsonc 规则
@@ -148,8 +148,6 @@ export default lincy({
148
148
  test: false, // 默认值: true, 可选: false
149
149
  // 是否启用 markdown 规则
150
150
  markdown: false, // 默认值: true, 可选: false
151
- // 是否启用 eslint-plugin-sort-keys 规则
152
- sortKeys: true, // 默认值: false, 可选: true
153
151
  // 覆盖规则
154
152
  overrides: {},
155
153
 
@@ -203,7 +201,9 @@ export default lincy(
203
201
  // 你还可以继续配置多个 ESLint Flat Configs
204
202
  {
205
203
  files: ['**/*.ts'],
206
- rules: {},
204
+ rules: {
205
+ 'perfectionist/sort-objects': 'error',
206
+ },
207
207
  },
208
208
  )
209
209
  ```
@@ -221,7 +221,7 @@ import {
221
221
  jsonc,
222
222
  markdown,
223
223
  node,
224
- sortKeys,
224
+ perfectionist,
225
225
  sortPackageJson,
226
226
  sortTsconfig,
227
227
  stylistic,
@@ -232,20 +232,16 @@ import {
232
232
  } from '@lincy/eslint-config'
233
233
 
234
234
  export default [
235
- ...comments(),
236
235
  ...ignores(),
237
- ...imports(),
238
- ...javascript(),
239
- ...jsdoc(),
236
+ ...javascript(/* Options */),
237
+ ...comments(),
240
238
  ...node(),
241
- ...sortKeys(),
242
- ...sortPackageJson(),
243
- ...sortTsconfig(),
239
+ ...jsdoc(),
240
+ ...imports(),
244
241
  ...unicorn(),
245
-
246
- ...typescript(),
242
+ ...perfectionist(),
243
+ ...typescript(/* Options */),
247
244
  ...stylistic(),
248
-
249
245
  ...vue(),
250
246
  ...jsonc(),
251
247
  ...yaml(),
@@ -296,7 +292,6 @@ export default lincy(
296
292
  jsonc: true,
297
293
  yaml: true,
298
294
  markdown: true,
299
- sortKeys: true,
300
295
  overrides: {}
301
296
  },
302
297
  {
@@ -354,6 +349,24 @@ export default lincy({
354
349
  })
355
350
  ```
356
351
 
352
+ #### `perfectionist` (sorting)
353
+
354
+ 这个插件 [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) 允许你排序对象键名,导入,自动修复等。
355
+
356
+ 安装了插件,但默认情况下没有启用任何规则。
357
+
358
+ 建议使用[configuration comments]单独选择每个文件。(https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1).
359
+
360
+ ```js
361
+ /* eslint perfectionist/sort-objects: "error" */
362
+ const objectWantedToSort = {
363
+ a: 2,
364
+ b: 1,
365
+ c: 3,
366
+ }
367
+ /* eslint perfectionist/sort-objects: "off" */
368
+ ```
369
+
357
370
  ### 类型感知规则
358
371
 
359
372
  您可以选择通过将选项对象传递给“typescript”配置来启用[类型感知规则](https://typescript-eslint.io/linting/typed-linting/):
package/dist/index.cjs CHANGED
@@ -66,6 +66,7 @@ __export(src_exports, {
66
66
  parserTs: () => parserTs,
67
67
  parserVue: () => import_vue_eslint_parser.default,
68
68
  parserYaml: () => import_yaml_eslint_parser.default,
69
+ perfectionist: () => perfectionist,
69
70
  pluginAntfu: () => import_eslint_plugin_antfu.default,
70
71
  pluginComments: () => import_eslint_plugin_eslint_comments.default,
71
72
  pluginImport: () => pluginImport,
@@ -74,15 +75,15 @@ __export(src_exports, {
74
75
  pluginMarkdown: () => import_eslint_plugin_markdown.default,
75
76
  pluginNoOnlyTests: () => import_eslint_plugin_no_only_tests.default,
76
77
  pluginNode: () => import_eslint_plugin_n.default,
77
- pluginSortKeys: () => import_eslint_plugin_sort_keys.default,
78
+ pluginPerfectionist: () => import_eslint_plugin_perfectionist.default,
78
79
  pluginStylistic: () => import_eslint_plugin.default,
79
80
  pluginTs: () => import_eslint_plugin2.default,
80
81
  pluginUnicorn: () => import_eslint_plugin_unicorn.default,
81
82
  pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
83
+ pluginVitest: () => import_eslint_plugin_vitest.default,
82
84
  pluginVue: () => import_eslint_plugin_vue.default,
83
85
  pluginYaml: () => pluginYaml,
84
86
  renameRules: () => renameRules,
85
- sortKeys: () => sortKeys,
86
87
  sortPackageJson: () => sortPackageJson,
87
88
  sortTsconfig: () => sortTsconfig,
88
89
  stylistic: () => stylistic,
@@ -116,7 +117,8 @@ var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-
116
117
  var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
117
118
  var pluginYaml = __toESM(require("eslint-plugin-yml"), 1);
118
119
  var import_eslint_plugin_no_only_tests = __toESM(require("eslint-plugin-no-only-tests"), 1);
119
- var import_eslint_plugin_sort_keys = __toESM(require("eslint-plugin-sort-keys"), 1);
120
+ var import_eslint_plugin_vitest = __toESM(require("eslint-plugin-vitest"), 1);
121
+ var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
120
122
  var parserTs = __toESM(require("@typescript-eslint/parser"), 1);
121
123
  var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
122
124
  var import_yaml_eslint_parser = __toESM(require("yaml-eslint-parser"), 1);
@@ -126,6 +128,7 @@ var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
126
128
  function comments() {
127
129
  return [
128
130
  {
131
+ name: "eslint:comments",
129
132
  plugins: {
130
133
  "eslint-comments": import_eslint_plugin_eslint_comments.default
131
134
  },
@@ -181,7 +184,11 @@ var GLOB_EXCLUDE = [
181
184
  "**/pnpm-lock.yaml",
182
185
  "**/output",
183
186
  "**/coverage",
187
+ "**/tmp",
184
188
  "**/temp",
189
+ "**/.tmp",
190
+ "**/.temp",
191
+ "**/.history",
185
192
  "**/.vitepress/cache",
186
193
  "**/.nuxt",
187
194
  "**/.next",
@@ -220,6 +227,7 @@ function imports(options = {}) {
220
227
  } = options;
221
228
  return [
222
229
  {
230
+ name: "eslint:imports",
223
231
  plugins: {
224
232
  antfu: import_eslint_plugin_antfu.default,
225
233
  import: pluginImport
@@ -273,6 +281,7 @@ function javascript(options = {}) {
273
281
  linterOptions: {
274
282
  reportUnusedDisableDirectives: true
275
283
  },
284
+ name: "eslint:javascript",
276
285
  plugins: {
277
286
  "antfu": import_eslint_plugin_antfu.default,
278
287
  "unused-imports": import_eslint_plugin_unused_imports.default
@@ -281,7 +290,6 @@ function javascript(options = {}) {
281
290
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
282
291
  "antfu/top-level-function": "error",
283
292
  "array-callback-return": "error",
284
- "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
285
293
  "block-scoped-var": "error",
286
294
  "constructor-super": "error",
287
295
  "default-case-last": "error",
@@ -440,6 +448,7 @@ function javascript(options = {}) {
440
448
  memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
441
449
  }
442
450
  ],
451
+ "style/arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
443
452
  "symbol-description": "error",
444
453
  "unicode-bom": ["error", "never"],
445
454
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
@@ -456,6 +465,7 @@ function javascript(options = {}) {
456
465
  },
457
466
  {
458
467
  files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
468
+ name: "eslint:scripts-overrides",
459
469
  rules: {
460
470
  "no-console": "off"
461
471
  }
@@ -470,6 +480,7 @@ function jsdoc(options = {}) {
470
480
  } = options;
471
481
  return [
472
482
  {
483
+ name: "eslint:jsdoc",
473
484
  plugins: {
474
485
  jsdoc: import_eslint_plugin_jsdoc.default
475
486
  },
@@ -501,11 +512,12 @@ function jsdoc(options = {}) {
501
512
  // src/configs/jsonc.ts
502
513
  function jsonc(options = {}) {
503
514
  const {
504
- stylistic: stylistic2 = true,
505
- overrides = {}
515
+ overrides = {},
516
+ stylistic: stylistic2 = true
506
517
  } = options;
507
518
  return [
508
519
  {
520
+ name: "eslint:jsonc:setup",
509
521
  plugins: {
510
522
  jsonc: pluginJsonc
511
523
  }
@@ -515,6 +527,7 @@ function jsonc(options = {}) {
515
527
  languageOptions: {
516
528
  parser: import_jsonc_eslint_parser.default
517
529
  },
530
+ name: "eslint:jsonc:rules",
518
531
  rules: {
519
532
  "jsonc/no-bigint-literals": "error",
520
533
  "jsonc/no-binary-expression": "error",
@@ -568,12 +581,14 @@ function markdown(options = {}) {
568
581
  } = options;
569
582
  return [
570
583
  {
584
+ name: "eslint:markdown:setup",
571
585
  plugins: {
572
586
  markdown: import_eslint_plugin_markdown.default
573
587
  }
574
588
  },
575
589
  {
576
590
  files: [GLOB_MARKDOWN],
591
+ name: "eslint:markdown:processor",
577
592
  processor: "markdown/markdown"
578
593
  },
579
594
  {
@@ -588,13 +603,18 @@ function markdown(options = {}) {
588
603
  }
589
604
  }
590
605
  },
606
+ name: "eslint:markdown:rules",
591
607
  rules: {
592
- "antfu/no-cjs-exports": "off",
593
608
  "antfu/no-ts-export-equal": "off",
609
+ "import/newline-after-import": "off",
594
610
  "no-alert": "off",
595
611
  "no-console": "off",
612
+ "no-labels": "off",
613
+ "no-lone-blocks": "off",
614
+ "no-restricted-syntax": "off",
596
615
  "no-undef": "off",
597
616
  "no-unused-expressions": "off",
617
+ "no-unused-labels": "off",
598
618
  "no-unused-vars": "off",
599
619
  "node/prefer-global/process": "off",
600
620
  "style/comma-dangle": "off",
@@ -638,6 +658,7 @@ function markdown(options = {}) {
638
658
  function node() {
639
659
  return [
640
660
  {
661
+ name: "eslint:node",
641
662
  plugins: {
642
663
  node: import_eslint_plugin_n.default
643
664
  },
@@ -660,6 +681,7 @@ function sortPackageJson() {
660
681
  return [
661
682
  {
662
683
  files: ["**/package.json"],
684
+ name: "eslint:sort-package-json",
663
685
  rules: {
664
686
  "jsonc/sort-array-values": [
665
687
  "error",
@@ -748,6 +770,7 @@ function sortTsconfig() {
748
770
  return [
749
771
  {
750
772
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
773
+ name: "eslint:sort-tsconfig",
751
774
  rules: {
752
775
  "jsonc/sort-keys": [
753
776
  "error",
@@ -877,11 +900,12 @@ function stylistic(options = {}) {
877
900
  } = options;
878
901
  const {
879
902
  indent = 4,
880
- quotes = "single",
881
- jsx = true
903
+ jsx = true,
904
+ quotes = "single"
882
905
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
883
906
  return [
884
907
  {
908
+ name: "eslint:stylistic",
885
909
  plugins: {
886
910
  antfu: import_eslint_plugin_antfu.default,
887
911
  style: import_eslint_plugin.default
@@ -889,6 +913,7 @@ function stylistic(options = {}) {
889
913
  rules: {
890
914
  "antfu/consistent-list-newline": "off",
891
915
  "antfu/if-newline": "error",
916
+ "antfu/indent-binary-ops": ["error", { indent }],
892
917
  "antfu/top-level-function": "error",
893
918
  "curly": ["error", "multi-or-nest", "consistent"],
894
919
  "style/array-bracket-spacing": ["error", "never"],
@@ -904,14 +929,9 @@ function stylistic(options = {}) {
904
929
  "style/indent": ["error", indent, {
905
930
  ArrayExpression: 1,
906
931
  CallExpression: { arguments: 1 },
932
+ flatTernaryExpressions: false,
907
933
  FunctionDeclaration: { body: 1, parameters: 1 },
908
934
  FunctionExpression: { body: 1, parameters: 1 },
909
- ImportDeclaration: 1,
910
- MemberExpression: 1,
911
- ObjectExpression: 1,
912
- SwitchCase: 1,
913
- VariableDeclarator: 1,
914
- flatTernaryExpressions: false,
915
935
  ignoreComments: false,
916
936
  ignoredNodes: [
917
937
  "TemplateLiteral *",
@@ -936,8 +956,13 @@ function stylistic(options = {}) {
936
956
  "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
937
957
  "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
938
958
  ],
959
+ ImportDeclaration: 1,
960
+ MemberExpression: 1,
961
+ ObjectExpression: 1,
939
962
  offsetTernaryExpressions: true,
940
- outerIIFEBody: 1
963
+ outerIIFEBody: 1,
964
+ SwitchCase: 1,
965
+ VariableDeclarator: 1
941
966
  }],
942
967
  "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
943
968
  "style/keyword-spacing": ["error", { after: true, before: true }],
@@ -1033,7 +1058,7 @@ var import_node_process = __toESM(require("process"), 1);
1033
1058
 
1034
1059
  // src/utils.ts
1035
1060
  function combine(...configs) {
1036
- return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
1061
+ return configs.flat();
1037
1062
  }
1038
1063
  function renameRules(rules, from, to) {
1039
1064
  return Object.fromEntries(
@@ -1080,6 +1105,7 @@ function typescript(options) {
1080
1105
  return [
1081
1106
  {
1082
1107
  // Install the plugins without globs, so they can be configured separately.
1108
+ name: "eslint:typescript:setup",
1083
1109
  plugins: {
1084
1110
  antfu: import_eslint_plugin_antfu.default,
1085
1111
  import: pluginImport,
@@ -1103,6 +1129,7 @@ function typescript(options) {
1103
1129
  ...parserOptions
1104
1130
  }
1105
1131
  },
1132
+ name: "eslint:typescript:rules",
1106
1133
  rules: {
1107
1134
  ...renameRules(
1108
1135
  import_eslint_plugin2.default.configs["eslint-recommended"].overrides[0].rules,
@@ -1116,9 +1143,6 @@ function typescript(options) {
1116
1143
  ),
1117
1144
  "antfu/generic-spacing": "error",
1118
1145
  "antfu/named-tuple-spacing": "error",
1119
- "antfu/no-cjs-exports": "error",
1120
- "antfu/no-const-enum": "error",
1121
- "antfu/no-ts-export-equal": "error",
1122
1146
  "no-dupe-class-members": "off",
1123
1147
  "no-invalid-this": "off",
1124
1148
  "no-loss-of-precision": "off",
@@ -1152,6 +1176,7 @@ function typescript(options) {
1152
1176
  },
1153
1177
  {
1154
1178
  files: ["**/*.d.ts"],
1179
+ name: "eslint:typescript:dts-overrides",
1155
1180
  rules: {
1156
1181
  "eslint-comments/no-unlimited-disable": "off",
1157
1182
  "import/no-duplicates": "off",
@@ -1161,12 +1186,14 @@ function typescript(options) {
1161
1186
  },
1162
1187
  {
1163
1188
  files: ["**/*.{test,spec}.ts?(x)"],
1189
+ name: "eslint:typescript:tests-overrides",
1164
1190
  rules: {
1165
1191
  "no-unused-expressions": "off"
1166
1192
  }
1167
1193
  },
1168
1194
  {
1169
1195
  files: ["**/*.js", "**/*.cjs"],
1196
+ name: "eslint:typescript:javascript-overrides",
1170
1197
  rules: {
1171
1198
  "ts/no-require-imports": "off",
1172
1199
  "ts/no-var-requires": "off"
@@ -1179,6 +1206,7 @@ function typescript(options) {
1179
1206
  function unicorn() {
1180
1207
  return [
1181
1208
  {
1209
+ name: "eslint:unicorn",
1182
1210
  plugins: {
1183
1211
  unicorn: import_eslint_plugin_unicorn.default
1184
1212
  },
@@ -1232,6 +1260,7 @@ function vue(options = {}) {
1232
1260
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1233
1261
  return [
1234
1262
  {
1263
+ name: "eslint:vue:setup",
1235
1264
  plugins: {
1236
1265
  vue: import_eslint_plugin_vue.default
1237
1266
  }
@@ -1249,6 +1278,7 @@ function vue(options = {}) {
1249
1278
  sourceType: "module"
1250
1279
  }
1251
1280
  },
1281
+ name: "eslint:vue:rules",
1252
1282
  processor: import_eslint_plugin_vue.default.processors[".vue"],
1253
1283
  rules: {
1254
1284
  ...import_eslint_plugin_vue.default.configs.base.rules,
@@ -1360,6 +1390,7 @@ function yaml(options = {}) {
1360
1390
  } = options;
1361
1391
  return [
1362
1392
  {
1393
+ name: "eslint:yaml:setup",
1363
1394
  plugins: {
1364
1395
  yaml: pluginYaml
1365
1396
  }
@@ -1369,6 +1400,7 @@ function yaml(options = {}) {
1369
1400
  languageOptions: {
1370
1401
  parser: import_yaml_eslint_parser.default
1371
1402
  },
1403
+ name: "eslint:yaml:rules",
1372
1404
  rules: {
1373
1405
  "style/spaced-comment": "off",
1374
1406
  "yaml/block-mapping": "error",
@@ -1405,26 +1437,41 @@ function test(options = {}) {
1405
1437
  } = options;
1406
1438
  return [
1407
1439
  {
1440
+ name: "eslint:test:setup",
1408
1441
  plugins: {
1409
- "no-only-tests": import_eslint_plugin_no_only_tests.default
1442
+ test: {
1443
+ ...import_eslint_plugin_vitest.default,
1444
+ rules: {
1445
+ ...import_eslint_plugin_vitest.default.rules,
1446
+ // extend `test/no-only-tests` rule
1447
+ ...import_eslint_plugin_no_only_tests.default.rules
1448
+ }
1449
+ }
1410
1450
  }
1411
1451
  },
1412
1452
  {
1413
1453
  files: GLOB_TESTS,
1454
+ name: "eslint:test:rules",
1414
1455
  rules: {
1415
- "no-only-tests/no-only-tests": isInEditor ? "off" : "error",
1456
+ "node/prefer-global/process": "off",
1457
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1458
+ "test/no-identical-title": "error",
1459
+ "test/no-only-tests": isInEditor ? "off" : "error",
1460
+ "test/prefer-hooks-in-order": "error",
1461
+ "test/prefer-lowercase-title": "error",
1416
1462
  ...overrides
1417
1463
  }
1418
1464
  }
1419
1465
  ];
1420
1466
  }
1421
1467
 
1422
- // src/configs/sort-keys.ts
1423
- function sortKeys() {
1468
+ // src/configs/perfectionist.ts
1469
+ function perfectionist() {
1424
1470
  return [
1425
1471
  {
1472
+ name: "eslint:perfectionist",
1426
1473
  plugins: {
1427
- "sort-keys": import_eslint_plugin_sort_keys.default
1474
+ perfectionist: import_eslint_plugin_perfectionist.default
1428
1475
  }
1429
1476
  }
1430
1477
  ];
@@ -1449,13 +1496,12 @@ var VuePackages = [
1449
1496
  ];
1450
1497
  function lincy(options = {}, ...userConfigs) {
1451
1498
  const {
1452
- isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.JETBRAINS_IDE) && !import_node_process2.default.env.CI),
1453
- vue: enableVue = VuePackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
1454
- typescript: enableTypeScript = (0, import_local_pkg2.isPackageExists)("typescript"),
1499
+ componentExts = [],
1455
1500
  gitignore: enableGitignore = true,
1456
- sortKeys: enableSortKeys = false,
1501
+ isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.JETBRAINS_IDE) && !import_node_process2.default.env.CI),
1457
1502
  overrides = {},
1458
- componentExts = []
1503
+ typescript: enableTypeScript = (0, import_local_pkg2.isPackageExists)("typescript"),
1504
+ vue: enableVue = VuePackages.some((i) => (0, import_local_pkg2.isPackageExists)(i))
1459
1505
  } = options;
1460
1506
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1461
1507
  if (stylisticOptions && !("jsx" in stylisticOptions))
@@ -1485,10 +1531,10 @@ function lincy(options = {}, ...userConfigs) {
1485
1531
  imports({
1486
1532
  stylistic: stylisticOptions
1487
1533
  }),
1488
- unicorn()
1534
+ unicorn(),
1535
+ // Optional plugins (installed but not enabled by default)
1536
+ perfectionist()
1489
1537
  );
1490
- if (enableSortKeys)
1491
- configs.push(sortKeys());
1492
1538
  if (enableVue)
1493
1539
  componentExts.push("vue");
1494
1540
  if (enableTypeScript) {
@@ -1592,6 +1638,7 @@ var src_default = lincy;
1592
1638
  parserTs,
1593
1639
  parserVue,
1594
1640
  parserYaml,
1641
+ perfectionist,
1595
1642
  pluginAntfu,
1596
1643
  pluginComments,
1597
1644
  pluginImport,
@@ -1600,15 +1647,15 @@ var src_default = lincy;
1600
1647
  pluginMarkdown,
1601
1648
  pluginNoOnlyTests,
1602
1649
  pluginNode,
1603
- pluginSortKeys,
1650
+ pluginPerfectionist,
1604
1651
  pluginStylistic,
1605
1652
  pluginTs,
1606
1653
  pluginUnicorn,
1607
1654
  pluginUnusedImports,
1655
+ pluginVitest,
1608
1656
  pluginVue,
1609
1657
  pluginYaml,
1610
1658
  renameRules,
1611
- sortKeys,
1612
1659
  sortPackageJson,
1613
1660
  sortTsconfig,
1614
1661
  stylistic,
package/dist/index.d.cts CHANGED
@@ -2,9 +2,14 @@ import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
2
2
  import { ParserOptions } from '@typescript-eslint/parser';
3
3
  import * as parser from '@typescript-eslint/parser';
4
4
  export { parser as parserTs };
5
- import { MergeIntersection, EslintRules, Unprefix, ReactRules, TypeScriptRules, RenamePrefix, VitestRules, YmlRules, NRules, Prefix, ImportRules, JsoncRules, VueRules, UnicornRules, EslintCommentsRules, RuleConfig, FlatESLintConfigItem } from '@antfu/eslint-define-config';
5
+ import { RuleConfig, MergeIntersection, RenamePrefix, VitestRules, YmlRules, NRules, Prefix, ImportRules, EslintRules, JsoncRules, VueRules, EslintCommentsRules, FlatESLintConfigItem } from '@antfu/eslint-define-config';
6
+ import { RuleOptions as RuleOptions$1 } from '@eslint-types/jsdoc/types';
7
+ import { RuleOptions } from '@eslint-types/typescript-eslint/types';
8
+ import { RuleOptions as RuleOptions$2 } from '@eslint-types/unicorn/types';
6
9
  import { Rules as Rules$1 } from 'eslint-plugin-antfu';
7
10
  export { default as pluginAntfu } from 'eslint-plugin-antfu';
11
+ import { UnprefixedRuleOptions } from '@stylistic/eslint-plugin';
12
+ export { default as pluginStylistic } from '@stylistic/eslint-plugin';
8
13
  export { default as pluginComments } from 'eslint-plugin-eslint-comments';
9
14
  import * as eslintPluginI from 'eslint-plugin-i';
10
15
  export { eslintPluginI as pluginImport };
@@ -13,7 +18,6 @@ import * as eslintPluginJsonc from 'eslint-plugin-jsonc';
13
18
  export { eslintPluginJsonc as pluginJsonc };
14
19
  export { default as pluginMarkdown } from 'eslint-plugin-markdown';
15
20
  export { default as pluginNode } from 'eslint-plugin-n';
16
- export { default as pluginStylistic } from '@stylistic/eslint-plugin';
17
21
  export { default as pluginTs } from '@typescript-eslint/eslint-plugin';
18
22
  export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
19
23
  export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
@@ -21,17 +25,20 @@ export { default as pluginVue } from 'eslint-plugin-vue';
21
25
  import * as eslintPluginYml from 'eslint-plugin-yml';
22
26
  export { eslintPluginYml as pluginYaml };
23
27
  export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
24
- export { default as pluginSortKeys } from 'eslint-plugin-sort-keys';
28
+ export { default as pluginVitest } from 'eslint-plugin-vitest';
29
+ export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
25
30
  export { default as parserVue } from 'vue-eslint-parser';
26
31
  export { default as parserYaml } from 'yaml-eslint-parser';
27
32
  export { default as parserJsonc } from 'jsonc-eslint-parser';
28
33
 
29
- type MergedRules = MergeIntersection<EslintRules & Unprefix<ReactRules, 'react/'> & Unprefix<TypeScriptRules, '@typescript-eslint/'>>;
30
- type StylisticRules = Pick<MergedRules, 'array-bracket-newline' | 'array-bracket-spacing' | 'array-element-newline' | 'arrow-spacing' | 'block-spacing' | 'brace-style' | 'comma-dangle' | 'comma-spacing' | 'comma-style' | 'computed-property-spacing' | 'dot-location' | 'eol-last' | 'func-call-spacing' | 'function-call-argument-newline' | 'function-paren-newline' | 'generator-star-spacing' | 'implicit-arrow-linebreak' | 'indent' | 'jsx-quotes' | 'key-spacing' | 'keyword-spacing' | 'linebreak-style' | 'lines-around-comment' | 'lines-around-directive' | 'lines-between-class-members' | 'max-len' | 'max-statements-per-line' | 'multiline-ternary' | 'new-parens' | 'newline-after-var' | 'newline-before-return' | 'newline-per-chained-call' | 'no-confusing-arrow' | 'no-extra-parens' | 'no-extra-semi' | 'no-floating-decimal' | 'no-mixed-operators' | 'no-mixed-spaces-and-tabs' | 'no-multi-spaces' | 'no-multiple-empty-lines' | 'no-spaced-func' | 'no-tabs' | 'no-trailing-spaces' | 'no-whitespace-before-property' | 'nonblock-statement-body-position' | 'object-curly-newline' | 'object-curly-spacing' | 'object-property-newline' | 'one-var-declaration-per-line' | 'operator-linebreak' | 'padded-blocks' | 'padding-line-between-statements' | 'quote-props' | 'quotes' | 'rest-spread-spacing' | 'semi' | 'semi-spacing' | 'semi-style' | 'space-before-blocks' | 'space-before-function-paren' | 'space-in-parens' | 'space-infix-ops' | 'space-unary-ops' | 'spaced-comment' | 'switch-colon-spacing' | 'template-curly-spacing' | 'template-tag-spacing' | 'wrap-iife' | 'wrap-regex' | 'yield-star-spacing' | 'block-spacing' | 'brace-style' | 'comma-dangle' | 'comma-spacing' | 'func-call-spacing' | 'indent' | 'key-spacing' | 'keyword-spacing' | 'lines-around-comment' | 'lines-between-class-members' | 'member-delimiter-style' | 'object-curly-spacing' | 'padding-line-between-statements' | 'quotes' | 'semi' | 'space-before-blocks' | 'space-before-function-paren' | 'space-infix-ops' | 'type-annotation-spacing'>;
31
-
32
- type Rules = MergeIntersection<RenamePrefix<TypeScriptRules, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<YmlRules, 'yml/', 'yaml/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<StylisticRules, 'style/'> & Prefix<Rules$1, 'antfu/'> & ImportRules & EslintRules & JsoncRules & VueRules & UnicornRules & EslintCommentsRules & {
34
+ type WrapRuleConfig<T extends {
35
+ [key: string]: any;
36
+ }> = {
37
+ [K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
38
+ };
39
+ type Rules = WrapRuleConfig<MergeIntersection<RenamePrefix<RuleOptions, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<YmlRules, 'yml/', 'yaml/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<UnprefixedRuleOptions, 'style/'> & Prefix<Rules$1, 'antfu/'> & RuleOptions$1 & ImportRules & EslintRules & JsoncRules & VueRules & RuleOptions$2 & EslintCommentsRules & {
33
40
  'test/no-only-tests': RuleConfig<[]>;
34
- }>;
41
+ }>>;
35
42
  type ConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
36
43
  /**
37
44
  * Custom name of each config item
@@ -145,12 +152,6 @@ interface OptionsConfig extends OptionsComponentExts {
145
152
  * @default true
146
153
  */
147
154
  markdown?: boolean;
148
- /**
149
- * Enable SortKeys support.
150
- *
151
- * @default false
152
- */
153
- sortKeys?: boolean;
154
155
  /**
155
156
  * Enable stylistic rules.
156
157
  *
@@ -225,11 +226,11 @@ declare function yaml(options?: OptionsOverrides & OptionsStylistic): ConfigItem
225
226
  declare function test(options?: OptionsIsInEditor & OptionsOverrides): ConfigItem[];
226
227
 
227
228
  /**
228
- * Optional sort-keys plugin
229
+ * Optional perfectionist plugin for props and items sorting.
229
230
  *
230
- * @see https://github.com/namnm/eslint-plugin-sort-keys
231
+ * @see https://github.com/azat-io/eslint-plugin-perfectionist
231
232
  */
232
- declare function sortKeys(): ConfigItem[];
233
+ declare function perfectionist(): ConfigItem[];
233
234
 
234
235
  /**
235
236
  * Combine array and non-array configs into a single array.
@@ -262,4 +263,4 @@ declare const GLOB_TESTS: string[];
262
263
  declare const GLOB_ALL_SRC: string[];
263
264
  declare const GLOB_EXCLUDE: string[];
264
265
 
265
- export { ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIgnores, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, Rules, StylisticConfig, StylisticOverridesConfig, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, renameRules, sortKeys, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, vue, yaml };
266
+ export { ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIgnores, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, Rules, StylisticConfig, StylisticOverridesConfig, WrapRuleConfig, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, perfectionist, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, vue, yaml };
package/dist/index.d.ts CHANGED
@@ -2,9 +2,14 @@ import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
2
2
  import { ParserOptions } from '@typescript-eslint/parser';
3
3
  import * as parser from '@typescript-eslint/parser';
4
4
  export { parser as parserTs };
5
- import { MergeIntersection, EslintRules, Unprefix, ReactRules, TypeScriptRules, RenamePrefix, VitestRules, YmlRules, NRules, Prefix, ImportRules, JsoncRules, VueRules, UnicornRules, EslintCommentsRules, RuleConfig, FlatESLintConfigItem } from '@antfu/eslint-define-config';
5
+ import { RuleConfig, MergeIntersection, RenamePrefix, VitestRules, YmlRules, NRules, Prefix, ImportRules, EslintRules, JsoncRules, VueRules, EslintCommentsRules, FlatESLintConfigItem } from '@antfu/eslint-define-config';
6
+ import { RuleOptions as RuleOptions$1 } from '@eslint-types/jsdoc/types';
7
+ import { RuleOptions } from '@eslint-types/typescript-eslint/types';
8
+ import { RuleOptions as RuleOptions$2 } from '@eslint-types/unicorn/types';
6
9
  import { Rules as Rules$1 } from 'eslint-plugin-antfu';
7
10
  export { default as pluginAntfu } from 'eslint-plugin-antfu';
11
+ import { UnprefixedRuleOptions } from '@stylistic/eslint-plugin';
12
+ export { default as pluginStylistic } from '@stylistic/eslint-plugin';
8
13
  export { default as pluginComments } from 'eslint-plugin-eslint-comments';
9
14
  import * as eslintPluginI from 'eslint-plugin-i';
10
15
  export { eslintPluginI as pluginImport };
@@ -13,7 +18,6 @@ import * as eslintPluginJsonc from 'eslint-plugin-jsonc';
13
18
  export { eslintPluginJsonc as pluginJsonc };
14
19
  export { default as pluginMarkdown } from 'eslint-plugin-markdown';
15
20
  export { default as pluginNode } from 'eslint-plugin-n';
16
- export { default as pluginStylistic } from '@stylistic/eslint-plugin';
17
21
  export { default as pluginTs } from '@typescript-eslint/eslint-plugin';
18
22
  export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
19
23
  export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
@@ -21,17 +25,20 @@ export { default as pluginVue } from 'eslint-plugin-vue';
21
25
  import * as eslintPluginYml from 'eslint-plugin-yml';
22
26
  export { eslintPluginYml as pluginYaml };
23
27
  export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
24
- export { default as pluginSortKeys } from 'eslint-plugin-sort-keys';
28
+ export { default as pluginVitest } from 'eslint-plugin-vitest';
29
+ export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
25
30
  export { default as parserVue } from 'vue-eslint-parser';
26
31
  export { default as parserYaml } from 'yaml-eslint-parser';
27
32
  export { default as parserJsonc } from 'jsonc-eslint-parser';
28
33
 
29
- type MergedRules = MergeIntersection<EslintRules & Unprefix<ReactRules, 'react/'> & Unprefix<TypeScriptRules, '@typescript-eslint/'>>;
30
- type StylisticRules = Pick<MergedRules, 'array-bracket-newline' | 'array-bracket-spacing' | 'array-element-newline' | 'arrow-spacing' | 'block-spacing' | 'brace-style' | 'comma-dangle' | 'comma-spacing' | 'comma-style' | 'computed-property-spacing' | 'dot-location' | 'eol-last' | 'func-call-spacing' | 'function-call-argument-newline' | 'function-paren-newline' | 'generator-star-spacing' | 'implicit-arrow-linebreak' | 'indent' | 'jsx-quotes' | 'key-spacing' | 'keyword-spacing' | 'linebreak-style' | 'lines-around-comment' | 'lines-around-directive' | 'lines-between-class-members' | 'max-len' | 'max-statements-per-line' | 'multiline-ternary' | 'new-parens' | 'newline-after-var' | 'newline-before-return' | 'newline-per-chained-call' | 'no-confusing-arrow' | 'no-extra-parens' | 'no-extra-semi' | 'no-floating-decimal' | 'no-mixed-operators' | 'no-mixed-spaces-and-tabs' | 'no-multi-spaces' | 'no-multiple-empty-lines' | 'no-spaced-func' | 'no-tabs' | 'no-trailing-spaces' | 'no-whitespace-before-property' | 'nonblock-statement-body-position' | 'object-curly-newline' | 'object-curly-spacing' | 'object-property-newline' | 'one-var-declaration-per-line' | 'operator-linebreak' | 'padded-blocks' | 'padding-line-between-statements' | 'quote-props' | 'quotes' | 'rest-spread-spacing' | 'semi' | 'semi-spacing' | 'semi-style' | 'space-before-blocks' | 'space-before-function-paren' | 'space-in-parens' | 'space-infix-ops' | 'space-unary-ops' | 'spaced-comment' | 'switch-colon-spacing' | 'template-curly-spacing' | 'template-tag-spacing' | 'wrap-iife' | 'wrap-regex' | 'yield-star-spacing' | 'block-spacing' | 'brace-style' | 'comma-dangle' | 'comma-spacing' | 'func-call-spacing' | 'indent' | 'key-spacing' | 'keyword-spacing' | 'lines-around-comment' | 'lines-between-class-members' | 'member-delimiter-style' | 'object-curly-spacing' | 'padding-line-between-statements' | 'quotes' | 'semi' | 'space-before-blocks' | 'space-before-function-paren' | 'space-infix-ops' | 'type-annotation-spacing'>;
31
-
32
- type Rules = MergeIntersection<RenamePrefix<TypeScriptRules, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<YmlRules, 'yml/', 'yaml/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<StylisticRules, 'style/'> & Prefix<Rules$1, 'antfu/'> & ImportRules & EslintRules & JsoncRules & VueRules & UnicornRules & EslintCommentsRules & {
34
+ type WrapRuleConfig<T extends {
35
+ [key: string]: any;
36
+ }> = {
37
+ [K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
38
+ };
39
+ type Rules = WrapRuleConfig<MergeIntersection<RenamePrefix<RuleOptions, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<YmlRules, 'yml/', 'yaml/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<UnprefixedRuleOptions, 'style/'> & Prefix<Rules$1, 'antfu/'> & RuleOptions$1 & ImportRules & EslintRules & JsoncRules & VueRules & RuleOptions$2 & EslintCommentsRules & {
33
40
  'test/no-only-tests': RuleConfig<[]>;
34
- }>;
41
+ }>>;
35
42
  type ConfigItem = Omit<FlatESLintConfigItem<Rules, false>, 'plugins'> & {
36
43
  /**
37
44
  * Custom name of each config item
@@ -145,12 +152,6 @@ interface OptionsConfig extends OptionsComponentExts {
145
152
  * @default true
146
153
  */
147
154
  markdown?: boolean;
148
- /**
149
- * Enable SortKeys support.
150
- *
151
- * @default false
152
- */
153
- sortKeys?: boolean;
154
155
  /**
155
156
  * Enable stylistic rules.
156
157
  *
@@ -225,11 +226,11 @@ declare function yaml(options?: OptionsOverrides & OptionsStylistic): ConfigItem
225
226
  declare function test(options?: OptionsIsInEditor & OptionsOverrides): ConfigItem[];
226
227
 
227
228
  /**
228
- * Optional sort-keys plugin
229
+ * Optional perfectionist plugin for props and items sorting.
229
230
  *
230
- * @see https://github.com/namnm/eslint-plugin-sort-keys
231
+ * @see https://github.com/azat-io/eslint-plugin-perfectionist
231
232
  */
232
- declare function sortKeys(): ConfigItem[];
233
+ declare function perfectionist(): ConfigItem[];
233
234
 
234
235
  /**
235
236
  * Combine array and non-array configs into a single array.
@@ -262,4 +263,4 @@ declare const GLOB_TESTS: string[];
262
263
  declare const GLOB_ALL_SRC: string[];
263
264
  declare const GLOB_EXCLUDE: string[];
264
265
 
265
- export { ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIgnores, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, Rules, StylisticConfig, StylisticOverridesConfig, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, renameRules, sortKeys, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, vue, yaml };
266
+ export { ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIgnores, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, Rules, StylisticConfig, StylisticOverridesConfig, WrapRuleConfig, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, perfectionist, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, vue, yaml };
package/dist/index.js CHANGED
@@ -19,16 +19,18 @@ import { default as default10 } from "eslint-plugin-unused-imports";
19
19
  import { default as default11 } from "eslint-plugin-vue";
20
20
  import * as pluginYaml from "eslint-plugin-yml";
21
21
  import { default as default12 } from "eslint-plugin-no-only-tests";
22
- import { default as default13 } from "eslint-plugin-sort-keys";
22
+ import { default as default13 } from "eslint-plugin-vitest";
23
+ import { default as default14 } from "eslint-plugin-perfectionist";
23
24
  import * as parserTs from "@typescript-eslint/parser";
24
- import { default as default14 } from "vue-eslint-parser";
25
- import { default as default15 } from "yaml-eslint-parser";
26
- import { default as default16 } from "jsonc-eslint-parser";
25
+ import { default as default15 } from "vue-eslint-parser";
26
+ import { default as default16 } from "yaml-eslint-parser";
27
+ import { default as default17 } from "jsonc-eslint-parser";
27
28
 
28
29
  // src/configs/comments.ts
29
30
  function comments() {
30
31
  return [
31
32
  {
33
+ name: "eslint:comments",
32
34
  plugins: {
33
35
  "eslint-comments": default3
34
36
  },
@@ -84,7 +86,11 @@ var GLOB_EXCLUDE = [
84
86
  "**/pnpm-lock.yaml",
85
87
  "**/output",
86
88
  "**/coverage",
89
+ "**/tmp",
87
90
  "**/temp",
91
+ "**/.tmp",
92
+ "**/.temp",
93
+ "**/.history",
88
94
  "**/.vitepress/cache",
89
95
  "**/.nuxt",
90
96
  "**/.next",
@@ -123,6 +129,7 @@ function imports(options = {}) {
123
129
  } = options;
124
130
  return [
125
131
  {
132
+ name: "eslint:imports",
126
133
  plugins: {
127
134
  antfu: default2,
128
135
  import: pluginImport
@@ -176,6 +183,7 @@ function javascript(options = {}) {
176
183
  linterOptions: {
177
184
  reportUnusedDisableDirectives: true
178
185
  },
186
+ name: "eslint:javascript",
179
187
  plugins: {
180
188
  "antfu": default2,
181
189
  "unused-imports": default10
@@ -184,7 +192,6 @@ function javascript(options = {}) {
184
192
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
185
193
  "antfu/top-level-function": "error",
186
194
  "array-callback-return": "error",
187
- "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
188
195
  "block-scoped-var": "error",
189
196
  "constructor-super": "error",
190
197
  "default-case-last": "error",
@@ -343,6 +350,7 @@ function javascript(options = {}) {
343
350
  memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
344
351
  }
345
352
  ],
353
+ "style/arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
346
354
  "symbol-description": "error",
347
355
  "unicode-bom": ["error", "never"],
348
356
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
@@ -359,6 +367,7 @@ function javascript(options = {}) {
359
367
  },
360
368
  {
361
369
  files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
370
+ name: "eslint:scripts-overrides",
362
371
  rules: {
363
372
  "no-console": "off"
364
373
  }
@@ -373,6 +382,7 @@ function jsdoc(options = {}) {
373
382
  } = options;
374
383
  return [
375
384
  {
385
+ name: "eslint:jsdoc",
376
386
  plugins: {
377
387
  jsdoc: default4
378
388
  },
@@ -404,11 +414,12 @@ function jsdoc(options = {}) {
404
414
  // src/configs/jsonc.ts
405
415
  function jsonc(options = {}) {
406
416
  const {
407
- stylistic: stylistic2 = true,
408
- overrides = {}
417
+ overrides = {},
418
+ stylistic: stylistic2 = true
409
419
  } = options;
410
420
  return [
411
421
  {
422
+ name: "eslint:jsonc:setup",
412
423
  plugins: {
413
424
  jsonc: pluginJsonc
414
425
  }
@@ -416,8 +427,9 @@ function jsonc(options = {}) {
416
427
  {
417
428
  files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
418
429
  languageOptions: {
419
- parser: default16
430
+ parser: default17
420
431
  },
432
+ name: "eslint:jsonc:rules",
421
433
  rules: {
422
434
  "jsonc/no-bigint-literals": "error",
423
435
  "jsonc/no-binary-expression": "error",
@@ -471,12 +483,14 @@ function markdown(options = {}) {
471
483
  } = options;
472
484
  return [
473
485
  {
486
+ name: "eslint:markdown:setup",
474
487
  plugins: {
475
488
  markdown: default5
476
489
  }
477
490
  },
478
491
  {
479
492
  files: [GLOB_MARKDOWN],
493
+ name: "eslint:markdown:processor",
480
494
  processor: "markdown/markdown"
481
495
  },
482
496
  {
@@ -491,13 +505,18 @@ function markdown(options = {}) {
491
505
  }
492
506
  }
493
507
  },
508
+ name: "eslint:markdown:rules",
494
509
  rules: {
495
- "antfu/no-cjs-exports": "off",
496
510
  "antfu/no-ts-export-equal": "off",
511
+ "import/newline-after-import": "off",
497
512
  "no-alert": "off",
498
513
  "no-console": "off",
514
+ "no-labels": "off",
515
+ "no-lone-blocks": "off",
516
+ "no-restricted-syntax": "off",
499
517
  "no-undef": "off",
500
518
  "no-unused-expressions": "off",
519
+ "no-unused-labels": "off",
501
520
  "no-unused-vars": "off",
502
521
  "node/prefer-global/process": "off",
503
522
  "style/comma-dangle": "off",
@@ -541,6 +560,7 @@ function markdown(options = {}) {
541
560
  function node() {
542
561
  return [
543
562
  {
563
+ name: "eslint:node",
544
564
  plugins: {
545
565
  node: default6
546
566
  },
@@ -563,6 +583,7 @@ function sortPackageJson() {
563
583
  return [
564
584
  {
565
585
  files: ["**/package.json"],
586
+ name: "eslint:sort-package-json",
566
587
  rules: {
567
588
  "jsonc/sort-array-values": [
568
589
  "error",
@@ -651,6 +672,7 @@ function sortTsconfig() {
651
672
  return [
652
673
  {
653
674
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
675
+ name: "eslint:sort-tsconfig",
654
676
  rules: {
655
677
  "jsonc/sort-keys": [
656
678
  "error",
@@ -780,11 +802,12 @@ function stylistic(options = {}) {
780
802
  } = options;
781
803
  const {
782
804
  indent = 4,
783
- quotes = "single",
784
- jsx = true
805
+ jsx = true,
806
+ quotes = "single"
785
807
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
786
808
  return [
787
809
  {
810
+ name: "eslint:stylistic",
788
811
  plugins: {
789
812
  antfu: default2,
790
813
  style: default7
@@ -792,6 +815,7 @@ function stylistic(options = {}) {
792
815
  rules: {
793
816
  "antfu/consistent-list-newline": "off",
794
817
  "antfu/if-newline": "error",
818
+ "antfu/indent-binary-ops": ["error", { indent }],
795
819
  "antfu/top-level-function": "error",
796
820
  "curly": ["error", "multi-or-nest", "consistent"],
797
821
  "style/array-bracket-spacing": ["error", "never"],
@@ -807,14 +831,9 @@ function stylistic(options = {}) {
807
831
  "style/indent": ["error", indent, {
808
832
  ArrayExpression: 1,
809
833
  CallExpression: { arguments: 1 },
834
+ flatTernaryExpressions: false,
810
835
  FunctionDeclaration: { body: 1, parameters: 1 },
811
836
  FunctionExpression: { body: 1, parameters: 1 },
812
- ImportDeclaration: 1,
813
- MemberExpression: 1,
814
- ObjectExpression: 1,
815
- SwitchCase: 1,
816
- VariableDeclarator: 1,
817
- flatTernaryExpressions: false,
818
837
  ignoreComments: false,
819
838
  ignoredNodes: [
820
839
  "TemplateLiteral *",
@@ -839,8 +858,13 @@ function stylistic(options = {}) {
839
858
  "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
840
859
  "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
841
860
  ],
861
+ ImportDeclaration: 1,
862
+ MemberExpression: 1,
863
+ ObjectExpression: 1,
842
864
  offsetTernaryExpressions: true,
843
- outerIIFEBody: 1
865
+ outerIIFEBody: 1,
866
+ SwitchCase: 1,
867
+ VariableDeclarator: 1
844
868
  }],
845
869
  "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
846
870
  "style/keyword-spacing": ["error", { after: true, before: true }],
@@ -936,7 +960,7 @@ import process from "process";
936
960
 
937
961
  // src/utils.ts
938
962
  function combine(...configs) {
939
- return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
963
+ return configs.flat();
940
964
  }
941
965
  function renameRules(rules, from, to) {
942
966
  return Object.fromEntries(
@@ -983,6 +1007,7 @@ function typescript(options) {
983
1007
  return [
984
1008
  {
985
1009
  // Install the plugins without globs, so they can be configured separately.
1010
+ name: "eslint:typescript:setup",
986
1011
  plugins: {
987
1012
  antfu: default2,
988
1013
  import: pluginImport,
@@ -1006,6 +1031,7 @@ function typescript(options) {
1006
1031
  ...parserOptions
1007
1032
  }
1008
1033
  },
1034
+ name: "eslint:typescript:rules",
1009
1035
  rules: {
1010
1036
  ...renameRules(
1011
1037
  default8.configs["eslint-recommended"].overrides[0].rules,
@@ -1019,9 +1045,6 @@ function typescript(options) {
1019
1045
  ),
1020
1046
  "antfu/generic-spacing": "error",
1021
1047
  "antfu/named-tuple-spacing": "error",
1022
- "antfu/no-cjs-exports": "error",
1023
- "antfu/no-const-enum": "error",
1024
- "antfu/no-ts-export-equal": "error",
1025
1048
  "no-dupe-class-members": "off",
1026
1049
  "no-invalid-this": "off",
1027
1050
  "no-loss-of-precision": "off",
@@ -1055,6 +1078,7 @@ function typescript(options) {
1055
1078
  },
1056
1079
  {
1057
1080
  files: ["**/*.d.ts"],
1081
+ name: "eslint:typescript:dts-overrides",
1058
1082
  rules: {
1059
1083
  "eslint-comments/no-unlimited-disable": "off",
1060
1084
  "import/no-duplicates": "off",
@@ -1064,12 +1088,14 @@ function typescript(options) {
1064
1088
  },
1065
1089
  {
1066
1090
  files: ["**/*.{test,spec}.ts?(x)"],
1091
+ name: "eslint:typescript:tests-overrides",
1067
1092
  rules: {
1068
1093
  "no-unused-expressions": "off"
1069
1094
  }
1070
1095
  },
1071
1096
  {
1072
1097
  files: ["**/*.js", "**/*.cjs"],
1098
+ name: "eslint:typescript:javascript-overrides",
1073
1099
  rules: {
1074
1100
  "ts/no-require-imports": "off",
1075
1101
  "ts/no-var-requires": "off"
@@ -1082,6 +1108,7 @@ function typescript(options) {
1082
1108
  function unicorn() {
1083
1109
  return [
1084
1110
  {
1111
+ name: "eslint:unicorn",
1085
1112
  plugins: {
1086
1113
  unicorn: default9
1087
1114
  },
@@ -1135,6 +1162,7 @@ function vue(options = {}) {
1135
1162
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1136
1163
  return [
1137
1164
  {
1165
+ name: "eslint:vue:setup",
1138
1166
  plugins: {
1139
1167
  vue: default11
1140
1168
  }
@@ -1142,7 +1170,7 @@ function vue(options = {}) {
1142
1170
  {
1143
1171
  files: [GLOB_VUE],
1144
1172
  languageOptions: {
1145
- parser: default14,
1173
+ parser: default15,
1146
1174
  parserOptions: {
1147
1175
  ecmaFeatures: {
1148
1176
  jsx: true
@@ -1152,6 +1180,7 @@ function vue(options = {}) {
1152
1180
  sourceType: "module"
1153
1181
  }
1154
1182
  },
1183
+ name: "eslint:vue:rules",
1155
1184
  processor: default11.processors[".vue"],
1156
1185
  rules: {
1157
1186
  ...default11.configs.base.rules,
@@ -1263,6 +1292,7 @@ function yaml(options = {}) {
1263
1292
  } = options;
1264
1293
  return [
1265
1294
  {
1295
+ name: "eslint:yaml:setup",
1266
1296
  plugins: {
1267
1297
  yaml: pluginYaml
1268
1298
  }
@@ -1270,8 +1300,9 @@ function yaml(options = {}) {
1270
1300
  {
1271
1301
  files: [GLOB_YAML],
1272
1302
  languageOptions: {
1273
- parser: default15
1303
+ parser: default16
1274
1304
  },
1305
+ name: "eslint:yaml:rules",
1275
1306
  rules: {
1276
1307
  "style/spaced-comment": "off",
1277
1308
  "yaml/block-mapping": "error",
@@ -1308,26 +1339,41 @@ function test(options = {}) {
1308
1339
  } = options;
1309
1340
  return [
1310
1341
  {
1342
+ name: "eslint:test:setup",
1311
1343
  plugins: {
1312
- "no-only-tests": default12
1344
+ test: {
1345
+ ...default13,
1346
+ rules: {
1347
+ ...default13.rules,
1348
+ // extend `test/no-only-tests` rule
1349
+ ...default12.rules
1350
+ }
1351
+ }
1313
1352
  }
1314
1353
  },
1315
1354
  {
1316
1355
  files: GLOB_TESTS,
1356
+ name: "eslint:test:rules",
1317
1357
  rules: {
1318
- "no-only-tests/no-only-tests": isInEditor ? "off" : "error",
1358
+ "node/prefer-global/process": "off",
1359
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1360
+ "test/no-identical-title": "error",
1361
+ "test/no-only-tests": isInEditor ? "off" : "error",
1362
+ "test/prefer-hooks-in-order": "error",
1363
+ "test/prefer-lowercase-title": "error",
1319
1364
  ...overrides
1320
1365
  }
1321
1366
  }
1322
1367
  ];
1323
1368
  }
1324
1369
 
1325
- // src/configs/sort-keys.ts
1326
- function sortKeys() {
1370
+ // src/configs/perfectionist.ts
1371
+ function perfectionist() {
1327
1372
  return [
1328
1373
  {
1374
+ name: "eslint:perfectionist",
1329
1375
  plugins: {
1330
- "sort-keys": default13
1376
+ perfectionist: default14
1331
1377
  }
1332
1378
  }
1333
1379
  ];
@@ -1352,13 +1398,12 @@ var VuePackages = [
1352
1398
  ];
1353
1399
  function lincy(options = {}, ...userConfigs) {
1354
1400
  const {
1355
- isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE) && !process2.env.CI),
1356
- vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
1357
- typescript: enableTypeScript = isPackageExists("typescript"),
1401
+ componentExts = [],
1358
1402
  gitignore: enableGitignore = true,
1359
- sortKeys: enableSortKeys = false,
1403
+ isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE) && !process2.env.CI),
1360
1404
  overrides = {},
1361
- componentExts = []
1405
+ typescript: enableTypeScript = isPackageExists("typescript"),
1406
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i))
1362
1407
  } = options;
1363
1408
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1364
1409
  if (stylisticOptions && !("jsx" in stylisticOptions))
@@ -1388,10 +1433,10 @@ function lincy(options = {}, ...userConfigs) {
1388
1433
  imports({
1389
1434
  stylistic: stylisticOptions
1390
1435
  }),
1391
- unicorn()
1436
+ unicorn(),
1437
+ // Optional plugins (installed but not enabled by default)
1438
+ perfectionist()
1392
1439
  );
1393
- if (enableSortKeys)
1394
- configs.push(sortKeys());
1395
1440
  if (enableVue)
1396
1441
  componentExts.push("vue");
1397
1442
  if (enableTypeScript) {
@@ -1491,10 +1536,11 @@ export {
1491
1536
  lincy,
1492
1537
  markdown,
1493
1538
  node,
1494
- default16 as parserJsonc,
1539
+ default17 as parserJsonc,
1495
1540
  parserTs,
1496
- default14 as parserVue,
1497
- default15 as parserYaml,
1541
+ default15 as parserVue,
1542
+ default16 as parserYaml,
1543
+ perfectionist,
1498
1544
  default2 as pluginAntfu,
1499
1545
  default3 as pluginComments,
1500
1546
  pluginImport,
@@ -1503,15 +1549,15 @@ export {
1503
1549
  default5 as pluginMarkdown,
1504
1550
  default12 as pluginNoOnlyTests,
1505
1551
  default6 as pluginNode,
1506
- default13 as pluginSortKeys,
1552
+ default14 as pluginPerfectionist,
1507
1553
  default7 as pluginStylistic,
1508
1554
  default8 as pluginTs,
1509
1555
  default9 as pluginUnicorn,
1510
1556
  default10 as pluginUnusedImports,
1557
+ default13 as pluginVitest,
1511
1558
  default11 as pluginVue,
1512
1559
  pluginYaml,
1513
1560
  renameRules,
1514
- sortKeys,
1515
1561
  sortPackageJson,
1516
1562
  sortTsconfig,
1517
1563
  stylistic,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "3.6.0",
4
+ "version": "3.7.1",
5
5
  "packageManager": "pnpm@8.7.6",
6
6
  "description": "LinCenYing's ESLint config",
7
7
  "author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
@@ -26,13 +26,13 @@
26
26
  "scripts": {
27
27
  "build": "tsup src/index.ts --format esm,cjs --shims --clean --dts",
28
28
  "stub": "tsup src/index.ts --format esm",
29
- "lint": "pnpm run stub && eslint .",
30
- "lint:fix": "eslint . --fix",
31
29
  "postpublish": "simple-open-url https://npmmirror.com/package/@lincy/eslint-config",
32
30
  "prepublishOnly": "nr build",
33
31
  "release": "bumpp && npm publish -r --access public",
34
32
  "test": "vitest",
35
- "typecheck": "tsc --noEmit",
33
+ "lint": "pnpm run stub && eslint .",
34
+ "lint:fix": "eslint . --fix",
35
+ "lint:ts": "tsc --noEmit",
36
36
  "prepare": "sh simple-git-hooks.sh"
37
37
  },
38
38
  "peerDependencies": {
@@ -40,22 +40,22 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@antfu/eslint-define-config": "1.23.0-2",
43
- "@stylistic/eslint-plugin": "0.1.2",
44
- "@typescript-eslint/eslint-plugin": "^6.9.1",
45
- "@typescript-eslint/parser": "^6.9.1",
43
+ "@stylistic/eslint-plugin": "1.2.0",
44
+ "@typescript-eslint/eslint-plugin": "^6.11.0",
45
+ "@typescript-eslint/parser": "^6.11.0",
46
46
  "eslint-config-flat-gitignore": "^0.1.1",
47
- "eslint-plugin-antfu": "^1.0.1",
47
+ "eslint-plugin-antfu": "^1.0.6",
48
48
  "eslint-plugin-eslint-comments": "^3.2.0",
49
49
  "eslint-plugin-i": "^2.29.0",
50
- "eslint-plugin-jsdoc": "^46.8.2",
50
+ "eslint-plugin-jsdoc": "^46.9.0",
51
51
  "eslint-plugin-jsonc": "^2.10.0",
52
52
  "eslint-plugin-markdown": "^3.0.1",
53
- "eslint-plugin-n": "^16.2.0",
53
+ "eslint-plugin-n": "^16.3.1",
54
54
  "eslint-plugin-no-only-tests": "^3.1.0",
55
- "eslint-plugin-sort-keys": "^2.3.5",
55
+ "eslint-plugin-perfectionist": "^2.3.0",
56
56
  "eslint-plugin-unicorn": "^49.0.0",
57
57
  "eslint-plugin-unused-imports": "^3.0.0",
58
- "eslint-plugin-vitest": "^0.3.8",
58
+ "eslint-plugin-vitest": "^0.3.9",
59
59
  "eslint-plugin-vue": "^9.18.1",
60
60
  "eslint-plugin-yml": "^1.10.0",
61
61
  "globals": "^13.23.0",
@@ -65,16 +65,19 @@
65
65
  "yaml-eslint-parser": "^1.2.2"
66
66
  },
67
67
  "devDependencies": {
68
- "@antfu/ni": "^0.21.8",
68
+ "@antfu/ni": "^0.21.9",
69
+ "@eslint-types/jsdoc": "46.8.2-1",
70
+ "@eslint-types/typescript-eslint": "^6.9.1",
71
+ "@eslint-types/unicorn": "^49.0.0",
69
72
  "@lincy/eslint-config": "workspace:*",
70
- "@stylistic/eslint-plugin-migrate": "^0.1.2",
71
- "@types/eslint": "^8.44.6",
72
- "@types/node": "^20.8.10",
73
+ "@stylistic/eslint-plugin-migrate": "^1.2.0",
74
+ "@types/eslint": "^8.44.7",
75
+ "@types/node": "^20.9.0",
73
76
  "bumpp": "^9.2.0",
74
- "eslint": "^8.52.0",
75
- "eslint-flat-config-viewer": "^0.1.0",
76
- "esno": "^0.17.0",
77
- "lint-staged": "^15.0.2",
77
+ "eslint": "^8.53.0",
78
+ "eslint-flat-config-viewer": "^0.1.1",
79
+ "esno": "^4.0.0",
80
+ "lint-staged": "^15.1.0",
78
81
  "rimraf": "^5.0.5",
79
82
  "simple-git-hooks": "^2.9.0",
80
83
  "simple-open-url": "^3.0.1",