@lincy/eslint-config 4.7.0 → 5.0.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
@@ -4,7 +4,7 @@ import { FlatConfigComposer } from "eslint-flat-config-utils";
4
4
 
5
5
  // src/plugins.ts
6
6
  import { default as default2 } from "eslint-plugin-antfu";
7
- import { default as default3 } from "eslint-plugin-eslint-comments";
7
+ import { default as default3 } from "@eslint-community/eslint-plugin-eslint-comments";
8
8
  import * as pluginImport from "eslint-plugin-import-x";
9
9
  import { default as default4 } from "eslint-plugin-n";
10
10
  import { default as default5 } from "eslint-plugin-unicorn";
@@ -15,7 +15,7 @@ import { default as default7 } from "eslint-plugin-perfectionist";
15
15
  async function comments() {
16
16
  return [
17
17
  {
18
- name: "eslint:comments",
18
+ name: "eslint/comments/rules",
19
19
  plugins: {
20
20
  "eslint-comments": default3
21
21
  },
@@ -50,6 +50,8 @@ var GLOB_SVELTE = "**/*.svelte";
50
50
  var GLOB_VUE = "**/*.vue";
51
51
  var GLOB_YAML = "**/*.y?(a)ml";
52
52
  var GLOB_TOML = "**/*.toml";
53
+ var GLOB_XML = "**/*.xml";
54
+ var GLOB_SVG = "**/*.svg";
53
55
  var GLOB_HTML = "**/*.htm?(l)";
54
56
  var GLOB_GRAPHQL = "**/*.{g,graph}ql";
55
57
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
@@ -111,7 +113,7 @@ async function ignores(options = {}) {
111
113
  ...GLOB_EXCLUDE,
112
114
  ...ignores2
113
115
  ],
114
- name: "eslint:ignores"
116
+ name: "eslint/ignores"
115
117
  }
116
118
  ];
117
119
  }
@@ -123,7 +125,7 @@ async function imports(options = {}) {
123
125
  } = options;
