@kirklin/eslint-config 2.6.1 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/factory.ts
2
- import { isPackageExists as isPackageExists4 } from "local-pkg";
3
2
  import { FlatConfigComposer } from "eslint-flat-config-utils";
3
+ import { isPackageExists as isPackageExists4 } from "local-pkg";
4
4
 
5
5
  // src/globs.ts
6
6
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
@@ -231,10 +231,12 @@ async function astro(options = {}) {
231
231
  "astro/no-unused-define-vars-in-style": "error",
232
232
  "astro/semi": "off",
233
233
  "astro/valid-compile": "error",
234
+ // Astro uses top level await for e.g. data fetching
235
+ // https://docs.astro.build/en/guides/data-fetching/#fetch-in-astro
236
+ "kirklin/no-top-level-await": "off",
234
237
  ...stylistic2 ? {
235
238
  "style/indent": "off",
236
239
  "style/jsx-closing-tag-location": "off",
237
- "style/jsx-indent": "off",
238
240
  "style/jsx-one-expression-per-line": "off",
239
241
  "style/no-multiple-empty-lines": "off"
240
242
  } : {},
@@ -256,13 +258,13 @@ async function command() {
256
258
  }
257
259
 
258
260
  // src/plugins.ts
259
- import { default as default2 } from "eslint-plugin-kirklin";
260
- import { default as default3 } from "@eslint-community/eslint-plugin-eslint-comments";
261
+ import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
261
262
  import * as pluginImport from "eslint-plugin-import-x";
263
+ import { default as default3 } from "eslint-plugin-kirklin";
262
264
  import { default as default4 } from "eslint-plugin-n";
263
- import { default as default5 } from "eslint-plugin-unicorn";
264
- import { default as default6 } from "eslint-plugin-unused-imports";
265
- import { default as default7 } from "eslint-plugin-perfectionist";
265
+ import { default as default5 } from "eslint-plugin-perfectionist";
266
+ import { default as default6 } from "eslint-plugin-unicorn";
267
+ import { default as default7 } from "eslint-plugin-unused-imports";
266
268
 
267
269
  // src/configs/comments.ts
268
270
  async function comments() {
@@ -270,7 +272,7 @@ async function comments() {
270
272
  {
271
273
  name: "kirklin/eslint-comments/rules",
272
274
  plugins: {
273
- "eslint-comments": default3
275
+ "eslint-comments": default2
274
276
  },
275
277
  rules: {
276
278
  "eslint-comments/no-aggregating-enable": "error",
@@ -282,6 +284,63 @@ async function comments() {
282
284
  ];
283
285
  }
284
286
 
287
+ // src/configs/disables.ts
288
+ async function disables() {
289
+ return [
290
+ {
291
+ files: [`**/scripts/${GLOB_SRC}`],
292
+ name: "kirklin/disables/scripts",
293
+ rules: {
294
+ "kirklin/no-top-level-await": "off",
295
+ "no-console": "off",
296
+ "ts/explicit-function-return-type": "off"
297
+ }
298
+ },
299
+ {
300
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
301
+ name: "kirklin/disables/cli",
302
+ rules: {
303
+ "kirklin/no-top-level-await": "off",
304
+ "no-console": "off"
305
+ }
306
+ },
307
+ {
308
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
309
+ name: "kirklin/disables/bin",
310
+ rules: {
311
+ "kirklin/no-import-dist": "off",
312
+ "kirklin/no-import-node-modules-by-path": "off"
313
+ }
314
+ },
315
+ {
316
+ files: ["**/*.d.?([cm])ts"],
317
+ name: "kirklin/disables/dts",
318
+ rules: {
319
+ "eslint-comments/no-unlimited-disable": "off",
320
+ "import/no-duplicates": "off",
321
+ "no-restricted-syntax": "off",
322
+ "unused-imports/no-unused-vars": "off"
323
+ }
324
+ },
325
+ {
326
+ files: ["**/*.js", "**/*.cjs"],
327
+ name: "kirklin/disables/cjs",
328
+ rules: {
329
+ "ts/no-require-imports": "off"
330
+ }
331
+ },
332
+ {
333
+ files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
334
+ name: "kirklin/disables/config-files",
335
+ rules: {
336
+ "kirklin/no-top-level-await": "off",
337
+ "no-console": "off",
338
+ "ts/explicit-function-return-type": "off"
339
+ }
340
+ }
341
+ ];
342
+ }
343
+
285
344
  // src/configs/formatters.ts
286
345
  import { isPackageExists as isPackageExists2 } from "local-pkg";
287
346
 
@@ -317,11 +376,12 @@ async function stylistic(options = {}) {
317
376
  {
318
377
  name: "kirklin/stylistic/rules",
319
378
  plugins: {
320
- kirklin: default2,
379
+ kirklin: default3,
321
380
  style: pluginStylistic
322
381
  },
323
382
  rules: {
324
383
  ...config.rules,
384
+ "kirklin/consistent-chaining": "error",
325
385
  "kirklin/consistent-list-newline": "error",
326
386
  "style/brace-style": ["error", "1tbs", { allowSingleLine: false }],
327
387
  "style/member-delimiter-style": ["error", { multiline: { delimiter: "semi" } }],
@@ -339,6 +399,16 @@ async function stylistic(options = {}) {
339
399
  }
340
400
 
341
401
  // src/configs/formatters.ts
402
+ function mergePrettierOptions(options, overrides = {}) {
403
+ return {
404
+ ...options,
405
+ ...overrides,
406
+ plugins: [
407
+ ...overrides.plugins || [],
408
+ ...options.plugins || []
409
+ ]
410
+ };
411
+ }
342
412
  async function formatters(options = {}, stylistic2 = {}) {
343
413
  if (options === true) {
344
414
  const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
@@ -416,10 +486,9 @@ async function formatters(options = {}, stylistic2 = {}) {
416
486
  rules: {
417
487
  "format/prettier": [
418
488
  "error",
419
- {
420
- ...prettierOptions,
489
+ mergePrettierOptions(prettierOptions, {
421
490
  parser: "css"
422
- }
491
+ })
423
492
  ]
424
493
  }
425
494
  },
@@ -432,10 +501,9 @@ async function formatters(options = {}, stylistic2 = {}) {
432
501
  rules: {
433
502
  "format/prettier": [
434
503
  "error",
435
- {
436
- ...prettierOptions,
504
+ mergePrettierOptions(prettierOptions, {
437
505
  parser: "scss"
438
- }
506
+ })
439
507
  ]
440
508
  }
441
509
  },
@@ -448,10 +516,9 @@ async function formatters(options = {}, stylistic2 = {}) {
448
516
  rules: {
449
517
  "format/prettier": [
450
518
  "error",
451
- {
452
- ...prettierOptions,
519
+ mergePrettierOptions(prettierOptions, {
453
520
  parser: "less"
454
- }
521
+ })
455
522
  ]
456
523
  }
457
524
  }
@@ -467,10 +534,9 @@ async function formatters(options = {}, stylistic2 = {}) {
467
534
  rules: {
468
535
  "format/prettier": [
469
536
  "error",
470
- {
471
- ...prettierOptions,
537
+ mergePrettierOptions(prettierOptions, {
472
538
  parser: "html"
473
- }
539
+ })
474
540
  ]
475
541
  }
476
542
  });
@@ -485,14 +551,12 @@ async function formatters(options = {}, stylistic2 = {}) {
485
551
  rules: {
486
552
  "format/prettier": [
487
553
  "error",
488
- {
489
- ...prettierXmlOptions,
490
- ...prettierOptions,
554
+ mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
491
555
  parser: "xml",
492
556
  plugins: [
493
557
  "@prettier/plugin-xml"
494
558
  ]
495
- }
559
+ })
496
560
  ]
497
561
  }
498
562
  });
@@ -507,14 +571,12 @@ async function formatters(options = {}, stylistic2 = {}) {
507
571
  rules: {
508
572
  "format/prettier": [
509
573
  "error",
510
- {
511
- ...prettierXmlOptions,
512
- ...prettierOptions,
574
+ mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
513
575
  parser: "xml",
514
576
  plugins: [
515
577
  "@prettier/plugin-xml"
516
578
  ]
517
- }
579
+ })
518
580
  ]
519
581
  }
520
582
  });
@@ -532,11 +594,10 @@ async function formatters(options = {}, stylistic2 = {}) {
532
594
  rules: {
533
595
  [`format/${formater}`]: [
534
596
  "error",
535
- formater === "prettier" ? {
536
- ...prettierOptions,
597
+ formater === "prettier" ? mergePrettierOptions(prettierOptions, {
537
598
  embeddedLanguageFormatting: "off",
538
599
  parser: "markdown"
539
- } : {
600
+ }) : {
540
601
  ...dprintOptions,
541
602
  language: "markdown"
542
603
  }
@@ -553,14 +614,13 @@ async function formatters(options = {}, stylistic2 = {}) {
553
614
  rules: {
554
615
  "format/prettier": [
555
616
  "error",
556
- {
557
- ...prettierOptions,
617
+ mergePrettierOptions(prettierOptions, {
558
618
  embeddedLanguageFormatting: "off",
559
619
  parser: "slidev",
560
620
  plugins: [
561
621
  "prettier-plugin-slidev"
562
622
  ]
563
- }
623
+ })
564
624
  ]
565
625
  }
566
626
  });
@@ -576,13 +636,12 @@ async function formatters(options = {}, stylistic2 = {}) {
576
636
  rules: {
577
637
  "format/prettier": [
578
638
  "error",
579
- {
580
- ...prettierOptions,
639
+ mergePrettierOptions(prettierOptions, {
581
640
  parser: "astro",
582
641
  plugins: [
583
642
  "prettier-plugin-astro"
584
643
  ]
585
- }
644
+ })
586
645
  ]
587
646
  }
588
647
  });
@@ -610,10 +669,9 @@ async function formatters(options = {}, stylistic2 = {}) {
610
669
  rules: {
611
670
  "format/prettier": [
612
671
  "error",
613
- {
614
- ...prettierOptions,
672
+ mergePrettierOptions(prettierOptions, {
615
673
  parser: "graphql"
616
- }
674
+ })
617
675
  ]
618
676
  }
619
677
  });
@@ -622,10 +680,14 @@ async function formatters(options = {}, stylistic2 = {}) {
622
680
  }
623
681
 
624
682
  // src/configs/ignores.ts
625
- async function ignores() {
683
+ async function ignores(userIgnores = []) {
626
684
  return [
627
685
  {
628
- ignores: GLOB_EXCLUDE
686
+ ignores: [
687
+ ...GLOB_EXCLUDE,
688
+ ...userIgnores
689
+ ],
690
+ name: "kirklin/ignores"
629
691
  }
630
692
  ];
631
693
  }
@@ -640,7 +702,7 @@ async function imports(options = {}) {
640
702
  name: "kirklin/imports/rules",
641
703
  plugins: {
642
704
  import: pluginImport,
643
- kirklin: default2
705
+ kirklin: default3
644
706
  },
645
707
  rules: {
646
708
  "import/first": "error",
@@ -649,7 +711,6 @@ async function imports(options = {}) {
649
711
  "import/no-named-default": "error",
650
712
  "import/no-self-import": "error",
651
713
  "import/no-webpack-loader-syntax": "error",
652
- "import/order": "error",
653
714
  "kirklin/import-dedupe": "error",
654
715
  "kirklin/no-import-dist": "error",
655
716
  "kirklin/no-import-node-modules-by-path": "error",
@@ -657,14 +718,6 @@ async function imports(options = {}) {
657
718
  "import/newline-after-import": ["error", { count: 1 }]
658
719
  } : {}
659
720
  }
660
- },
661
- {
662
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
663
- name: "kirklin/imports/disables/bin",
664
- rules: {
665
- "kirklin/no-import-dist": "off",
666
- "kirklin/no-import-node-modules-by-path": "off"
667
- }
668
721
  }
669
722
  ];
670
723
  }
@@ -705,8 +758,8 @@ async function javascript(options = {}) {
705
758
  {
706
759
  name: "kirklin/javascript/rules",
707
760
  plugins: {
708
- "kirklin": default2,
709
- "unused-imports": default6
761
+ "kirklin": default3,
762
+ "unused-imports": default7
710
763
  },
711
764
  rules: {
712
765
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
@@ -716,6 +769,7 @@ async function javascript(options = {}) {
716
769
  "default-case-last": "error",
717
770
  "dot-notation": ["error", { allowKeywords: true }],
718
771
  "eqeqeq": ["error", "smart"],
772
+ "kirklin/no-top-level-await": "error",
719
773
  "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
720
774
  "no-alert": "error",
721
775
  "no-array-constructor": "error",
@@ -781,9 +835,6 @@ async function javascript(options = {}) {
781
835
  ],
782
836
  "no-restricted-syntax": [
783
837
  "error",
784
- "DebuggerStatement",
785
- "LabeledStatement",
786
- "WithStatement",
787
838
  "TSEnumDeclaration[const=true]",
788
839
  "TSExportAssignment"
789
840
  ],
@@ -854,16 +905,6 @@ async function javascript(options = {}) {
854
905
  "prefer-rest-params": "error",
855
906
  "prefer-spread": "error",
856
907
  "prefer-template": "error",
857
- "sort-imports": [
858
- "error",
859
- {
860
- allowSeparatedGroups: false,
861
- ignoreCase: false,
862
- ignoreDeclarationSort: true,
863
- ignoreMemberSort: false,
864
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
865
- }
866
- ],
867
908
  "symbol-description": "error",
868
909
  "unicode-bom": ["error", "never"],
869
910
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
@@ -883,13 +924,6 @@ async function javascript(options = {}) {
883
924
  "yoda": ["error", "never"],
884
925
  ...overrides
885
926
  }
886
- },
887
- {
888
- files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
889
- name: "kirklin/javascript/disables/cli",
890
- rules: {
891
- "no-console": "off"
892
- }
893
927
  }
894
928
  ];
895
929
  }
@@ -930,23 +964,6 @@ async function jsdoc(options = {}) {
930
964
  ];
931
965
  }
932
966
 
933
- // src/configs/jsx.ts
934
- async function jsx() {
935
- return [
936
- {
937
- files: [GLOB_JSX, GLOB_TSX],
938
- languageOptions: {
939
- parserOptions: {
940
- ecmaFeatures: {
941
- jsx: true
942
- }
943
- }
944
- },
945
- name: "kirklin/jsx/setup"
946
- }
947
- ];
948
- }
949
-
950
967
  // src/configs/jsonc.ts
951
968
  async function jsonc(options = {}) {
952
969
  const {
@@ -1022,6 +1039,23 @@ async function jsonc(options = {}) {
1022
1039
  ];
1023
1040
  }
1024
1041
 
1042
+ // src/configs/jsx.ts
1043
+ async function jsx() {
1044
+ return [
1045
+ {
1046
+ files: [GLOB_JSX, GLOB_TSX],
1047
+ languageOptions: {
1048
+ parserOptions: {
1049
+ ecmaFeatures: {
1050
+ jsx: true
1051
+ }
1052
+ }
1053
+ },
1054
+ name: "kirklin/jsx/setup"
1055
+ }
1056
+ ];
1057
+ }
1058
+
1025
1059
  // src/configs/markdown.ts
1026
1060
  import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
1027
1061
  async function markdown(options = {}) {
@@ -1030,7 +1064,7 @@ async function markdown(options = {}) {
1030
1064
  files = [GLOB_MARKDOWN],
1031
1065
  overrides = {}
1032
1066
  } = options;
1033
- const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
1067
+ const markdown2 = await interopDefault(import("@eslint/markdown"));
1034
1068
  return [
1035
1069
  {
1036
1070
  name: "kirklin/markdown/setup",
@@ -1072,6 +1106,7 @@ async function markdown(options = {}) {
1072
1106
  name: "kirklin/markdown/disables",
1073
1107
  rules: {
1074
1108
  "import/newline-after-import": "off",
1109
+ "kirklin/no-top-level-await": "off",
1075
1110
  "no-alert": "off",
1076
1111
  "no-console": "off",
1077
1112
  "no-labels": "off",
@@ -1085,13 +1120,13 @@ async function markdown(options = {}) {
1085
1120
  "style/comma-dangle": "off",
1086
1121
  "style/eol-last": "off",
1087
1122
  "ts/consistent-type-imports": "off",
1123
+ "ts/explicit-function-return-type": "off",
1088
1124
  "ts/no-namespace": "off",
1089
1125
  "ts/no-redeclare": "off",
1090
1126
  "ts/no-require-imports": "off",
1091
1127
  "ts/no-unused-expressions": "off",
1092
1128
  "ts/no-unused-vars": "off",
1093
1129
  "ts/no-use-before-define": "off",
1094
- "ts/no-var-requires": "off",
1095
1130
  "unicode-bom": "off",
1096
1131
  "unused-imports/no-unused-imports": "off",
1097
1132
  "unused-imports/no-unused-vars": "off",
@@ -1129,7 +1164,28 @@ async function perfectionist() {
1129
1164
  {
1130
1165
  name: "kirklin/perfectionist/setup",
1131
1166
  plugins: {
1132
- perfectionist: default7
1167
+ perfectionist: default5
1168
+ },
1169
+ rules: {
1170
+ "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
1171
+ "perfectionist/sort-imports": ["error", {
1172
+ groups: [
1173
+ "type",
1174
+ ["parent-type", "sibling-type", "index-type", "internal-type"],
1175
+ "builtin",
1176
+ "external",
1177
+ "internal",
1178
+ ["parent", "sibling", "index"],
1179
+ "side-effect",
1180
+ "object",
1181
+ "unknown"
1182
+ ],
1183
+ newlinesBetween: "ignore",
1184
+ order: "asc",
1185
+ type: "natural"
1186
+ }],
1187
+ "perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
1188
+ "perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
1133
1189
  }
1134
1190
  }
1135
1191
  ];
@@ -1152,25 +1208,31 @@ var NextJsPackages = [
1152
1208
  async function react(options = {}) {
1153
1209
  const {
1154
1210
  files = [GLOB_SRC],
1155
- overrides = {}
1211
+ filesTypeAware = [GLOB_TS, GLOB_TSX],
1212
+ ignoresTypeAware = [
1213
+ `${GLOB_MARKDOWN}/**`,
1214
+ GLOB_ASTRO_TS
1215
+ ],
1216
+ overrides = {},
1217
+ tsconfigPath
1156
1218
  } = options;
1157
1219
  await ensurePackages([
1158
1220
  "@eslint-react/eslint-plugin",
1159
1221
  "eslint-plugin-react-hooks",
1160
1222
  "eslint-plugin-react-refresh"
1161
1223
  ]);
1162
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1163
1224
  const isTypeAware = !!tsconfigPath;
1225
+ const typeAwareRules = {
1226
+ "react/no-leaked-conditional-rendering": "warn"
1227
+ };
1164
1228
  const [
1165
1229
  pluginReact,
1166
1230
  pluginReactHooks,
1167
- pluginReactRefresh,
1168
- parserTs
1231
+ pluginReactRefresh
1169
1232
  ] = await Promise.all([
1170
1233
  interopDefault(import("@eslint-react/eslint-plugin")),
1171
1234
  interopDefault(import("eslint-plugin-react-hooks")),
1172
- interopDefault(import("eslint-plugin-react-refresh")),
1173
- interopDefault(import("@typescript-eslint/parser"))
1235
+ interopDefault(import("eslint-plugin-react-refresh"))
1174
1236
  ]);
1175
1237
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists3(i));
1176
1238
  const isUsingRemix = RemixPackages.some((i) => isPackageExists3(i));
@@ -1191,12 +1253,10 @@ async function react(options = {}) {
1191
1253
  {
1192
1254
  files,
1193
1255
  languageOptions: {
1194
- parser: parserTs,
1195
1256
  parserOptions: {
1196
1257
  ecmaFeatures: {
1197
1258
  jsx: true
1198
- },
1199
- ...isTypeAware ? { project: tsconfigPath } : {}
1259
+ }
1200
1260
  },
1201
1261
  sourceType: "module"
1202
1262
  },
@@ -1224,6 +1284,13 @@ async function react(options = {}) {
1224
1284
  allowConstantExport: isAllowConstantExport,
1225
1285
  allowExportNames: [
1226
1286
  ...isUsingNext ? [
1287
+ "dynamic",
1288
+ "dynamicParams",
1289
+ "revalidate",
1290
+ "fetchCache",
1291
+ "runtime",
1292
+ "preferredRegion",
1293
+ "maxDuration",
1227
1294
  "config",
1228
1295
  "generateStaticParams",
1229
1296
  "metadata",
@@ -1278,12 +1345,43 @@ async function react(options = {}) {
1278
1345
  "react/prefer-destructuring-assignment": "warn",
1279
1346
  "react/prefer-shorthand-boolean": "warn",
1280
1347
  "react/prefer-shorthand-fragment": "warn",
1281
- ...isTypeAware ? {
1282
- "react/no-leaked-conditional-rendering": "warn"
1283
- } : {},
1284
1348
  // overrides
1285
1349
  ...overrides
1286
1350
  }
1351
+ },
1352
+ ...isTypeAware ? [{
1353
+ files: filesTypeAware,
1354
+ ignores: ignoresTypeAware,
1355
+ name: "kirklin/react/type-aware-rules",
1356
+ rules: {
1357
+ ...typeAwareRules
1358
+ }
1359
+ }] : []
1360
+ ];
1361
+ }
1362
+
1363
+ // src/configs/regexp.ts
1364
+ import { configs } from "eslint-plugin-regexp";
1365
+ async function regexp(options = {}) {
1366
+ const config = configs["flat/recommended"];
1367
+ const rules = {
1368
+ ...config.rules
1369
+ };
1370
+ if (options.level === "warn") {
1371
+ for (const key in rules) {
1372
+ if (rules[key] === "error") {
1373
+ rules[key] = "warn";
1374
+ }
1375
+ }
1376
+ }
1377
+ return [
1378
+ {
1379
+ ...config,
1380
+ name: "kirklin/regexp/rules",
1381
+ rules: {
1382
+ ...rules,
1383
+ ...options.overrides
1384
+ }
1287
1385
  }
1288
1386
  ];
1289
1387
  }
@@ -1680,7 +1778,7 @@ async function svelte(options = {}) {
1680
1778
  // superseded by svelte/no-trailing-spaces
1681
1779
  "svelte/derived-has-same-inputs-outputs": "error",
1682
1780
  "svelte/html-closing-bracket-spacing": "error",
1683
- "svelte/html-quotes": ["error", { prefer: quotes }],
1781
+ "svelte/html-quotes": ["error", { prefer: quotes === "backtick" ? "double" : quotes }],
1684
1782
  "svelte/indent": ["error", { alignAttributesVertically: true, indent }],
1685
1783
  "svelte/mustache-spacing": "error",
1686
1784
  "svelte/no-spaces-around-equal-signs-in-attribute": "error",
@@ -1728,14 +1826,19 @@ async function test(options = {}) {
1728
1826
  files,
1729
1827
  name: "kirklin/test/rules",
1730
1828
  rules: {
1731
- "node/prefer-global/process": "off",
1732
1829
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1733
1830
  "test/no-identical-title": "error",
1734
1831
  "test/no-import-node-test": "error",
1735
1832
  "test/no-only-tests": isInEditor ? "off" : "error",
1736
1833
  "test/prefer-hooks-in-order": "error",
1737
1834
  "test/prefer-lowercase-title": "error",
1738
- "ts/explicit-function-return-type": "off",
1835
+ // Disables
1836
+ ...{
1837
+ "kirklin/no-top-level-await": "off",
1838
+ "no-unused-expressions": "off",
1839
+ "node/prefer-global/process": "off",
1840
+ "ts/explicit-function-return-type": "off"
1841
+ },
1739
1842
  ...overrides
1740
1843
  }
1741
1844
  }
@@ -1880,7 +1983,7 @@ async function typescript(options = {}) {
1880
1983
  // Install the plugins without globs, so they can be configured separately.
1881
1984
  name: "kirklin/typescript/setup",
1882
1985
  plugins: {
1883
- kirklin: default2,
1986
+ kirklin: default3,
1884
1987
  ts: pluginTs
1885
1988
  }
1886
1989
  },
@@ -1904,7 +2007,6 @@ async function typescript(options = {}) {
1904
2007
  { "@typescript-eslint": "ts" }
1905
2008
  ),
1906
2009
  "no-dupe-class-members": "off",
1907
- "no-loss-of-precision": "off",
1908
2010
  "no-redeclare": "off",
1909
2011
  "no-use-before-define": "off",
1910
2012
  "no-useless-constructor": "off",
@@ -1923,10 +2025,14 @@ async function typescript(options = {}) {
1923
2025
  "ts/no-extraneous-class": "off",
1924
2026
  "ts/no-import-type-side-effects": "error",
1925
2027
  "ts/no-invalid-void-type": "off",
1926
- "ts/no-loss-of-precision": "error",
1927
2028
  "ts/no-non-null-assertion": "off",
1928
- "ts/no-redeclare": "error",
2029
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
1929
2030
  "ts/no-require-imports": "error",
2031
+ "ts/no-unused-expressions": ["error", {
2032
+ allowShortCircuit: true,
2033
+ allowTaggedTemplates: true,
2034
+ allowTernary: true
2035
+ }],
1930
2036
  "ts/no-unused-vars": "off",
1931
2037
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1932
2038
  "ts/no-useless-constructor": "off",
@@ -1951,70 +2057,36 @@ async function typescript(options = {}) {
1951
2057
  ...typeAwareRules,
1952
2058
  ...overridesTypeAware
1953
2059
  }
1954
- }] : [],
1955
- {
1956
- files: ["**/*.d.?([cm])ts"],
1957
- name: "kirklin/typescript/disables/dts",
1958
- rules: {
1959
- "eslint-comments/no-unlimited-disable": "off",
1960
- "import/no-duplicates": "off",
1961
- "no-restricted-syntax": "off",
1962
- "unused-imports/no-unused-vars": "off"
1963
- }
1964
- },
1965
- {
1966
- files: ["**/*.{test,spec}.ts?(x)"],
1967
- name: "kirklin/typescript/disables/test",
1968
- rules: {
1969
- "no-unused-expressions": "off"
1970
- }
1971
- },
1972
- {
1973
- files: ["**/*.js", "**/*.cjs"],
1974
- name: "kirklin/typescript/disables/cjs",
1975
- rules: {
1976
- "ts/no-require-imports": "off",
1977
- "ts/no-var-requires": "off"
1978
- }
1979
- }
2060
+ }] : []
1980
2061
  ];
1981
2062
  }
1982
2063
 
1983
2064
  // src/configs/unicorn.ts
1984
- async function unicorn() {
2065
+ async function unicorn(options = {}) {
1985
2066
  return [
1986
2067
  {
1987
2068
  name: "kirklin/unicorn/rules",
1988
2069
  plugins: {
1989
- unicorn: default5
2070
+ unicorn: default6
1990
2071
  },
1991
2072
  rules: {
1992
- // Pass error message when throwing errors
1993
- "unicorn/error-message": "error",
1994
- // Uppercase regex escapes
1995
- "unicorn/escape-case": "error",
1996
- // Array.isArray instead of instanceof
1997
- "unicorn/no-instanceof-array": "error",
1998
- // Ban `new Array` as `Array` constructor's params are ambiguous
1999
- "unicorn/no-new-array": "error",
2000
- // Prevent deprecated `new Buffer()`
2001
- "unicorn/no-new-buffer": "error",
2002
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
2003
- "unicorn/number-literal-case": "error",
2004
- // textContent instead of innerText
2005
- "unicorn/prefer-dom-node-text-content": "error",
2006
- // includes over indexOf when checking for existence
2007
- "unicorn/prefer-includes": "error",
2008
- // Prefer using the node: protocol
2009
- "unicorn/prefer-node-protocol": "error",
2010
- // Prefer using number properties like `Number.isNaN` rather than `isNaN`
2011
- "unicorn/prefer-number-properties": "error",
2012
- // String methods startsWith/endsWith instead of more complicated stuff
2013
- "unicorn/prefer-string-starts-ends-with": "error",
2014
- // Enforce throwing type error when throwing error while checking typeof
2015
- "unicorn/prefer-type-error": "error",
2016
- // Use new when throwing error
2017
- "unicorn/throw-new-error": "error"
2073
+ ...options.allRecommended ? default6.configs["flat/recommended"].rules : {
2074
+ "unicorn/consistent-empty-array-spread": "error",
2075
+ "unicorn/error-message": "error",
2076
+ "unicorn/escape-case": "error",
2077
+ "unicorn/new-for-builtins": "error",
2078
+ "unicorn/no-instanceof-array": "error",
2079
+ "unicorn/no-new-array": "error",
2080
+ "unicorn/no-new-buffer": "error",
2081
+ "unicorn/number-literal-case": "error",
2082
+ "unicorn/prefer-dom-node-text-content": "error",
2083
+ "unicorn/prefer-includes": "error",
2084
+ "unicorn/prefer-node-protocol": "error",
2085
+ "unicorn/prefer-number-properties": "error",
2086
+ "unicorn/prefer-string-starts-ends-with": "error",
2087
+ "unicorn/prefer-type-error": "error",
2088
+ "unicorn/throw-new-error": "error"
2089
+ }
2018
2090
  }
2019
2091
  }
2020
2092
  ];
@@ -2071,7 +2143,6 @@ async function vue(options = {}) {
2071
2143
  parserVue,
2072
2144
  processorVueBlocks
2073
2145
  ] = await Promise.all([
2074
- // @ts-expect-error missing types
2075
2146
  interopDefault(import("eslint-plugin-vue")),
2076
2147
  interopDefault(import("vue-eslint-parser")),
2077
2148
  interopDefault(import("eslint-processor-vue-blocks"))
@@ -2138,7 +2209,9 @@ async function vue(options = {}) {
2138
2209
  ...pluginVue.configs["vue3-strongly-recommended"].rules,
2139
2210
  ...pluginVue.configs["vue3-recommended"].rules
2140
2211
  },
2212
+ "kirklin/no-top-level-await": "off",
2141
2213
  "node/prefer-global/process": "off",
2214
+ "ts/explicit-function-return-type": "off",
2142
2215
  "vue/block-order": ["error", {
2143
2216
  order: ["script", "template", "style"]
2144
2217
  }],
@@ -2275,7 +2348,7 @@ async function yaml(options = {}) {
2275
2348
  "yaml/indent": ["error", indent === "tab" ? 2 : indent],
2276
2349
  "yaml/key-spacing": "error",
2277
2350
  "yaml/no-tab-indent": "error",
2278
- "yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
2351
+ "yaml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
2279
2352
  "yaml/spaced-comment": "error"
2280
2353
  } : {},
2281
2354
  ...overrides
@@ -2284,37 +2357,9 @@ async function yaml(options = {}) {
2284
2357
  ];
2285
2358
  }
2286
2359
 
2287
- // src/configs/regexp.ts
2288
- import { configs } from "eslint-plugin-regexp";
2289
- async function regexp(options = {}) {
2290
- const config = configs["flat/recommended"];
2291
- const rules = {
2292
- ...config.rules
2293
- };
2294
- if (options.level === "warn") {
2295
- for (const key in rules) {
2296
- if (rules[key] === "error") {
2297
- rules[key] = "warn";
2298
- }
2299
- }
2300
- }
2301
- return [
2302
- {
2303
- ...config,
2304
- name: "kirklin/regexp/rules",
2305
- rules: {
2306
- ...rules,
2307
- ...options.overrides
2308
- }
2309
- }
2310
- ];
2311
- }
2312
-
2313
2360
  // src/factory.ts
2314
2361
  var flatConfigProps = [
2315
2362
  "name",
2316
- "files",
2317
- "ignores",
2318
2363
  "languageOptions",
2319
2364
  "linterOptions",
2320
2365
  "processor",
@@ -2352,6 +2397,7 @@ function kirklin(options = {}, ...userConfigs) {
2352
2397
  solid: enableSolid = false,
2353
2398
  svelte: enableSvelte = false,
2354
2399
  typescript: enableTypeScript = isPackageExists4("typescript"),
2400
+ unicorn: enableUnicorn = true,
2355
2401
  unocss: enableUnoCSS = false,
2356
2402
  vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
2357
2403
  } = options;
@@ -2359,7 +2405,7 @@ function kirklin(options = {}, ...userConfigs) {
2359
2405
  if (isInEditor == null) {
2360
2406
  isInEditor = isInEditorEnv();
2361
2407
  if (isInEditor) {
2362
- console.log("[@kirklin/eslint-config] Detected running in editor, some rules are disabled.");
2408
+ console.info("[@kirklin/eslint-config] Detected running in editor, some rules are disabled.");
2363
2409
  }
2364
2410
  }
2365
2411
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
@@ -2369,15 +2415,21 @@ function kirklin(options = {}, ...userConfigs) {
2369
2415
  const configs2 = [];
2370
2416
  if (enableGitignore) {
2371
2417
  if (typeof enableGitignore !== "boolean") {
2372
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
2418
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2419
+ name: "kirklin/gitignore",
2420
+ ...enableGitignore
2421
+ })]));
2373
2422
  } else {
2374
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
2423
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2424
+ name: "kirklin/gitignore",
2425
+ strict: false
2426
+ })]));
2375
2427
  }
2376
2428
  }
2377
2429
  const typescriptOptions = resolveSubOptions(options, "typescript");
2378
2430
  const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2379
2431
  configs2.push(
2380
- ignores(),
2432
+ ignores(options.ignores),
2381
2433
  javascript({
2382
2434
  isInEditor,
2383
2435
  overrides: getOverrides(options, "javascript")
@@ -2390,11 +2442,13 @@ function kirklin(options = {}, ...userConfigs) {
2390
2442
  imports({
2391
2443
  stylistic: stylisticOptions
2392
2444
  }),
2393
- unicorn(),
2394
2445
  command(),
2395
2446
  // Optional plugins (installed but not enabled by default)
2396
2447
  perfectionist()
2397
2448
  );
2449
+ if (enableUnicorn) {
2450
+ configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
2451
+ }
2398
2452
  if (enableVue) {
2399
2453
  componentExts.push("vue");
2400
2454
  }
@@ -2503,6 +2557,12 @@ function kirklin(options = {}, ...userConfigs) {
2503
2557
  typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2504
2558
  ));
2505
2559
  }
2560
+ configs2.push(
2561
+ disables()
2562
+ );
2563
+ if ("files" in options) {
2564
+ throw new Error('[@kirklin/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
2565
+ }
2506
2566
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2507
2567
  if (key in options) {
2508
2568
  acc[key] = options[key];
@@ -2573,6 +2633,7 @@ export {
2573
2633
  comments,
2574
2634
  src_default as default,
2575
2635
  defaultPluginRenaming,
2636
+ disables,
2576
2637
  ensurePackages,
2577
2638
  formatters,
2578
2639
  getOverrides,