@lincy/eslint-config 4.6.3 → 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
@@ -1,12 +1,10 @@
1
1
  // src/factory.ts
2
- import process3 from "node:process";
3
- import fs from "node:fs";
4
2
  import { isPackageExists as isPackageExists3 } from "local-pkg";
5
3
  import { FlatConfigComposer } from "eslint-flat-config-utils";
6
4
 
7
5
  // src/plugins.ts
8
6
  import { default as default2 } from "eslint-plugin-antfu";
9
- import { default as default3 } from "eslint-plugin-eslint-comments";
7
+ import { default as default3 } from "@eslint-community/eslint-plugin-eslint-comments";
10
8
  import * as pluginImport from "eslint-plugin-import-x";
11
9
  import { default as default4 } from "eslint-plugin-n";
12
10
  import { default as default5 } from "eslint-plugin-unicorn";
@@ -17,7 +15,7 @@ import { default as default7 } from "eslint-plugin-perfectionist";
17
15
  async function comments() {
18
16
  return [
19
17
  {
20
- name: "eslint:comments",
18
+ name: "eslint/comments/rules",
21
19
  plugins: {
22
20
  "eslint-comments": default3
23
21
  },
@@ -52,6 +50,8 @@ var GLOB_SVELTE = "**/*.svelte";
52
50
  var GLOB_VUE = "**/*.vue";
53
51
  var GLOB_YAML = "**/*.y?(a)ml";
54
52
  var GLOB_TOML = "**/*.toml";
53
+ var GLOB_XML = "**/*.xml";
54
+ var GLOB_SVG = "**/*.svg";
55
55
  var GLOB_HTML = "**/*.htm?(l)";
56
56
  var GLOB_GRAPHQL = "**/*.{g,graph}ql";
57
57
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
@@ -93,6 +93,7 @@ var GLOB_EXCLUDE = [
93
93
  "**/.output",
94
94
  "**/.vite-inspect",
95
95
  "**/.yarn",
96
+ "**/vite.config.*.timestamp-*",
96
97
  "**/CHANGELOG*.md",
97
98
  "**/*.min.*",
98
99
  "**/LICENSE*",
@@ -111,7 +112,8 @@ async function ignores(options = {}) {
111
112
  ignores: [
112
113
  ...GLOB_EXCLUDE,
113
114
  ...ignores2
114
- ]
115
+ ],
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,7 +188,10 @@ async function javascript(options = {}) {
186
188
  linterOptions: {
187
189
  reportUnusedDisableDirectives: true
188
190
  },
189
- name: "eslint:javascript:rules",
191
+ name: "eslint/javascript/setup"
192
+ },
193
+ {
194
+ name: "eslint/javascript/rules",
190
195
  plugins: {
191
196
  "antfu": default2,
192
197
  "unused-imports": default6
@@ -265,9 +270,6 @@ async function javascript(options = {}) {
265
270
  ],
266
271
  "no-restricted-syntax": [
267
272
  "error",
268
- "DebuggerStatement",
269
- "LabeledStatement",
270
- "WithStatement",
271
273
  "TSEnumDeclaration[const=true]",
272
274
  "TSExportAssignment"
273
275
  ],
@@ -370,7 +372,7 @@ async function javascript(options = {}) {
370
372
  },
371
373
  {
372
374
  files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
373
- name: "eslint:scripts:disables",
375
+ name: "eslint/scripts/disables",
374
376
  rules: {
375
377
  "no-console": "off"
376
378
  }
@@ -380,7 +382,10 @@ async function javascript(options = {}) {
380
382
 
381
383
  // src/utils.ts
382
384
  import process from "node:process";
385
+ import { fileURLToPath } from "node:url";
383
386
  import { isPackageExists } from "local-pkg";
387
+ var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
388
+ var isCwdInScope = isPackageExists("@antfu/eslint-config");
384
389
  async function combine(...configs2) {
385
390
  const resolved = await Promise.all(configs2);
386
391
  return resolved.flat();
@@ -423,25 +428,31 @@ async function interopDefault(m) {
423
428
  const resolved = await m;
424
429
  return resolved.default || resolved;
425
430
  }
431
+ function isPackageInScope(name) {
432
+ return isPackageExists(name, { paths: [scopeUrl] });
433
+ }
426
434
  async function ensurePackages(packages) {
427
- if (process.stdout.isTTY === false) {
435
+ if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
428
436
  return;
429
- }
430
- const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
431
- if (nonExistingPackages.length === 0) {
437
+ const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
438
+ if (nonExistingPackages.length === 0)
432
439
  return;
433
- }
434
- const { default: prompts } = await import("prompts");
435
- const { result } = await prompts([
436
- {
437
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
438
- name: "result",
439
- type: "confirm"
440
- }
441
- ]);
442
- 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)
443
445
  await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
444
- }
446
+ }
447
+ function isInEditorEnv() {
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"));
445
456
  }
446
457
 
447
458
  // src/configs/jsdoc.ts
@@ -451,7 +462,7 @@ async function jsdoc(options = {}) {
451
462
  } = options;
452
463
  return [
453
464
  {
454
- name: "eslint:jsdoc:rules",
465
+ name: "eslint/jsdoc/rules",
455
466
  plugins: {
456
467
  jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
457
468
  },
@@ -496,7 +507,7 @@ async function jsonc(options = {}) {
496
507
  ]);
497
508
  return [
498
509
  {
499
- name: "eslint:jsonc:setup",
510
+ name: "eslint/jsonc/setup",
500
511
  plugins: {
501
512
  jsonc: pluginJsonc
502
513
  }
@@ -506,7 +517,7 @@ async function jsonc(options = {}) {
506
517
  languageOptions: {
507
518
  parser: parserJsonc
508
519
  },
509
- name: "eslint:jsonc:rules",
520
+ name: "eslint/jsonc/rules",
510
521
  rules: {
511
522
  "jsonc/no-bigint-literals": "error",
512
523
  "jsonc/no-binary-expression": "error",
@@ -552,6 +563,23 @@ async function jsonc(options = {}) {
552
563
  ];
553
564
  }
554
565
 
566
+ // src/configs/jsx.ts
567
+ async function jsx() {
568
+ return [
569
+ {
570
+ files: [GLOB_JSX, GLOB_TSX],
571
+ languageOptions: {
572
+ parserOptions: {
573
+ ecmaFeatures: {
574
+ jsx: true
575
+ }
576
+ }
577
+ },
578
+ name: "eslint/jsx/setup"
579
+ }
580
+ ];
581
+ }
582
+
555
583
  // src/configs/markdown.ts
556
584
  import * as parserPlain from "eslint-parser-plain";
557
585
  import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
@@ -564,7 +592,7 @@ async function markdown(options = {}) {
564
592
  const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
565
593
  return [
566
594
  {
567
- name: "eslint:markdown:setup",
595
+ name: "eslint/markdown/setup",
568
596
  plugins: {
569
597
  markdown: markdown2
570
598
  }
@@ -572,7 +600,7 @@ async function markdown(options = {}) {
572
600
  {
573
601
  files,
574
602
  ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
575
- name: "eslint:markdown:processor",
603
+ name: "eslint/markdown/processor",
576
604
  processor: mergeProcessors([
577
605
  markdown2.processors.markdown,
578
606
  processorPassThrough
@@ -583,7 +611,7 @@ async function markdown(options = {}) {
583
611
  languageOptions: {
584
612
  parser: parserPlain
585
613
  },
586
- name: "eslint:markdown:parser"
614
+ name: "eslint/markdown/parser"
587
615
  },
588
616
  {
589
617
  files: [
@@ -597,7 +625,7 @@ async function markdown(options = {}) {
597
625
  }
598
626
  }
599
627
  },
600
- name: "eslint:markdown:disables",
628
+ name: "eslint/markdown/disables",
601
629
  rules: {
602
630
  "import/newline-after-import": "off",
603
631
  "no-alert": "off",
@@ -616,6 +644,7 @@ async function markdown(options = {}) {
616
644
  "ts/no-namespace": "off",
617
645
  "ts/no-redeclare": "off",
618
646
  "ts/no-require-imports": "off",
647
+ "ts/no-unused-expressions": "off",
619
648
  "ts/no-unused-vars": "off",
620
649
  "ts/no-use-before-define": "off",
621
650
  "ts/no-var-requires": "off",
@@ -650,7 +679,7 @@ async function markdown(options = {}) {
650
679
  async function perfectionist() {
651
680
  return [
652
681
  {
653
- name: "eslint:perfectionist:setup",
682
+ name: "eslint/perfectionist/setup",
654
683
  plugins: {
655
684
  perfectionist: default7
656
685
  }
@@ -676,7 +705,7 @@ async function stylistic(options = {}) {
676
705
  } = options;
677
706
  const {
678
707
  indent,
679
- jsx,
708
+ jsx: jsx2,
680
709
  lessOpinionated,
681
710
  quotes,
682
711
  semi
@@ -685,14 +714,14 @@ async function stylistic(options = {}) {
685
714
  const config = pluginStylistic.configs.customize({
686
715
  flat: true,
687
716
  indent,
688
- jsx,
717
+ jsx: jsx2,
689
718
  pluginName: "style",
690
719
  quotes,
691
720
  semi
692
721
  });
693
722
  return [
694
723
  {
695
- name: "eslint:stylistic",
724
+ name: "eslint/stylistic/rules",
696
725
  plugins: {
697
726
  antfu: default2,
698
727
  style: pluginStylistic
@@ -720,17 +749,21 @@ async function stylistic(options = {}) {
720
749
  // src/configs/formatters.ts
721
750
  async function formatters(options = {}, stylistic2 = {}) {
722
751
  const defaultIndent = 4;
723
- await ensurePackages([
724
- "eslint-plugin-format"
725
- ]);
726
752
  if (options === true) {
753
+ const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
727
754
  options = {
728
755
  css: false,
729
756
  graphql: true,
730
757
  html: true,
731
- markdown: true
758
+ markdown: true,
759
+ svg: isPrettierPluginXmlInScope,
760
+ xml: isPrettierPluginXmlInScope
732
761
  };
733
762
  }
763
+ await ensurePackages([
764
+ "eslint-plugin-format",
765
+ options.xml || options.svg ? "@prettier/plugin-xml" : void 0
766
+ ]);
734
767
  const {
735
768
  indent,
736
769
  quotes,
@@ -742,6 +775,7 @@ async function formatters(options = {}, stylistic2 = {}) {
742
775
  const prettierOptions = Object.assign(
743
776
  {
744
777
  endOfLine: "lf",
778
+ printWidth: 200,
745
779
  semi,
746
780
  singleQuote: quotes === "single",
747
781
  tabWidth: typeof indent === "number" ? indent : defaultIndent,
@@ -750,6 +784,12 @@ async function formatters(options = {}, stylistic2 = {}) {
750
784
  },
751
785
  options.prettierOptions || {}
752
786
  );
787
+ const prettierXmlOptions = {
788
+ xmlQuoteAttributes: "double",
789
+ xmlSelfClosingSpace: true,
790
+ xmlSortAttributesByKey: false,
791
+ xmlWhitespaceSensitivity: "ignore"
792
+ };
753
793
  const dprintOptions = Object.assign(
754
794
  {
755
795
  indentWidth: typeof indent === "number" ? indent : defaultIndent,
@@ -761,7 +801,7 @@ async function formatters(options = {}, stylistic2 = {}) {
761
801
  const pluginFormat = await interopDefault(import("eslint-plugin-format"));
762
802
  const configs2 = [
763
803
  {
764
- name: "eslint:formatters:setup",
804
+ name: "eslint/formatters/setup",
765
805
  plugins: {
766
806
  format: pluginFormat
767
807
  }
@@ -774,7 +814,7 @@ async function formatters(options = {}, stylistic2 = {}) {
774
814
  languageOptions: {
775
815
  parser: parserPlain2
776
816
  },
777
- name: "eslint:formatter:css",
817
+ name: "eslint/formatters/css",
778
818
  rules: {
779
819
  "format/prettier": [
780
820
  "error",
@@ -790,7 +830,7 @@ async function formatters(options = {}, stylistic2 = {}) {
790
830
  languageOptions: {
791
831
  parser: parserPlain2
792
832
  },
793
- name: "eslint:formatter:scss",
833
+ name: "eslint/formatters/scss",
794
834
  rules: {
795
835
  "format/prettier": [
796
836
  "error",
@@ -806,7 +846,7 @@ async function formatters(options = {}, stylistic2 = {}) {
806
846
  languageOptions: {
807
847
  parser: parserPlain2
808
848
  },
809
- name: "eslint:formatter:less",
849
+ name: "eslint/formatters/less",
810
850
  rules: {
811
851
  "format/prettier": [
812
852
  "error",
@@ -825,7 +865,7 @@ async function formatters(options = {}, stylistic2 = {}) {
825
865
  languageOptions: {
826
866
  parser: parserPlain2
827
867
  },
828
- name: "eslint:formatter:html",
868
+ name: "eslint/formatters/html",
829
869
  rules: {
830
870
  "format/prettier": [
831
871
  "error",
@@ -837,6 +877,28 @@ async function formatters(options = {}, stylistic2 = {}) {
837
877
  }
838
878
  });
839
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
+ }
840
902
  if (options.markdown) {
841
903
  const formater = options.markdown === true ? "prettier" : options.markdown;
842
904
  configs2.push({
@@ -844,12 +906,11 @@ async function formatters(options = {}, stylistic2 = {}) {
844
906
  languageOptions: {
845
907
  parser: parserPlain2
846
908
  },
847
- name: "eslint:formatter:markdown",
909
+ name: "eslint/formatters/markdown",
848
910
  rules: {
849
911
  [`format/${formater}`]: [
850
912
  "error",
851
913
  formater === "prettier" ? {
852
- printWidth: 200,
853
914
  ...prettierOptions,
854
915
  embeddedLanguageFormatting: "off",
855
916
  parser: "markdown"
@@ -867,7 +928,7 @@ async function formatters(options = {}, stylistic2 = {}) {
867
928
  languageOptions: {
868
929
  parser: parserPlain2
869
930
  },
870
- name: "eslint:formatter:graphql",
931
+ name: "eslint/formatters/graphql",
871
932
  rules: {
872
933
  "format/prettier": [
873
934
  "error",
@@ -886,7 +947,7 @@ async function formatters(options = {}, stylistic2 = {}) {
886
947
  async function node() {
887
948
  return [
888
949
  {
889
- name: "eslint:node:rules",
950
+ name: "eslint/node/rules",
890
951
  plugins: {
891
952
  node: default4
892
953
  },
@@ -912,7 +973,7 @@ var ReactRefreshAllowConstantExportPackages = [
912
973
  async function react(options = {}) {
913
974
  const {
914
975
  files = [GLOB_JSX, GLOB_TSX],
915
- jsx = true,
976
+ jsx: jsx2 = true,
916
977
  overrides = {},
917
978
  version = "detect"
918
979
  } = options;
@@ -942,7 +1003,7 @@ async function react(options = {}) {
942
1003
  const plugins = pluginReact.configs.all.plugins;
943
1004
  return [
944
1005
  {
945
- name: "eslint:react:setup",
1006
+ name: "eslint/react/setup",
946
1007
  plugins: {
947
1008
  "react": plugins["@eslint-react"],
948
1009
  "react-dom": plugins["@eslint-react/dom"],
@@ -958,12 +1019,12 @@ async function react(options = {}) {
958
1019
  parser: parserTs,
959
1020
  parserOptions: {
960
1021
  ecmaFeatures: {
961
- jsx
1022
+ jsx: jsx2
962
1023
  },
963
1024
  ...isTypeAware ? { project: tsconfigPath } : {}
964
1025
  }
965
1026
  },
966
- name: "eslint:react:rules",
1027
+ name: "eslint/react/rules",
967
1028
  rules: {
968
1029
  // recommended rules from @eslint-react/dom
969
1030
  "react-dom/no-children-in-void-dom-elements": "warn",
@@ -1067,7 +1128,7 @@ async function sortPackageJson() {
1067
1128
  return [
1068
1129
  {
1069
1130
  files: ["**/package.json"],
1070
- name: "eslint:sort-package-json",
1131
+ name: "eslint/sort/package-json",
1071
1132
  rules: {
1072
1133
  "jsonc/sort-array-values": [
1073
1134
  "error",
@@ -1088,6 +1149,7 @@ async function sortPackageJson() {
1088
1149
  "private",
1089
1150
  "packageManager",
1090
1151
  "description",
1152
+ "contributors",
1091
1153
  "author",
1092
1154
  "license",
1093
1155
  "funding",
@@ -1168,7 +1230,7 @@ function sortTsconfig() {
1168
1230
  return [
1169
1231
  {
1170
1232
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1171
- name: "eslint:sort-tsconfig",
1233
+ name: "eslint/sort/tsconfig",
1172
1234
  rules: {
1173
1235
  "jsonc/sort-keys": [
1174
1236
  "error",
@@ -1301,13 +1363,13 @@ async function test(options = {}) {
1301
1363
  pluginVitest,
1302
1364
  pluginNoOnlyTests
1303
1365
  ] = await Promise.all([
1304
- interopDefault(import("eslint-plugin-vitest")),
1366
+ interopDefault(import("@vitest/eslint-plugin")),
1305
1367
  // @ts-expect-error missing types
1306
1368
  interopDefault(import("eslint-plugin-no-only-tests"))
1307
1369
  ]);
1308
1370
  return [
1309
1371
  {
1310
- name: "eslint:test:setup",
1372
+ name: "eslint/test/setup",
1311
1373
  plugins: {
1312
1374
  test: {
1313
1375
  ...pluginVitest,
@@ -1321,7 +1383,7 @@ async function test(options = {}) {
1321
1383
  },
1322
1384
  {
1323
1385
  files,
1324
- name: "eslint:test:rules",
1386
+ name: "eslint/test/rules",
1325
1387
  rules: {
1326
1388
  "node/prefer-global/process": "off",
1327
1389
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
@@ -1330,6 +1392,7 @@ async function test(options = {}) {
1330
1392
  "test/no-only-tests": isInEditor ? "off" : "error",
1331
1393
  "test/prefer-hooks-in-order": "error",
1332
1394
  "test/prefer-lowercase-title": "error",
1395
+ "ts/explicit-function-return-type": "off",
1333
1396
  ...overrides
1334
1397
  }
1335
1398
  }
@@ -1342,19 +1405,22 @@ async function typescript(options = {}) {
1342
1405
  const {
1343
1406
  componentExts = [],
1344
1407
  overrides = {},
1345
- parserOptions = {}
1408
+ parserOptions = {},
1409
+ type = "app"
1346
1410
  } = options;
1347
1411
  const files = options.files ?? [
1348
1412
  GLOB_SRC,
1349
1413
  ...componentExts.map((ext) => `**/*.${ext}`)
1350
1414
  ];
1415
+ const ignoresTypeAware = options.ignoresTypeAware ?? [
1416
+ `${GLOB_MARKDOWN}/**`
1417
+ ];
1351
1418
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1352
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1419
+ const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1353
1420
  const isTypeAware = !!tsconfigPath;
1354
1421
  const typeAwareRules = {
1355
1422
  "dot-notation": "off",
1356
1423
  "no-implied-eval": "off",
1357
- "no-throw-literal": "off",
1358
1424
  "ts/await-thenable": "error",
1359
1425
  "ts/dot-notation": ["error", { allowKeywords: true }],
1360
1426
  "ts/no-floating-promises": "error",
@@ -1367,9 +1433,12 @@ async function typescript(options = {}) {
1367
1433
  "ts/no-unsafe-call": "error",
1368
1434
  "ts/no-unsafe-member-access": "error",
1369
1435
  "ts/no-unsafe-return": "error",
1436
+ "ts/promise-function-async": "error",
1370
1437
  "ts/restrict-plus-operands": "error",
1371
1438
  "ts/restrict-template-expressions": "error",
1372
- "ts/strict-boolean-expressions": "error",
1439
+ "ts/return-await": ["error", "in-try-catch"],
1440
+ "ts/strict-boolean-expressions": ["error", { allowNullableBoolean: true, allowNullableObject: true }],
1441
+ "ts/switch-exhaustiveness-check": "error",
1373
1442
  "ts/unbound-method": "error"
1374
1443
  };
1375
1444
  const [
@@ -1389,19 +1458,22 @@ async function typescript(options = {}) {
1389
1458
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1390
1459
  sourceType: "module",
1391
1460
  ...typeAware ? {
1392
- project: tsconfigPath,
1461
+ projectService: {
1462
+ allowDefaultProject: ["./*.js"],
1463
+ defaultProject: tsconfigPath
1464
+ },
1393
1465
  tsconfigRootDir: process2.cwd()
1394
1466
  } : {},
1395
1467
  ...parserOptions
1396
1468
  }
1397
1469
  },
1398
- name: `eslint:typescript:${typeAware ? "type-aware-parser" : "parser"}`
1470
+ name: `eslint/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1399
1471
  };
1400
1472
  }
1401
1473
  return [
1402
1474
  {
1403
1475
  // Install the plugins without globs, so they can be configured separately.
1404
- name: "eslint:typescript:setup",
1476
+ name: "eslint/typescript/setup",
1405
1477
  plugins: {
1406
1478
  antfu: default2,
1407
1479
  ts: pluginTs
@@ -1409,14 +1481,14 @@ async function typescript(options = {}) {
1409
1481
  },
1410
1482
  // assign type-aware parser for type-aware files and type-unaware parser for the rest
1411
1483
  ...isTypeAware ? [
1412
- makeParser(true, filesTypeAware),
1413
- makeParser(false, files, filesTypeAware)
1484
+ makeParser(false, files),
1485
+ makeParser(true, filesTypeAware, ignoresTypeAware)
1414
1486
  ] : [
1415
1487
  makeParser(false, files)
1416
1488
  ],
1417
1489
  {
1418
1490
  files,
1419
- name: "eslint:typescript:rules",
1491
+ name: "eslint/typescript/rules",
1420
1492
  rules: {
1421
1493
  ...renameRules(
1422
1494
  pluginTs.configs["eslint-recommended"].overrides[0].rules,
@@ -1432,12 +1504,15 @@ async function typescript(options = {}) {
1432
1504
  "no-use-before-define": "off",
1433
1505
  "no-useless-constructor": "off",
1434
1506
  "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1435
- "ts/ban-types": ["error", { types: { Function: false } }],
1436
1507
  "ts/consistent-type-definitions": ["error", "interface"],
1437
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1508
+ "ts/consistent-type-imports": ["error", {
1509
+ disallowTypeAnnotations: false,
1510
+ prefer: "type-imports"
1511
+ }],
1438
1512
  "ts/method-signature-style": ["error", "property"],
1439
1513
  "ts/no-dupe-class-members": "error",
1440
1514
  "ts/no-dynamic-delete": "off",
1515
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
1441
1516
  "ts/no-explicit-any": "off",
1442
1517
  "ts/no-extraneous-class": "off",
1443
1518
  "ts/no-import-type-side-effects": "error",
@@ -1449,23 +1524,31 @@ async function typescript(options = {}) {
1449
1524
  "ts/no-unused-vars": "off",
1450
1525
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1451
1526
  "ts/no-useless-constructor": "off",
1452
- "ts/prefer-ts-expect-error": "error",
1527
+ "ts/no-wrapper-object-types": "error",
1453
1528
  "ts/triple-slash-reference": "off",
1454
1529
  "ts/unified-signatures": "off",
1530
+ ...type === "lib" ? {
1531
+ "ts/explicit-function-return-type": ["error", {
1532
+ allowExpressions: true,
1533
+ allowHigherOrderFunctions: true,
1534
+ allowIIFEs: true
1535
+ }]
1536
+ } : {},
1455
1537
  ...overrides
1456
1538
  }
1457
1539
  },
1458
1540
  ...isTypeAware ? [{
1459
1541
  files: filesTypeAware,
1460
- name: "eslint:typescript:rules-type-aware",
1542
+ ignores: ignoresTypeAware,
1543
+ name: "eslint/typescript/rules-type-aware",
1461
1544
  rules: {
1462
- ...tsconfigPath ? typeAwareRules : {},
1545
+ ...typeAwareRules,
1463
1546
  ...overrides
1464
1547
  }
1465
1548
  }] : [],
1466
1549
  {
1467
- files: ["**/*.d.ts"],
1468
- name: "eslint:typescript:disables:dts",
1550
+ files: ["**/*.d.?([cm])ts"],
1551
+ name: "eslint/typescript/disables/dts",
1469
1552
  rules: {
1470
1553
  "eslint-comments/no-unlimited-disable": "off",
1471
1554
  "import/no-duplicates": "off",
@@ -1475,14 +1558,14 @@ async function typescript(options = {}) {
1475
1558
  },
1476
1559
  {
1477
1560
  files: ["**/*.{test,spec}.ts?(x)"],
1478
- name: "eslint:typescript:disables:test",
1561
+ name: "eslint/typescript/disables/test",
1479
1562
  rules: {
1480
1563
  "no-unused-expressions": "off"
1481
1564
  }
1482
1565
  },
1483
1566
  {
1484
1567
  files: ["**/*.js", "**/*.cjs"],
1485
- name: "eslint:typescript:disables:cjs",
1568
+ name: "eslint/typescript/disables/cjs",
1486
1569
  rules: {
1487
1570
  "ts/no-require-imports": "off",
1488
1571
  "ts/no-var-requires": "off"
@@ -1492,40 +1575,32 @@ async function typescript(options = {}) {
1492
1575
  }
1493
1576
 
1494
1577
  // src/configs/unicorn.ts
1495
- async function unicorn() {
1578
+ async function unicorn(options = {}) {
1496
1579
  return [
1497
1580
  {
1498
- name: "eslint:unicorn",
1581
+ name: "eslint/unicorn/rules",
1499
1582
  plugins: {
1500
1583
  unicorn: default5
1501
1584
  },
1502
1585
  rules: {
1503
- // Pass error message when throwing errors
1504
- "unicorn/error-message": "error",
1505
- // Uppercase regex escapes
1506
- "unicorn/escape-case": "error",
1507
- // Array.isArray instead of instanceof
1508
- "unicorn/no-instanceof-array": "error",
1509
- // Ban `new Array` as `Array` constructor's params are ambiguous
1510
- "unicorn/no-new-array": "error",
1511
- // Prevent deprecated `new Buffer()`
1512
- "unicorn/no-new-buffer": "error",
1513
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1514
- "unicorn/number-literal-case": "error",
1515
- // textContent instead of innerText
1516
- "unicorn/prefer-dom-node-text-content": "error",
1517
- // includes over indexOf when checking for existence
1518
- "unicorn/prefer-includes": "error",
1519
- // Prefer using the node: protocol
1520
- "unicorn/prefer-node-protocol": "error",
1521
- // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1522
- "unicorn/prefer-number-properties": "error",
1523
- // String methods startsWith/endsWith instead of more complicated stuff
1524
- "unicorn/prefer-string-starts-ends-with": "error",
1525
- // Enforce throwing type error when throwing error while checking typeof
1526
- "unicorn/prefer-type-error": "error",
1527
- // Use new when throwing error
1528
- "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
+ }
1529
1604
  }
1530
1605
  }
1531
1606
  ];
@@ -1548,7 +1623,7 @@ async function unocss(options = {}) {
1548
1623
  ]);
1549
1624
  return [
1550
1625
  {
1551
- name: "eslint:unocss",
1626
+ name: "eslint/unocss/rules",
1552
1627
  plugins: {
1553
1628
  unocss: pluginUnoCSS
1554
1629
  },
@@ -1613,7 +1688,7 @@ async function vue(options = {}) {
1613
1688
  watchEffect: "readonly"
1614
1689
  }
1615
1690
  },
1616
- name: "eslint:vue:setup",
1691
+ name: "eslint/vue/setup",
1617
1692
  plugins: {
1618
1693
  vue: pluginVue
1619
1694
  }
@@ -1631,7 +1706,7 @@ async function vue(options = {}) {
1631
1706
  sourceType: "module"
1632
1707
  }
1633
1708
  },
1634
- name: "eslint:vue:rules",
1709
+ name: "eslint/vue/rules",
1635
1710
  processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors2([
1636
1711
  pluginVue.processors[".vue"],
1637
1712
  processorVueBlocks({
@@ -1760,7 +1835,7 @@ async function yaml(options = {}) {
1760
1835
  ]);
1761
1836
  return [
1762
1837
  {
1763
- name: "eslint:yaml:setup",
1838
+ name: "eslint/yaml/setup",
1764
1839
  plugins: {
1765
1840
  yaml: pluginYaml
1766
1841
  }
@@ -1770,7 +1845,7 @@ async function yaml(options = {}) {
1770
1845
  languageOptions: {
1771
1846
  parser: parserYaml
1772
1847
  },
1773
- name: "eslint:yaml:rules",
1848
+ name: "eslint/yaml/rules",
1774
1849
  rules: {
1775
1850
  "style/spaced-comment": "off",
1776
1851
  "yaml/block-mapping": "error",
@@ -1818,7 +1893,7 @@ async function toml(options = {}) {
1818
1893
  ]);
1819
1894
  return [
1820
1895
  {
1821
- name: "eslint:toml:setup",
1896
+ name: "eslint/toml/setup",
1822
1897
  plugins: {
1823
1898
  toml: pluginToml
1824
1899
  }
@@ -1828,7 +1903,7 @@ async function toml(options = {}) {
1828
1903
  languageOptions: {
1829
1904
  parser: parserToml
1830
1905
  },
1831
- name: "eslint:toml:rules",
1906
+ name: "eslint/toml/rules",
1832
1907
  rules: {
1833
1908
  "style/spaced-comment": "off",
1834
1909
  "toml/comma-style": "error",
@@ -1861,8 +1936,6 @@ async function toml(options = {}) {
1861
1936
  // src/factory.ts
1862
1937
  var flatConfigProps = [
1863
1938
  "name",
1864
- "files",
1865
- "ignores",
1866
1939
  "languageOptions",
1867
1940
  "linterOptions",
1868
1941
  "processor",
@@ -1897,29 +1970,40 @@ function lincy(options = {}, ...userConfigs) {
1897
1970
  autoRenamePlugins = true,
1898
1971
  componentExts = [],
1899
1972
  gitignore: enableGitignore = true,
1900
- isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1973
+ jsx: enableJsx = true,
1901
1974
  overrides = {},
1902
1975
  react: enableReact = ReactPackages.some((i) => isPackageExists3(i)),
1903
1976
  regexp: enableRegexp = true,
1904
1977
  typescript: enableTypeScript = isPackageExists3("typescript"),
1978
+ unicorn: enableUnicorn = true,
1905
1979
  unocss: enableUnoCSS = false,
1906
1980
  vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
1907
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
+ }
1908
1988
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1909
1989
  const tsconfigPath = typeof enableTypeScript !== "boolean" && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : void 0;
1910
1990
  if (stylisticOptions) {
1911
1991
  if (!("jsx" in stylisticOptions)) {
1912
- stylisticOptions.jsx = options.jsx ?? true;
1992
+ stylisticOptions.jsx = enableJsx;
1913
1993
  }
1914
1994
  }
1915
1995
  const configs2 = [];
1916
1996
  if (enableGitignore) {
1917
1997
  if (typeof enableGitignore !== "boolean") {
1918
- 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
+ })]));
1919
2002
  } else {
1920
- if (fs.existsSync(".gitignore")) {
1921
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1922
- }
2003
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2004
+ name: "eslint/gitignore",
2005
+ strict: false
2006
+ })]));
1923
2007
  }
1924
2008
  }
1925
2009
  configs2.push(
@@ -1938,10 +2022,12 @@ function lincy(options = {}, ...userConfigs) {
1938
2022
  imports({
1939
2023
  stylistic: stylisticOptions
1940
2024
  }),
1941
- unicorn(),
1942
2025
  // Optional plugins (installed but not enabled by default)
1943
2026
  perfectionist()
1944
2027
  );
2028
+ if (enableUnicorn) {
2029
+ configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
2030
+ }
1945
2031
  if (enableVue) {
1946
2032
  componentExts.push("vue");
1947
2033
  }
@@ -1950,9 +2036,13 @@ function lincy(options = {}, ...userConfigs) {
1950
2036
  ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1951
2037
  componentExts,
1952
2038
  overrides: overrides.typescript,
1953
- tsconfigPath
2039
+ tsconfigPath,
2040
+ type: options.type
1954
2041
  }));
1955
2042
  }
2043
+ if (enableJsx) {
2044
+ configs2.push(jsx());
2045
+ }
1956
2046
  if (stylisticOptions) {
1957
2047
  configs2.push(stylistic({
1958
2048
  overrides: overrides.stylistic,
@@ -2030,6 +2120,9 @@ function lincy(options = {}, ...userConfigs) {
2030
2120
  typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2031
2121
  ));
2032
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
+ }
2033
2126
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2034
2127
  if (key in options) {
2035
2128
  acc[key] = options[key];
@@ -2073,11 +2166,13 @@ export {
2073
2166
  GLOB_SRC_EXT,
2074
2167
  GLOB_STYLE,
2075
2168
  GLOB_SVELTE,
2169
+ GLOB_SVG,
2076
2170
  GLOB_TESTS,
2077
2171
  GLOB_TOML,
2078
2172
  GLOB_TS,
2079
2173
  GLOB_TSX,
2080
2174
  GLOB_VUE,
2175
+ GLOB_XML,
2081
2176
  GLOB_YAML,
2082
2177
  StylisticConfigDefaults,
2083
2178
  combine,
@@ -2089,9 +2184,13 @@ export {
2089
2184
  ignores,
2090
2185
  imports,
2091
2186
  interopDefault,
2187
+ isInEditorEnv,
2188
+ isInGitHooksOrLintStaged,
2189
+ isPackageInScope,
2092
2190
  javascript,
2093
2191
  jsdoc,
2094
2192
  jsonc,
2193
+ jsx,
2095
2194
  lincy,
2096
2195
  markdown,
2097
2196
  node,