124
126
  return [
125
127
  {
126
- name: "eslint:imports:rules",
128
+ name: "eslint/imports/rules",
127
129
  plugins: {
128
130
  antfu: default2,
129
131
  import: pluginImport
@@ -146,7 +148,7 @@ async function imports(options = {}) {
146
148
  },
147
149
  {
148
150
  files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
149
- name: "eslint:imports:disables:bin",
151
+ name: "eslint/imports/disables/bin",
150
152
  rules: {
151
153
  "antfu/no-import-dist": "off",
152
154
  "antfu/no-import-node-modules-by-path": "off"
@@ -186,10 +188,10 @@ async function javascript(options = {}) {
186
188
  linterOptions: {
187
189
  reportUnusedDisableDirectives: true
188
190
  },
189
- name: "eslint:javascript:setup"
191
+ name: "eslint/javascript/setup"
190
192
  },
191
193
  {
192
- name: "eslint:javascript:rules",
194
+ name: "eslint/javascript/rules",
193
195
  plugins: {
194
196
  "antfu": default2,
195
197
  "unused-imports": default6
@@ -268,9 +270,6 @@ async function javascript(options = {}) {
268
270
  ],
269
271
  "no-restricted-syntax": [
270
272
  "error",
271
- "DebuggerStatement",
272
- "LabeledStatement",
273
- "WithStatement",
274
273
  "TSEnumDeclaration[const=true]",
275
274
  "TSExportAssignment"
276
275
  ],
@@ -373,7 +372,7 @@ async function javascript(options = {}) {
373
372
  },
374
373
  {
375
374
  files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
376
- name: "eslint:scripts:disables",
375
+ name: "eslint/scripts/disables",
377
376
  rules: {
378
377
  "no-console": "off"
379
378
  }
@@ -383,7 +382,10 @@ async function javascript(options = {}) {
383
382
 
384
383
  // src/utils.ts
385
384
  import process from "node:process";
385
+ import { fileURLToPath } from "node:url";
386
386
  import { isPackageExists } from "local-pkg";
387
+ var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
388
+ var isCwdInScope = isPackageExists("@antfu/eslint-config");
387
389
  async function combine(...configs2) {
388
390
  const resolved = await Promise.all(configs2);
389
391
  return resolved.flat();
@@ -426,28 +428,31 @@ async function interopDefault(m) {
426
428
  const resolved = await m;
427
429
  return resolved.default || resolved;
428
430
  }
431
+ function isPackageInScope(name) {
432
+ return isPackageExists(name, { paths: [scopeUrl] });
433
+ }
429
434
  async function ensurePackages(packages) {
430
- if (process.stdout.isTTY === false) {
435
+ if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
431
436
  return;
432
- }
433
- const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
434
- if (nonExistingPackages.length === 0) {
437
+ const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
438
+ if (nonExistingPackages.length === 0)
435
439
  return;
436
- }
437
- const { default: prompts } = await import("prompts");
438
- const { result } = await prompts([
439
- {
440
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
441
- name: "result",
442
- type: "confirm"
443
- }
444
- ]);
445
- if (result) {
440
+ const p = await import("@clack/prompts");
441
+ const result = await p.confirm({
442
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
443
+ });
444
+ if (result)
446
445
  await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
447
- }
448
446
  }
449
447
  function isInEditorEnv() {
450
- return !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI);
448
+ if (process.env.CI)
449
+ return false;
450
+ if (isInGitHooksOrLintStaged())
451
+ return false;
452
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
453
+ }
454
+ function isInGitHooksOrLintStaged() {
455
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
451
456
  }
452
457
 
453
458
  // src/configs/jsdoc.ts
@@ -457,7 +462,7 @@ async function jsdoc(options = {}) {
457
462
  } = options;
458
463
  return [
459
464
  {
460
- name: "eslint:jsdoc:rules",
465
+ name: "eslint/jsdoc/rules",
461
466
  plugins: {
462
467
  jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
463
468
  },
@@ -502,7 +507,7 @@ async function jsonc(options = {}) {
502
507
  ]);
503
508
  return [
504
509
  {
505
- name: "eslint:jsonc:setup",
510
+ name: "eslint/jsonc/setup",
506
511
  plugins: {
507
512
  jsonc: pluginJsonc
508
513
  }
@@ -512,7 +517,7 @@ async function jsonc(options = {}) {
512
517
  languageOptions: {
513
518
  parser: parserJsonc
514
519
  },
515
- name: "eslint:jsonc:rules",
520
+ name: "eslint/jsonc/rules",
516
521
  rules: {
517
522
  "jsonc/no-bigint-literals": "error",
518
523
  "jsonc/no-binary-expression": "error",
@@ -570,7 +575,7 @@ async function jsx() {
570
575
  }
571
576
  }
572
577
  },
573
- name: "eslint:jsx:setup"
578
+ name: "eslint/jsx/setup"
574
579
  }
575
580
  ];
576
581
  }
@@ -587,7 +592,7 @@ async function markdown(options = {}) {
587
592
  const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
588
593
  return [
589
594
  {
590
- name: "eslint:markdown:setup",
595
+ name: "eslint/markdown/setup",
591
596
  plugins: {
592
597
  markdown: markdown2
593
598
  }
@@ -595,7 +600,7 @@ async function markdown(options = {}) {
595
600
  {
596
601
  files,
597
602
  ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
598
- name: "eslint:markdown:processor",
603
+ name: "eslint/markdown/processor",
599
604
  processor: mergeProcessors([
600
605
  markdown2.processors.markdown,
601
606
  processorPassThrough
@@ -606,7 +611,7 @@ async function markdown(options = {}) {
606
611
  languageOptions: {
607
612
  parser: parserPlain
608
613
  },
609
- name: "eslint:markdown:parser"
614
+ name: "eslint/markdown/parser"
610
615
  },
611
616
  {
612
617
  files: [
@@ -620,7 +625,7 @@ async function markdown(options = {}) {
620
625
  }
621
626
  }
622
627
  },
623
- name: "eslint:markdown:disables",
628
+ name: "eslint/markdown/disables",
624
629
  rules: {
625
630
  "import/newline-after-import": "off",
626
631
  "no-alert": "off",
@@ -674,7 +679,7 @@ async function markdown(options = {}) {
674
679
  async function perfectionist() {
675
680
  return [
676
681
  {
677
- name: "eslint:perfectionist:setup",
682
+ name: "eslint/perfectionist/setup",
678
683
  plugins: {
679
684
  perfectionist: default7
680
685
  }
@@ -716,7 +721,7 @@ async function stylistic(options = {}) {
716
721
  });
717
722
  return [
718
723
  {
719
- name: "eslint:stylistic",
724
+ name: "eslint/stylistic/rules",
720
725
  plugins: {
721
726
  antfu: default2,
722
727
  style: pluginStylistic
@@ -744,17 +749,21 @@ async function stylistic(options = {}) {
744
749
  // src/configs/formatters.ts
745
750
  async function formatters(options = {}, stylistic2 = {}) {
746
751
  const defaultIndent = 4;
747
- await ensurePackages([
748
- "eslint-plugin-format"
749
- ]);
750
752
  if (options === true) {
753
+ const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
751
754
  options = {
752
755
  css: false,
753
756
  graphql: true,
754
757
  html: true,
755
- markdown: true
758
+ markdown: true,
759
+ svg: isPrettierPluginXmlInScope,
760
+ xml: isPrettierPluginXmlInScope
756
761
  };
757
762
  }
763
+ await ensurePackages([
764
+ "eslint-plugin-format",
765
+ options.xml || options.svg ? "@prettier/plugin-xml" : void 0
766
+ ]);
758
767
  const {
759
768
  indent,
760
769
  quotes,
@@ -766,6 +775,7 @@ async function formatters(options = {}, stylistic2 = {}) {
766
775
  const prettierOptions = Object.assign(
767
776
  {
768
777
  endOfLine: "lf",
778
+ printWidth: 200,
769
779
  semi,
770
780
  singleQuote: quotes === "single",
771
781
  tabWidth: typeof indent === "number" ? indent : defaultIndent,
@@ -774,6 +784,12 @@ async function formatters(options = {}, stylistic2 = {}) {
774
784
  },
775
785
  options.prettierOptions || {}
776
786
  );
787
+ const prettierXmlOptions = {
788
+ xmlQuoteAttributes: "double",
789
+ xmlSelfClosingSpace: true,
790
+ xmlSortAttributesByKey: false,
791
+ xmlWhitespaceSensitivity: "ignore"
792
+ };
777
793
  const dprintOptions = Object.assign(
778
794
  {
779
795
  indentWidth: typeof indent === "number" ? indent : defaultIndent,
@@ -785,7 +801,7 @@ async function formatters(options = {}, stylistic2 = {}) {
785
801
  const pluginFormat = await interopDefault(import("eslint-plugin-format"));
786
802
  const configs2 = [
787
803
  {
788
- name: "eslint:formatters:setup",
804
+ name: "eslint/formatters/setup",
789
805
  plugins: {
790
806
  format: pluginFormat
791
807
  }
@@ -798,7 +814,7 @@ async function formatters(options = {}, stylistic2 = {}) {
798
814
  languageOptions: {
799
815
  parser: parserPlain2
800
816
  },
801
- name: "eslint:formatter:css",
817
+ name: "eslint/formatters/css",
802
818
  rules: {
803
819
  "format/prettier": [
804
820
  "error",
@@ -814,7 +830,7 @@ async function formatters(options = {}, stylistic2 = {}) {
814
830
  languageOptions: {
815
831
  parser: parserPlain2
816
832
  },
817
- name: "eslint:formatter:scss",
833
+ name: "eslint/formatters/scss",
818
834
  rules: {
819
835
  "format/prettier": [
820
836
  "error",
@@ -830,7 +846,7 @@ async function formatters(options = {}, stylistic2 = {}) {
830
846
  languageOptions: {
831
847
  parser: parserPlain2
832
848
  },
833
- name: "eslint:formatter:less",
849
+ name: "eslint/formatters/less",
834
850
  rules: {
835
851
  "format/prettier": [
836
852
  "error",
@@ -849,7 +865,7 @@ async function formatters(options = {}, stylistic2 = {}) {
849
865
  languageOptions: {
850
866
  parser: parserPlain2
851
867
  },
852
- name: "eslint:formatter:html",
868
+ name: "eslint/formatters/html",
853
869
  rules: {
854
870
  "format/prettier": [
855
871
  "error",
@@ -861,6 +877,28 @@ async function formatters(options = {}, stylistic2 = {}) {
861
877
  }
862
878
  });
863
879
  }
880
+ if (options.svg) {
881
+ configs2.push({
882
+ files: [GLOB_SVG],
883
+ languageOptions: {
884
+ parser: parserPlain2
885
+ },
886
+ name: "eslint/formatters/svg",
887
+ rules: {
888
+ "format/prettier": [
889
+ "error",
890
+ {
891
+ ...prettierXmlOptions,
892
+ ...prettierOptions,
893
+ parser: "xml",
894
+ plugins: [
895
+ "@prettier/plugin-xml"
896
+ ]
897
+ }
898
+ ]
899
+ }
900
+ });
901
+ }
864
902
  if (options.markdown) {
865
903
  const formater = options.markdown === true ? "prettier" : options.markdown;
866
904
  configs2.push({
@@ -868,12 +906,11 @@ async function formatters(options = {}, stylistic2 = {}) {
868
906
  languageOptions: {
869
907
  parser: parserPlain2
870
908
  },
871
- name: "eslint:formatter:markdown",
909
+ name: "eslint/formatters/markdown",
872
910
  rules: {
873
911
  [`format/${formater}`]: [
874
912
  "error",
875
913
  formater === "prettier" ? {
876
- printWidth: 200,
877
914
  ...prettierOptions,
878
915
  embeddedLanguageFormatting: "off",
879
916
  parser: "markdown"
@@ -891,7 +928,7 @@ async function formatters(options = {}, stylistic2 = {}) {
891
928
  languageOptions: {
892
929
  parser: parserPlain2
893
930
  },
894
- name: "eslint:formatter:graphql",
931
+ name: "eslint/formatters/graphql",
895
932
  rules: {
896
933
  "format/prettier": [
897
934
  "error",
@@ -910,7 +947,7 @@ async function formatters(options = {}, stylistic2 = {}) {
910
947
  async function node() {
911
948
  return [
912
949
  {
913
- name: "eslint:node:rules",
950
+ name: "eslint/node/rules",
914
951
  plugins: {
915
952
  node: default4
916
953
  },
@@ -966,7 +1003,7 @@ async function react(options = {}) {
966
1003
  const plugins = pluginReact.configs.all.plugins;
967
1004
  return [
968
1005
  {
969
- name: "eslint:react:setup",
1006
+ name: "eslint/react/setup",
970
1007
  plugins: {
971
1008
  "react": plugins["@eslint-react"],
972
1009
  "react-dom": plugins["@eslint-react/dom"],
@@ -987,7 +1024,7 @@ async function react(options = {}) {
987
1024
  ...isTypeAware ? { project: tsconfigPath } : {}
988
1025
  }
989
1026
  },
990
- name: "eslint:react:rules",
1027
+ name: "eslint/react/rules",
991
1028
  rules: {
992
1029
  // recommended rules from @eslint-react/dom
993
1030
  "react-dom/no-children-in-void-dom-elements": "warn",
@@ -1091,7 +1128,7 @@ async function sortPackageJson() {
1091
1128
  return [
1092
1129
  {
1093
1130
  files: ["**/package.json"],
1094
- name: "eslint:sort-package-json",
1131
+ name: "eslint/sort/package-json",
1095
1132
  rules: {
1096
1133
  "jsonc/sort-array-values": [
1097
1134
  "error",
@@ -1193,7 +1230,7 @@ function sortTsconfig() {
1193
1230
  return [
1194
1231
  {
1195
1232
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1196
- name: "eslint:sort-tsconfig",
1233
+ name: "eslint/sort/tsconfig",
1197
1234
  rules: {
1198
1235
  "jsonc/sort-keys": [
1199
1236
  "error",
@@ -1326,13 +1363,13 @@ async function test(options = {}) {
1326
1363
  pluginVitest,
1327
1364
  pluginNoOnlyTests
1328
1365
  ] = await Promise.all([
1329
- interopDefault(import("eslint-plugin-vitest")),
1366
+ interopDefault(import("@vitest/eslint-plugin")),
1330
1367
  // @ts-expect-error missing types
1331
1368
  interopDefault(import("eslint-plugin-no-only-tests"))
1332
1369
  ]);
1333
1370
  return [
1334
1371
  {
1335
- name: "eslint:test:setup",
1372
+ name: "eslint/test/setup",
1336
1373
  plugins: {
1337
1374
  test: {
1338
1375
  ...pluginVitest,
@@ -1346,7 +1383,7 @@ async function test(options = {}) {
1346
1383
  },
1347
1384
  {
1348
1385
  files,
1349
- name: "eslint:test:rules",
1386
+ name: "eslint/test/rules",
1350
1387
  rules: {
1351
1388
  "node/prefer-global/process": "off",
1352
1389
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
@@ -1375,6 +1412,9 @@ async function typescript(options = {}) {
1375
1412
  GLOB_SRC,
1376
1413
  ...componentExts.map((ext) => `**/*.${ext}`)
1377
1414
  ];
1415
+ const ignoresTypeAware = options.ignoresTypeAware ?? [
1416
+ `${GLOB_MARKDOWN}/**`
1417
+ ];
1378
1418
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1379
1419
  const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1380
1420
  const isTypeAware = !!tsconfigPath;
@@ -1427,13 +1467,13 @@ async function typescript(options = {}) {
1427
1467
  ...parserOptions
1428
1468
  }
1429
1469
  },
1430
- name: `eslint:typescript:${typeAware ? "type-aware-parser" : "parser"}`
1470
+ name: `eslint/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1431
1471
  };
1432
1472
  }
1433
1473
  return [
1434
1474
  {
1435
1475
  // Install the plugins without globs, so they can be configured separately.
1436
- name: "eslint:typescript:setup",
1476
+ name: "eslint/typescript/setup",
1437
1477
  plugins: {
1438
1478
  antfu: default2,
1439
1479
  ts: pluginTs
@@ -1441,14 +1481,14 @@ async function typescript(options = {}) {
1441
1481
  },
1442
1482
  // assign type-aware parser for type-aware files and type-unaware parser for the rest
1443
1483
  ...isTypeAware ? [
1444
- makeParser(true, filesTypeAware),
1445
- makeParser(false, files, filesTypeAware)
1484
+ makeParser(false, files),
1485
+ makeParser(true, filesTypeAware, ignoresTypeAware)
1446
1486
  ] : [
1447
1487
  makeParser(false, files)
1448
1488
  ],
1449
1489
  {
1450
1490
  files,
1451
- name: "eslint:typescript:rules",
1491
+ name: "eslint/typescript/rules",
1452
1492
  rules: {
1453
1493
  ...renameRules(
1454
1494
  pluginTs.configs["eslint-recommended"].overrides[0].rules,
@@ -1499,7 +1539,8 @@ async function typescript(options = {}) {
1499
1539
  },
1500
1540
  ...isTypeAware ? [{
1501
1541
  files: filesTypeAware,
1502
- name: "eslint:typescript:rules-type-aware",
1542
+ ignores: ignoresTypeAware,
1543
+ name: "eslint/typescript/rules-type-aware",
1503
1544
  rules: {
1504
1545
  ...typeAwareRules,
1505
1546
  ...overrides
@@ -1507,7 +1548,7 @@ async function typescript(options = {}) {
1507
1548
  }] : [],
1508
1549
  {
1509
1550
  files: ["**/*.d.?([cm])ts"],
1510
- name: "eslint:typescript:disables:dts",
1551
+ name: "eslint/typescript/disables/dts",
1511
1552
  rules: {
1512
1553
  "eslint-comments/no-unlimited-disable": "off",
1513
1554
  "import/no-duplicates": "off",
@@ -1517,14 +1558,14 @@ async function typescript(options = {}) {
1517
1558
  },
1518
1559
  {
1519
1560
  files: ["**/*.{test,spec}.ts?(x)"],
1520
- name: "eslint:typescript:disables:test",
1561
+ name: "eslint/typescript/disables/test",
1521
1562
  rules: {
1522
1563
  "no-unused-expressions": "off"
1523
1564
  }
1524
1565
  },
1525
1566
  {
1526
1567
  files: ["**/*.js", "**/*.cjs"],
1527
- name: "eslint:typescript:disables:cjs",
1568
+ name: "eslint/typescript/disables/cjs",
1528
1569
  rules: {
1529
1570
  "ts/no-require-imports": "off",
1530
1571
  "ts/no-var-requires": "off"
@@ -1534,40 +1575,32 @@ async function typescript(options = {}) {
1534
1575
  }
1535
1576
 
1536
1577
  // src/configs/unicorn.ts
1537
- async function unicorn() {
1578
+ async function unicorn(options = {}) {
1538
1579
  return [
1539
1580
  {
1540
- name: "eslint:unicorn",
1581
+ name: "eslint/unicorn/rules",
1541
1582
  plugins: {
1542
1583
  unicorn: default5
1543
1584
  },
1544
1585
  rules: {
1545
- // Pass error message when throwing errors
1546
- "unicorn/error-message": "error",
1547
- // Uppercase regex escapes
1548
- "unicorn/escape-case": "error",
1549
- // Array.isArray instead of instanceof
1550
- "unicorn/no-instanceof-array": "error",
1551
- // Ban `new Array` as `Array` constructor's params are ambiguous
1552
- "unicorn/no-new-array": "error",
1553
- // Prevent deprecated `new Buffer()`
1554
- "unicorn/no-new-buffer": "error",
1555
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1556
- "unicorn/number-literal-case": "error",
1557
- // textContent instead of innerText
1558
- "unicorn/prefer-dom-node-text-content": "error",
1559
- // includes over indexOf when checking for existence
1560
- "unicorn/prefer-includes": "error",
1561
- // Prefer using the node: protocol
1562
- "unicorn/prefer-node-protocol": "error",
1563
- // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1564
- "unicorn/prefer-number-properties": "error",
1565
- // String methods startsWith/endsWith instead of more complicated stuff
1566
- "unicorn/prefer-string-starts-ends-with": "error",
1567
- // Enforce throwing type error when throwing error while checking typeof
1568
- "unicorn/prefer-type-error": "error",
1569
- // Use new when throwing error
1570
- "unicorn/throw-new-error": "error"
1586
+ ...options.allRecommended ? default5.configs["flat/recommended"].rules : {
1587
+ "unicorn/consistent-empty-array-spread": "error",
1588
+ "unicorn/consistent-function-scoping": "error",
1589
+ "unicorn/error-message": "error",
1590
+ "unicorn/escape-case": "error",
1591
+ "unicorn/new-for-builtins": "error",
1592
+ "unicorn/no-instanceof-array": "error",
1593
+ "unicorn/no-new-array": "error",
1594
+ "unicorn/no-new-buffer": "error",
1595
+ "unicorn/number-literal-case": "error",
1596
+ "unicorn/prefer-dom-node-text-content": "error",
1597
+ "unicorn/prefer-includes": "error",
1598
+ "unicorn/prefer-node-protocol": "error",
1599
+ "unicorn/prefer-number-properties": "error",
1600
+ "unicorn/prefer-string-starts-ends-with": "error",
1601
+ "unicorn/prefer-type-error": "error",
1602
+ "unicorn/throw-new-error": "error"
1603
+ }
1571
1604
  }
1572
1605
  }
1573
1606
  ];
@@ -1590,7 +1623,7 @@ async function unocss(options = {}) {
1590
1623
  ]);
1591
1624
  return [
1592
1625
  {
1593
- name: "eslint:unocss",
1626
+ name: "eslint/unocss/rules",
1594
1627
  plugins: {
1595
1628
  unocss: pluginUnoCSS
1596
1629
  },
@@ -1655,7 +1688,7 @@ async function vue(options = {}) {
1655
1688
  watchEffect: "readonly"
1656
1689
  }
1657
1690
  },
1658
- name: "eslint:vue:setup",
1691
+ name: "eslint/vue/setup",
1659
1692
  plugins: {
1660
1693
  vue: pluginVue
1661
1694
  }
@@ -1673,7 +1706,7 @@ async function vue(options = {}) {
1673
1706
  sourceType: "module"
1674
1707
  }
1675
1708
  },
1676
- name: "eslint:vue:rules",
1709
+ name: "eslint/vue/rules",
1677
1710
  processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors2([
1678
1711
  pluginVue.processors[".vue"],
1679
1712
  processorVueBlocks({
@@ -1802,7 +1835,7 @@ async function yaml(options = {}) {
1802
1835
  ]);
1803
1836
  return [
1804
1837
  {
1805
- name: "eslint:yaml:setup",
1838
+ name: "eslint/yaml/setup",
1806
1839
  plugins: {
1807
1840
  yaml: pluginYaml
1808
1841
  }
@@ -1812,7 +1845,7 @@ async function yaml(options = {}) {
1812
1845
  languageOptions: {
1813
1846
  parser: parserYaml
1814
1847
  },
1815
- name: "eslint:yaml:rules",
1848
+ name: "eslint/yaml/rules",
1816
1849
  rules: {
1817
1850
  "style/spaced-comment": "off",
1818
1851
  "yaml/block-mapping": "error",
@@ -1860,7 +1893,7 @@ async function toml(options = {}) {
1860
1893
  ]);
1861
1894
  return [
1862
1895
  {
1863
- name: "eslint:toml:setup",
1896
+ name: "eslint/toml/setup",
1864
1897
  plugins: {
1865
1898
  toml: pluginToml
1866
1899
  }
@@ -1870,7 +1903,7 @@ async function toml(options = {}) {
1870
1903
  languageOptions: {
1871
1904
  parser: parserToml
1872
1905
  },
1873
- name: "eslint:toml:rules",
1906
+ name: "eslint/toml/rules",
1874
1907
  rules: {
1875
1908
  "style/spaced-comment": "off",
1876
1909
  "toml/comma-style": "error",
@@ -1903,8 +1936,6 @@ async function toml(options = {}) {
1903
1936
  // src/factory.ts
1904
1937
  var flatConfigProps = [
1905
1938
  "name",
1906
- "files",
1907
- "ignores",
1908
1939
  "languageOptions",
1909
1940
  "linterOptions",
1910
1941
  "processor",
@@ -1939,15 +1970,21 @@ function lincy(options = {}, ...userConfigs) {
1939
1970
  autoRenamePlugins = true,
1940
1971
  componentExts = [],
1941
1972
  gitignore: enableGitignore = true,
1942
- isInEditor = isInEditorEnv(),
1943
1973
  jsx: enableJsx = true,
1944
1974
  overrides = {},
1945
1975
  react: enableReact = ReactPackages.some((i) => isPackageExists3(i)),
1946
1976
  regexp: enableRegexp = true,
1947
1977
  typescript: enableTypeScript = isPackageExists3("typescript"),
1978
+ unicorn: enableUnicorn = true,
1948
1979
  unocss: enableUnoCSS = false,
1949
1980
  vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
1950
1981
  } = options;
1982
+ let isInEditor = options.isInEditor;
1983
+ if (isInEditor == null) {
1984
+ isInEditor = isInEditorEnv();
1985
+ if (isInEditor)
1986
+ console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
1987
+ }
1951
1988
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1952
1989
  const tsconfigPath = typeof enableTypeScript !== "boolean" && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : void 0;
1953
1990
  if (stylisticOptions) {
@@ -1958,9 +1995,15 @@ function lincy(options = {}, ...userConfigs) {
1958
1995
  const configs2 = [];
1959
1996
  if (enableGitignore) {
1960
1997
  if (typeof enableGitignore !== "boolean") {
1961
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1998
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
1999
+ name: "eslint/gitignore",
2000
+ ...enableGitignore
2001
+ })]));
1962
2002
  } else {
1963
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
2003
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2004
+ name: "eslint/gitignore",
2005
+ strict: false
2006
+ })]));
1964
2007
  }
1965
2008
  }
1966
2009
  configs2.push(
@@ -1979,10 +2022,12 @@ function lincy(options = {}, ...userConfigs) {
1979
2022
  imports({
1980
2023
  stylistic: stylisticOptions
1981
2024
  }),
1982
- unicorn(),
1983
2025
  // Optional plugins (installed but not enabled by default)
1984
2026
  perfectionist()
1985
2027
  );
2028
+ if (enableUnicorn) {
2029
+ configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
2030
+ }
1986
2031
  if (enableVue) {
1987
2032
  componentExts.push("vue");
1988
2033
  }
@@ -2075,6 +2120,9 @@ function lincy(options = {}, ...userConfigs) {
2075
2120
  typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2076
2121
  ));
2077
2122
  }
2123
+ if ("files" in options) {
2124
+ throw new Error("[@lincy/eslint-config] \u7B2C\u4E00\u4E2A\u53C2\u6570\u4E0D\u5E94\u5305\u542B\u201Cfiles\u201D\u5C5E\u6027\uFF0C\u56E0\u4E3A\u9009\u9879\u5E94\u8BE5\u662F\u5168\u5C40\u7684\u3002\u8BF7\u5C06\u5176\u653E\u5728\u7B2C\u4E8C\u4E2A\u6216\u66F4\u540E\u9762\u7684\u914D\u7F6E\u4E2D\u3002");
2125
+ }
2078
2126
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2079
2127
  if (key in options) {
2080
2128
  acc[key] = options[key];
@@ -2118,11 +2166,13 @@ export {
2118
2166
  GLOB_SRC_EXT,
2119
2167
  GLOB_STYLE,
2120
2168
  GLOB_SVELTE,
2169
+ GLOB_SVG,
2121
2170
  GLOB_TESTS,
2122
2171
  GLOB_TOML,
2123
2172
  GLOB_TS,
2124
2173
  GLOB_TSX,
2125
2174
  GLOB_VUE,
2175
+ GLOB_XML,
2126
2176
  GLOB_YAML,
2127
2177
  StylisticConfigDefaults,
2128
2178
  combine,
@@ -2135,6 +2185,8 @@ export {
2135
2185
  imports,
2136
2186
  interopDefault,
2137
2187
  isInEditorEnv,
2188
+ isInGitHooksOrLintStaged,
2189
+ isPackageInScope,
2138
2190
  javascript,
2139
2191
  jsdoc,
2140
2192
  jsonc,