@pengzhanbo/eslint-config 1.7.0 → 1.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,52 +1,13 @@
1
- // src/utils.ts
2
- var parserPlain = {
3
- meta: {
4
- name: "parser-plain"
5
- },
6
- parseForESLint: (code) => ({
7
- ast: {
8
- body: [],
9
- comments: [],
10
- loc: { end: code.length, start: 0 },
11
- range: [0, code.length],
12
- tokens: [],
13
- type: "Program"
14
- },
15
- scopeManager: null,
16
- services: { isPlain: true },
17
- visitorKeys: {
18
- Program: []
19
- }
20
- })
21
- };
22
- async function combine(...configs) {
23
- const resolved = await Promise.all(configs);
24
- return resolved.flat();
25
- }
26
- function renameRules(rules, from, to) {
27
- return Object.fromEntries(
28
- Object.entries(rules).map(([key, value]) => {
29
- if (key.startsWith(from))
30
- return [to + key.slice(from.length), value];
31
- return [key, value];
32
- })
33
- );
34
- }
35
- function toArray(value) {
36
- return Array.isArray(value) ? value : [value];
37
- }
38
- async function interopDefault(m) {
39
- const resolved = await m;
40
- return resolved.default || resolved;
41
- }
42
-
43
- // src/preset.ts
44
- import fs from "fs";
1
+ // src/factory.ts
2
+ import process2 from "node:process";
3
+ import fs from "node:fs";
4
+ import { isPackageExists as isPackageExists5 } from "local-pkg";
5
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
45
6
 
46
7
  // src/plugins.ts
47
8
  import { default as default2 } from "eslint-plugin-antfu";
48
9
  import { default as default3 } from "eslint-plugin-eslint-comments";
49
- import * as pluginImport from "eslint-plugin-i";
10
+ import * as pluginImport from "eslint-plugin-import-x";
50
11
  import { default as default4 } from "eslint-plugin-n";
51
12
  import { default as default5 } from "eslint-plugin-unicorn";
52
13
  import { default as default6 } from "eslint-plugin-unused-imports";
@@ -56,7 +17,7 @@ import { default as default7 } from "eslint-plugin-perfectionist";
56
17
  async function comments() {
57
18
  return [
58
19
  {
59
- name: "config:eslint-comments",
20
+ name: "config/eslint-comments/rules",
60
21
  plugins: {
61
22
  "eslint-comments": default3
62
23
  },
@@ -93,6 +54,7 @@ var GLOB_TOML = "**/*.toml";
93
54
  var GLOB_HTML = "**/*.htm?(l)";
94
55
  var GLOB_ASTRO = "**/*.astro";
95
56
  var GLOB_SVELTE = "**/*.svelte";
57
+ var GLOB_GRAPHQL = "**/*.{g,graph}ql";
96
58
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
97
59
  var GLOB_TESTS = [
98
60
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -160,7 +122,7 @@ async function imports(options = {}) {
160
122
  } = options;
161
123
  return [
162
124
  {
163
- name: "config:imports",
125
+ name: "config/imports/rules",
164
126
  plugins: {
165
127
  antfu: default2,
166
128
  import: pluginImport
@@ -177,13 +139,13 @@ async function imports(options = {}) {
177
139
  "import/no-webpack-loader-syntax": "error",
178
140
  "import/order": "error",
179
141
  ...stylistic2 ? {
180
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
142
+ "import/newline-after-import": ["error", { count: 1 }]
181
143
  } : {}
182
144
  }
183
145
  },
184
146
  {
185
147
  files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
186
- name: "antfu:imports:bin",
148
+ name: "config/imports/disables/bin",
187
149
  rules: {
188
150
  "antfu/no-import-dist": "off",
189
151
  "antfu/no-import-node-modules-by-path": "off"
@@ -223,7 +185,7 @@ async function javascript(options = {}) {
223
185
  linterOptions: {
224
186
  reportUnusedDisableDirectives: true
225
187
  },
226
- name: "config:javascript",
188
+ name: "config/javascript/rules",
227
189
  plugins: {
228
190
  "antfu": default2,
229
191
  "unused-imports": default6
@@ -277,7 +239,7 @@ async function javascript(options = {}) {
277
239
  "no-multi-str": "error",
278
240
  "no-new": "error",
279
241
  "no-new-func": "error",
280
- "no-new-symbol": "error",
242
+ "no-new-native-nonconstructor": "error",
281
243
  "no-new-wrappers": "error",
282
244
  "no-obj-calls": "error",
283
245
  "no-octal": "error",
@@ -400,7 +362,7 @@ async function javascript(options = {}) {
400
362
  },
401
363
  {
402
364
  files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
403
- name: "config:scripts-overrides",
365
+ name: "config/javascript/disables/cli",
404
366
  rules: {
405
367
  "no-console": "off"
406
368
  }
@@ -408,6 +370,78 @@ async function javascript(options = {}) {
408
370
  ];
409
371
  }
410
372
 
373
+ // src/utils.ts
374
+ import { isPackageExists } from "local-pkg";
375
+ var parserPlain = {
376
+ meta: {
377
+ name: "parser-plain"
378
+ },
379
+ parseForESLint: (code) => ({
380
+ ast: {
381
+ body: [],
382
+ comments: [],
383
+ loc: { end: code.length, start: 0 },
384
+ range: [0, code.length],
385
+ tokens: [],
386
+ type: "Program"
387
+ },
388
+ scopeManager: null,
389
+ services: { isPlain: true },
390
+ visitorKeys: {
391
+ Program: []
392
+ }
393
+ })
394
+ };
395
+ async function combine(...configs) {
396
+ const resolved = await Promise.all(configs);
397
+ return resolved.flat();
398
+ }
399
+ function renameRules(rules, map) {
400
+ return Object.fromEntries(
401
+ Object.entries(rules).map(([key, value]) => {
402
+ for (const [from, to] of Object.entries(map)) {
403
+ if (key.startsWith(`${from}/`))
404
+ return [to + key.slice(from.length), value];
405
+ }
406
+ return [key, value];
407
+ })
408
+ );
409
+ }
410
+ function renamePluginInConfigs(configs, map) {
411
+ return configs.map((i) => {
412
+ const clone = { ...i };
413
+ if (clone.rules)
414
+ clone.rules = renameRules(clone.rules, map);
415
+ if (clone.plugins) {
416
+ clone.plugins = Object.fromEntries(
417
+ Object.entries(clone.plugins).map(([key, value]) => {
418
+ if (key in map)
419
+ return [map[key], value];
420
+ return [key, value];
421
+ })
422
+ );
423
+ }
424
+ return clone;
425
+ });
426
+ }
427
+ function toArray(value) {
428
+ return Array.isArray(value) ? value : [value];
429
+ }
430
+ async function interopDefault(m) {
431
+ const resolved = await m;
432
+ return resolved.default || resolved;
433
+ }
434
+ async function ensurePackages(packages) {
435
+ const list = toArray(packages);
436
+ const nonExistingPackages = list.filter((i) => i && !isPackageExists(i));
437
+ if (nonExistingPackages.length === 0)
438
+ return;
439
+ if (nonExistingPackages.length > 0)
440
+ console.warn(`${nonExistingPackages.join(", ")} is not installed, please install it first.
441
+ Run \`npm install -D ${nonExistingPackages.join(" ")}\``);
442
+ await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
443
+ }
444
+
411
445
  // src/configs/jsdoc.ts
412
446
  async function jsdoc(options = {}) {
413
447
  const {
@@ -415,7 +449,7 @@ async function jsdoc(options = {}) {
415
449
  } = options;
416
450
  return [
417
451
  {
418
- name: "config:jsdoc",
452
+ name: "config/jsdoc/rules",
419
453
  plugins: {
420
454
  jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
421
455
  },
@@ -463,7 +497,7 @@ async function jsonc(options = {}) {
463
497
  ]);
464
498
  return [
465
499
  {
466
- name: "config:jsonc:setup",
500
+ name: "config/jsonc/setup",
467
501
  plugins: {
468
502
  jsonc: pluginJsonc
469
503
  }
@@ -473,7 +507,7 @@ async function jsonc(options = {}) {
473
507
  languageOptions: {
474
508
  parser: parserJsonc
475
509
  },
476
- name: "config:jsonc:rules",
510
+ name: "config/jsonc/rules",
477
511
  rules: {
478
512
  "jsonc/no-bigint-literals": "error",
479
513
  "jsonc/no-binary-expression": "error",
@@ -530,14 +564,14 @@ async function markdown(options = {}) {
530
564
  const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
531
565
  return [
532
566
  {
533
- name: "config:markdown:setup",
567
+ name: "config/markdown/setup",
534
568
  plugins: {
535
569
  markdown: markdown2
536
570
  }
537
571
  },
538
572
  {
539
573
  files,
540
- name: "config:markdown:processor",
574
+ name: "config/markdown/processor",
541
575
  // `eslint-plugin-markdown` only creates virtual files for code blocks,
542
576
  // but not the markdown file itself. We use `eslint-merge-processors` to
543
577
  // add a pass-through processor for the markdown file itself.
@@ -551,7 +585,7 @@ async function markdown(options = {}) {
551
585
  languageOptions: {
552
586
  parser: parserPlain
553
587
  },
554
- name: "config:markdown:parser"
588
+ name: "config/markdown/parser"
555
589
  },
556
590
  {
557
591
  files: [
@@ -565,7 +599,7 @@ async function markdown(options = {}) {
565
599
  }
566
600
  }
567
601
  },
568
- name: "config:markdown:disables",
602
+ name: "config/markdown/disables",
569
603
  rules: {
570
604
  "import/newline-after-import": "off",
571
605
  "no-alert": "off",
@@ -619,7 +653,7 @@ async function markdown(options = {}) {
619
653
  async function node() {
620
654
  return [
621
655
  {
622
- name: "config:node",
656
+ name: "config/node/rules",
623
657
  plugins: {
624
658
  node: default4
625
659
  },
@@ -637,148 +671,507 @@ async function node() {
637
671
  ];
638
672
  }
639
673
 
640
- // src/configs/sort.ts
641
- async function sortPackageJson() {
674
+ // src/configs/perfectionist.ts
675
+ async function perfectionist() {
642
676
  return [
643
677
  {
644
- files: ["**/package.json"],
645
- name: "config:sort-package-json",
646
- rules: {
647
- "jsonc/sort-array-values": [
648
- "error",
649
- {
650
- order: { type: "asc" },
651
- pathPattern: "^files$"
652
- }
653
- ],
654
- "jsonc/sort-keys": [
655
- "error",
656
- {
657
- order: [
658
- "publisher",
659
- "name",
660
- "displayName",
661
- "type",
662
- "version",
663
- "private",
664
- "packageManager",
665
- "description",
666
- "author",
667
- "license",
668
- "funding",
669
- "homepage",
670
- "repository",
671
- "bugs",
672
- "keywords",
673
- "categories",
674
- "sideEffects",
675
- "exports",
676
- "main",
677
- "module",
678
- "unpkg",
679
- "jsdelivr",
680
- "types",
681
- "typesVersions",
682
- "bin",
683
- "icon",
684
- "files",
685
- "engines",
686
- "activationEvents",
687
- "contributes",
688
- "scripts",
689
- "peerDependencies",
690
- "peerDependenciesMeta",
691
- "dependencies",
692
- "optionalDependencies",
693
- "devDependencies",
694
- "pnpm",
695
- "overrides",
696
- "resolutions",
697
- "husky",
698
- "simple-git-hooks",
699
- "lint-staged",
700
- "eslintConfig"
701
- ],
702
- pathPattern: "^$"
703
- },
704
- {
705
- order: { type: "asc" },
706
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
707
- },
708
- {
709
- order: { type: "asc" },
710
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
711
- },
712
- {
713
- order: [
714
- "types",
715
- "import",
716
- "require",
717
- "default"
718
- ],
719
- pathPattern: "^exports.*$"
720
- }
721
- ]
678
+ name: "config/perfectionist/setup",
679
+ plugins: {
680
+ perfectionist: default7
722
681
  }
723
682
  }
724
683
  ];
725
684
  }
726
- function sortTsconfig() {
685
+
686
+ // src/configs/formatters.ts
687
+ import { isPackageExists as isPackageExists2 } from "local-pkg";
688
+
689
+ // src/configs/stylistic.ts
690
+ var StylisticConfigDefaults = {
691
+ indent: 2,
692
+ jsx: true,
693
+ quotes: "single",
694
+ semi: false
695
+ };
696
+ async function stylistic(options = {}) {
697
+ const {
698
+ indent,
699
+ jsx,
700
+ overrides = {},
701
+ quotes,
702
+ semi
703
+ } = {
704
+ ...StylisticConfigDefaults,
705
+ ...options
706
+ };
707
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
708
+ const config = pluginStylistic.configs.customize({
709
+ flat: true,
710
+ indent,
711
+ jsx,
712
+ pluginName: "style",
713
+ quotes,
714
+ semi
715
+ });
727
716
  return [
728
717
  {
729
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
730
- name: "config:sort-tsconfig",
718
+ name: "config/stylistic/rules",
719
+ plugins: {
720
+ antfu: default2,
721
+ style: pluginStylistic
722
+ },
731
723
  rules: {
732
- "jsonc/sort-keys": [
733
- "error",
734
- {
735
- order: [
736
- "extends",
737
- "compilerOptions",
738
- "references",
739
- "files",
740
- "include",
741
- "exclude"
742
- ],
743
- pathPattern: "^$"
744
- },
745
- {
746
- order: [
747
- /* Projects */
748
- "incremental",
749
- "composite",
750
- "tsBuildInfoFile",
751
- "disableSourceOfProjectReferenceRedirect",
752
- "disableSolutionSearching",
753
- "disableReferencedProjectLoad",
754
- /* Language and Environment */
755
- "target",
756
- "jsx",
757
- "jsxFactory",
758
- "jsxFragmentFactory",
759
- "jsxImportSource",
760
- "lib",
761
- "moduleDetection",
762
- "noLib",
763
- "reactNamespace",
764
- "useDefineForClassFields",
765
- "emitDecoratorMetadata",
766
- "experimentalDecorators",
767
- /* Modules */
768
- "baseUrl",
769
- "rootDir",
770
- "rootDirs",
771
- "customConditions",
772
- "module",
773
- "moduleResolution",
774
- "moduleSuffixes",
775
- "noResolve",
776
- "paths",
777
- "resolveJsonModule",
778
- "resolvePackageJsonExports",
779
- "resolvePackageJsonImports",
780
- "typeRoots",
781
- "types",
724
+ ...config.rules,
725
+ "antfu/consistent-list-newline": "error",
726
+ "antfu/if-newline": "error",
727
+ "antfu/top-level-function": "error",
728
+ "curly": ["error", "multi-or-nest", "consistent"],
729
+ ...overrides
730
+ }
731
+ }
732
+ ];
733
+ }
734
+
735
+ // src/configs/formatters.ts
736
+ var formatPackages = ["eslint-plugin-format"];
737
+ async function formatters(options = {}, stylistic2 = {}) {
738
+ if (options === true) {
739
+ options = {
740
+ astro: isPackageExists2("astro"),
741
+ css: true,
742
+ graphql: true,
743
+ html: true,
744
+ markdown: true
745
+ };
746
+ }
747
+ if (options.astro)
748
+ formatPackages.push("prettier-plugin-astro");
749
+ await ensurePackages(formatPackages);
750
+ const {
751
+ indent,
752
+ quotes,
753
+ semi
754
+ } = {
755
+ ...StylisticConfigDefaults,
756
+ ...stylistic2
757
+ };
758
+ const prettierOptions = Object.assign(
759
+ {
760
+ endOfLine: "auto",
761
+ semi,
762
+ singleQuote: quotes === "single",
763
+ tabWidth: typeof indent === "number" ? indent : 2,
764
+ trailingComma: "all",
765
+ useTabs: indent === "tab"
766
+ },
767
+ options.prettierOptions || {}
768
+ );
769
+ const dprintOptions = Object.assign(
770
+ {
771
+ indentWidth: typeof indent === "number" ? indent : 2,
772
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
773
+ useTabs: indent === "tab"
774
+ },
775
+ options.dprintOptions || {}
776
+ );
777
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
778
+ const configs = [
779
+ {
780
+ name: "config/formatters/setup",
781
+ plugins: {
782
+ format: pluginFormat
783
+ }
784
+ }
785
+ ];
786
+ if (options.css) {
787
+ configs.push(
788
+ {
789
+ files: [GLOB_CSS, GLOB_POSTCSS],
790
+ languageOptions: {
791
+ parser: parserPlain
792
+ },
793
+ name: "config/formatter/css",
794
+ rules: {
795
+ "format/prettier": [
796
+ "error",
797
+ {
798
+ ...prettierOptions,
799
+ parser: "css"
800
+ }
801
+ ]
802
+ }
803
+ },
804
+ {
805
+ files: [GLOB_SCSS],
806
+ languageOptions: {
807
+ parser: parserPlain
808
+ },
809
+ name: "config/formatter/scss",
810
+ rules: {
811
+ "format/prettier": [
812
+ "error",
813
+ {
814
+ ...prettierOptions,
815
+ parser: "scss"
816
+ }
817
+ ]
818
+ }
819
+ },
820
+ {
821
+ files: [GLOB_LESS],
822
+ languageOptions: {
823
+ parser: parserPlain
824
+ },
825
+ name: "config/formatter/less",
826
+ rules: {
827
+ "format/prettier": [
828
+ "error",
829
+ {
830
+ ...prettierOptions,
831
+ parser: "less"
832
+ }
833
+ ]
834
+ }
835
+ }
836
+ );
837
+ }
838
+ if (options.html) {
839
+ configs.push({
840
+ files: ["**/*.html"],
841
+ languageOptions: {
842
+ parser: parserPlain
843
+ },
844
+ name: "config/formatter/html",
845
+ rules: {
846
+ "format/prettier": [
847
+ "error",
848
+ {
849
+ ...prettierOptions,
850
+ parser: "html"
851
+ }
852
+ ]
853
+ }
854
+ });
855
+ }
856
+ if (options.markdown) {
857
+ const formater = options.markdown === true ? "prettier" : options.markdown;
858
+ configs.push({
859
+ files: [GLOB_MARKDOWN],
860
+ languageOptions: {
861
+ parser: parserPlain
862
+ },
863
+ name: "config/formatter/markdown",
864
+ rules: {
865
+ [`format/${formater}`]: [
866
+ "error",
867
+ formater === "prettier" ? {
868
+ printWidth: 120,
869
+ ...prettierOptions,
870
+ embeddedLanguageFormatting: "off",
871
+ parser: "markdown"
872
+ } : {
873
+ ...dprintOptions,
874
+ language: "markdown"
875
+ }
876
+ ]
877
+ }
878
+ });
879
+ }
880
+ if (options.graphql) {
881
+ configs.push({
882
+ files: [GLOB_GRAPHQL],
883
+ languageOptions: {
884
+ parser: parserPlain
885
+ },
886
+ name: "config/formatter/graphql",
887
+ rules: {
888
+ "format/prettier": [
889
+ "error",
890
+ {
891
+ ...prettierOptions,
892
+ parser: "graphql"
893
+ }
894
+ ]
895
+ }
896
+ });
897
+ }
898
+ if (options.astro) {
899
+ configs.push({
900
+ files: [GLOB_ASTRO],
901
+ languageOptions: {
902
+ parser: parserPlain
903
+ },
904
+ name: "config/formatter/astro",
905
+ rules: {
906
+ "format/prettier": [
907
+ "error",
908
+ {
909
+ ...prettierOptions,
910
+ parser: "astro",
911
+ plugins: [
912
+ "prettier-plugin-astro"
913
+ ]
914
+ }
915
+ ]
916
+ }
917
+ });
918
+ }
919
+ return configs;
920
+ }
921
+
922
+ // src/configs/react.ts
923
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
924
+ var ReactRefreshAllowConstantExportPackages = [
925
+ "vite"
926
+ ];
927
+ async function react(options = {}) {
928
+ const {
929
+ files = [GLOB_JSX, GLOB_TSX],
930
+ overrides = {},
931
+ typescript: typescript2 = true
932
+ } = options;
933
+ await ensurePackages([
934
+ "eslint-plugin-react",
935
+ "eslint-plugin-react-hooks",
936
+ "eslint-plugin-react-refresh"
937
+ ]);
938
+ const [
939
+ pluginReact,
940
+ pluginReactHooks,
941
+ pluginReactRefresh
942
+ ] = await Promise.all([
943
+ interopDefault(import("eslint-plugin-react")),
944
+ interopDefault(import("eslint-plugin-react-hooks")),
945
+ interopDefault(import("eslint-plugin-react-refresh"))
946
+ ]);
947
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
948
+ (i) => isPackageExists3(i)
949
+ );
950
+ return [
951
+ {
952
+ name: "config/react/setup",
953
+ plugins: {
954
+ "react": pluginReact,
955
+ "react-hooks": pluginReactHooks,
956
+ "react-refresh": pluginReactRefresh
957
+ },
958
+ settings: {
959
+ react: {
960
+ version: "detect"
961
+ }
962
+ }
963
+ },
964
+ {
965
+ files,
966
+ languageOptions: {
967
+ parserOptions: {
968
+ ecmaFeatures: {
969
+ jsx: true
970
+ }
971
+ }
972
+ },
973
+ name: "config/react/rules",
974
+ rules: {
975
+ // recommended rules react-hooks
976
+ "react-hooks/exhaustive-deps": "warn",
977
+ "react-hooks/rules-of-hooks": "error",
978
+ // react refresh
979
+ "react-refresh/only-export-components": [
980
+ "warn",
981
+ { allowConstantExport: isAllowConstantExport }
982
+ ],
983
+ // recommended rules react
984
+ "react/display-name": "error",
985
+ "react/jsx-key": "error",
986
+ "react/jsx-no-comment-textnodes": "error",
987
+ "react/jsx-no-duplicate-props": "error",
988
+ "react/jsx-no-target-blank": "error",
989
+ "react/jsx-no-undef": "error",
990
+ "react/jsx-uses-react": "error",
991
+ "react/jsx-uses-vars": "error",
992
+ "react/no-children-prop": "error",
993
+ "react/no-danger-with-children": "error",
994
+ "react/no-deprecated": "error",
995
+ "react/no-direct-mutation-state": "error",
996
+ "react/no-find-dom-node": "error",
997
+ "react/no-is-mounted": "error",
998
+ "react/no-render-return-value": "error",
999
+ "react/no-string-refs": "error",
1000
+ "react/no-unescaped-entities": "error",
1001
+ "react/no-unknown-property": "error",
1002
+ "react/no-unsafe": "off",
1003
+ "react/prop-types": "error",
1004
+ "react/react-in-jsx-scope": "off",
1005
+ "react/require-render-return": "error",
1006
+ ...typescript2 ? {
1007
+ "react/jsx-no-undef": "off",
1008
+ "react/prop-type": "off"
1009
+ } : {},
1010
+ // overrides
1011
+ ...overrides
1012
+ }
1013
+ }
1014
+ ];
1015
+ }
1016
+
1017
+ // src/configs/sort.ts
1018
+ async function sortPackageJson() {
1019
+ return [
1020
+ {
1021
+ files: ["**/package.json"],
1022
+ name: "config/sort/package-json",
1023
+ rules: {
1024
+ "jsonc/sort-array-values": [
1025
+ "error",
1026
+ {
1027
+ order: { type: "asc" },
1028
+ pathPattern: "^files$"
1029
+ }
1030
+ ],
1031
+ "jsonc/sort-keys": [
1032
+ "error",
1033
+ {
1034
+ order: [
1035
+ "publisher",
1036
+ "name",
1037
+ "displayName",
1038
+ "type",
1039
+ "version",
1040
+ "private",
1041
+ "packageManager",
1042
+ "description",
1043
+ "author",
1044
+ "license",
1045
+ "funding",
1046
+ "homepage",
1047
+ "repository",
1048
+ "bugs",
1049
+ "keywords",
1050
+ "categories",
1051
+ "sideEffects",
1052
+ "exports",
1053
+ "main",
1054
+ "module",
1055
+ "unpkg",
1056
+ "jsdelivr",
1057
+ "types",
1058
+ "typesVersions",
1059
+ "bin",
1060
+ "icon",
1061
+ "files",
1062
+ "engines",
1063
+ "activationEvents",
1064
+ "contributes",
1065
+ "scripts",
1066
+ "peerDependencies",
1067
+ "peerDependenciesMeta",
1068
+ "dependencies",
1069
+ "optionalDependencies",
1070
+ "devDependencies",
1071
+ "pnpm",
1072
+ "overrides",
1073
+ "resolutions",
1074
+ "husky",
1075
+ "simple-git-hooks",
1076
+ "lint-staged",
1077
+ "eslintConfig"
1078
+ ],
1079
+ pathPattern: "^$"
1080
+ },
1081
+ {
1082
+ order: { type: "asc" },
1083
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1084
+ },
1085
+ {
1086
+ order: { type: "asc" },
1087
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1088
+ },
1089
+ {
1090
+ order: [
1091
+ "types",
1092
+ "import",
1093
+ "require",
1094
+ "default"
1095
+ ],
1096
+ pathPattern: "^exports.*$"
1097
+ },
1098
+ {
1099
+ order: [
1100
+ // client hooks only
1101
+ "pre-commit",
1102
+ "prepare-commit-msg",
1103
+ "commit-msg",
1104
+ "post-commit",
1105
+ "pre-rebase",
1106
+ "post-rewrite",
1107
+ "post-checkout",
1108
+ "post-merge",
1109
+ "pre-push",
1110
+ "pre-auto-gc"
1111
+ ],
1112
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1113
+ }
1114
+ ]
1115
+ }
1116
+ }
1117
+ ];
1118
+ }
1119
+ function sortTsconfig() {
1120
+ return [
1121
+ {
1122
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1123
+ name: "config/sort/tsconfig-json",
1124
+ rules: {
1125
+ "jsonc/sort-keys": [
1126
+ "error",
1127
+ {
1128
+ order: [
1129
+ "extends",
1130
+ "compilerOptions",
1131
+ "references",
1132
+ "files",
1133
+ "include",
1134
+ "exclude"
1135
+ ],
1136
+ pathPattern: "^$"
1137
+ },
1138
+ {
1139
+ order: [
1140
+ /* Projects */
1141
+ "incremental",
1142
+ "composite",
1143
+ "tsBuildInfoFile",
1144
+ "disableSourceOfProjectReferenceRedirect",
1145
+ "disableSolutionSearching",
1146
+ "disableReferencedProjectLoad",
1147
+ /* Language and Environment */
1148
+ "target",
1149
+ "jsx",
1150
+ "jsxFactory",
1151
+ "jsxFragmentFactory",
1152
+ "jsxImportSource",
1153
+ "lib",
1154
+ "moduleDetection",
1155
+ "noLib",
1156
+ "reactNamespace",
1157
+ "useDefineForClassFields",
1158
+ "emitDecoratorMetadata",
1159
+ "experimentalDecorators",
1160
+ /* Modules */
1161
+ "baseUrl",
1162
+ "rootDir",
1163
+ "rootDirs",
1164
+ "customConditions",
1165
+ "module",
1166
+ "moduleResolution",
1167
+ "moduleSuffixes",
1168
+ "noResolve",
1169
+ "paths",
1170
+ "resolveJsonModule",
1171
+ "resolvePackageJsonExports",
1172
+ "resolvePackageJsonImports",
1173
+ "typeRoots",
1174
+ "types",
782
1175
  "allowArbitraryExtensions",
783
1176
  "allowImportingTsExtensions",
784
1177
  "allowUmdGlobalAccess",
@@ -849,46 +1242,141 @@ function sortTsconfig() {
849
1242
  ];
850
1243
  }
851
1244
 
852
- // src/configs/stylistic.ts
853
- var StylisticConfigDefaults = {
854
- indent: 2,
855
- jsx: true,
856
- quotes: "single",
857
- semi: false
858
- };
859
- async function stylistic(options = {}) {
1245
+ // src/configs/svelte.ts
1246
+ async function svelte(options = {}) {
860
1247
  const {
861
- indent,
862
- jsx,
1248
+ files = [GLOB_SVELTE],
863
1249
  overrides = {},
864
- quotes,
865
- semi
866
- } = {
867
- ...StylisticConfigDefaults,
868
- ...options
869
- };
870
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
871
- const config = pluginStylistic.configs.customize({
872
- flat: true,
873
- indent,
874
- jsx,
875
- pluginName: "style",
876
- quotes,
877
- semi
878
- });
1250
+ stylistic: stylistic2 = true
1251
+ } = options;
1252
+ const {
1253
+ indent = 2,
1254
+ quotes = "single"
1255
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1256
+ await ensurePackages([
1257
+ "eslint-plugin-svelte"
1258
+ ]);
1259
+ const [
1260
+ pluginSvelte,
1261
+ parserSvelte
1262
+ ] = await Promise.all([
1263
+ interopDefault(import("eslint-plugin-svelte")),
1264
+ interopDefault(import("svelte-eslint-parser"))
1265
+ ]);
879
1266
  return [
880
1267
  {
881
- name: "config:stylistic",
1268
+ name: "config/svelte/setup",
882
1269
  plugins: {
883
- antfu: default2,
884
- style: pluginStylistic
1270
+ svelte: pluginSvelte
1271
+ }
1272
+ },
1273
+ {
1274
+ files,
1275
+ languageOptions: {
1276
+ parser: parserSvelte,
1277
+ parserOptions: {
1278
+ extraFileExtensions: [".svelte"],
1279
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1280
+ }
885
1281
  },
1282
+ name: "config/svelte/rules",
1283
+ processor: pluginSvelte.processors[".svelte"],
886
1284
  rules: {
887
- ...config.rules,
888
- "antfu/consistent-list-newline": "error",
889
- "antfu/if-newline": "error",
890
- "antfu/top-level-function": "error",
891
- "curly": ["error", "multi-or-nest", "consistent"],
1285
+ "import/no-mutable-exports": "off",
1286
+ "no-undef": "off",
1287
+ // incompatible with most recent (attribute-form) generic types RFC
1288
+ "no-unused-vars": ["error", {
1289
+ args: "none",
1290
+ caughtErrors: "none",
1291
+ ignoreRestSiblings: true,
1292
+ vars: "all",
1293
+ varsIgnorePattern: "^\\$\\$Props$"
1294
+ }],
1295
+ "svelte/comment-directive": "error",
1296
+ "svelte/no-at-debug-tags": "warn",
1297
+ "svelte/no-at-html-tags": "error",
1298
+ "svelte/no-dupe-else-if-blocks": "error",
1299
+ "svelte/no-dupe-style-properties": "error",
1300
+ "svelte/no-dupe-use-directives": "error",
1301
+ "svelte/no-dynamic-slot-name": "error",
1302
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1303
+ "svelte/no-inner-declarations": "error",
1304
+ "svelte/no-not-function-handler": "error",
1305
+ "svelte/no-object-in-text-mustaches": "error",
1306
+ "svelte/no-reactive-functions": "error",
1307
+ "svelte/no-reactive-literals": "error",
1308
+ "svelte/no-shorthand-style-property-overrides": "error",
1309
+ "svelte/no-unknown-style-directive-property": "error",
1310
+ "svelte/no-unused-svelte-ignore": "error",
1311
+ "svelte/no-useless-mustaches": "error",
1312
+ "svelte/require-store-callbacks-use-set-param": "error",
1313
+ "svelte/system": "error",
1314
+ "svelte/valid-compile": "error",
1315
+ "svelte/valid-each-key": "error",
1316
+ "unused-imports/no-unused-vars": [
1317
+ "error",
1318
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
1319
+ ],
1320
+ ...stylistic2 ? {
1321
+ "style/indent": "off",
1322
+ // superseded by svelte/indent
1323
+ "style/no-trailing-spaces": "off",
1324
+ // superseded by svelte/no-trailing-spaces
1325
+ "svelte/derived-has-same-inputs-outputs": "error",
1326
+ "svelte/html-closing-bracket-spacing": "error",
1327
+ "svelte/html-quotes": ["error", { prefer: quotes }],
1328
+ "svelte/indent": ["error", { alignAttributesVertically: true, indent }],
1329
+ "svelte/mustache-spacing": "error",
1330
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1331
+ "svelte/no-trailing-spaces": "error",
1332
+ "svelte/spaced-html-comment": "error"
1333
+ } : {},
1334
+ ...overrides
1335
+ }
1336
+ }
1337
+ ];
1338
+ }
1339
+
1340
+ // src/configs/test.ts
1341
+ async function test(options = {}) {
1342
+ const {
1343
+ files = GLOB_TESTS,
1344
+ isInEditor = false,
1345
+ overrides = {}
1346
+ } = options;
1347
+ const [
1348
+ pluginVitest,
1349
+ pluginNoOnlyTests
1350
+ ] = await Promise.all([
1351
+ interopDefault(import("eslint-plugin-vitest")),
1352
+ // @ts-expect-error missing types
1353
+ interopDefault(import("eslint-plugin-no-only-tests"))
1354
+ ]);
1355
+ return [
1356
+ {
1357
+ name: "config/test/setup",
1358
+ plugins: {
1359
+ test: {
1360
+ ...pluginVitest,
1361
+ rules: {
1362
+ ...pluginVitest.rules,
1363
+ // extend `test/no-only-tests` rule
1364
+ ...pluginNoOnlyTests.rules
1365
+ }
1366
+ }
1367
+ }
1368
+ },
1369
+ {
1370
+ files,
1371
+ name: "config/test/rules",
1372
+ rules: {
1373
+ "node/prefer-global/process": "off",
1374
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1375
+ "test/no-identical-title": "error",
1376
+ "test/no-import-node-test": "error",
1377
+ "test/no-only-tests": isInEditor ? "off" : "error",
1378
+ "test/prefer-hooks-in-order": "error",
1379
+ "test/prefer-lowercase-title": "error",
892
1380
  ...overrides
893
1381
  }
894
1382
  }
@@ -896,7 +1384,7 @@ async function stylistic(options = {}) {
896
1384
  }
897
1385
 
898
1386
  // src/configs/typescript.ts
899
- import process from "process";
1387
+ import process from "node:process";
900
1388
  async function typescript(options = {}) {
901
1389
  const {
902
1390
  componentExts = [],
@@ -954,13 +1442,13 @@ async function typescript(options = {}) {
954
1442
  ...parserOptions
955
1443
  }
956
1444
  },
957
- name: `antfu:typescript:${typeAware ? "type-aware-parser" : "parser"}`
1445
+ name: `config/typescript/${typeAware ? "type-aware-parser" : "parser"}`
958
1446
  };
959
1447
  }
960
1448
  return [
961
1449
  {
962
1450
  // Install the plugins without globs, so they can be configured separately.
963
- name: "config:typescript:setup",
1451
+ name: "config/typescript/setup",
964
1452
  plugins: {
965
1453
  antfu: default2,
966
1454
  ts: pluginTs
@@ -973,17 +1461,15 @@ async function typescript(options = {}) {
973
1461
  ] : [makeParser(false, files)],
974
1462
  {
975
1463
  files,
976
- name: "config:typescript:rules",
1464
+ name: "config/typescript/rules",
977
1465
  rules: {
978
1466
  ...renameRules(
979
1467
  pluginTs.configs["eslint-recommended"].overrides[0].rules,
980
- "@typescript-eslint/",
981
- "ts/"
1468
+ { "@typescript-eslint": "ts" }
982
1469
  ),
983
1470
  ...renameRules(
984
1471
  pluginTs.configs.strict.rules,
985
- "@typescript-eslint/",
986
- "ts/"
1472
+ { "@typescript-eslint": "ts" }
987
1473
  ),
988
1474
  "no-dupe-class-members": "off",
989
1475
  "no-loss-of-precision": "off",
@@ -1017,7 +1503,7 @@ async function typescript(options = {}) {
1017
1503
  },
1018
1504
  {
1019
1505
  files: filesTypeAware,
1020
- name: "config:typescript:rules-type-aware",
1506
+ name: "config/typescript/rules-type-aware",
1021
1507
  rules: {
1022
1508
  ...tsconfigPath ? typeAwareRules : {},
1023
1509
  ...overrides
@@ -1025,7 +1511,7 @@ async function typescript(options = {}) {
1025
1511
  },
1026
1512
  {
1027
1513
  files: ["**/*.d.ts"],
1028
- name: "config:typescript:dts-overrides",
1514
+ name: "config/typescript/disables/dts",
1029
1515
  rules: {
1030
1516
  "eslint-comments/no-unlimited-disable": "off",
1031
1517
  "import/no-duplicates": "off",
@@ -1035,14 +1521,14 @@ async function typescript(options = {}) {
1035
1521
  },
1036
1522
  {
1037
1523
  files: ["**/*.{test,spec}.ts?(x)"],
1038
- name: "config:typescript:tests-overrides",
1524
+ name: "config/typescript/disables/tests",
1039
1525
  rules: {
1040
1526
  "no-unused-expressions": "off"
1041
1527
  }
1042
1528
  },
1043
1529
  {
1044
1530
  files: ["**/*.js", "**/*.cjs"],
1045
- name: "config:typescript:javascript-overrides",
1531
+ name: "config/typescript/disables/cjs",
1046
1532
  rules: {
1047
1533
  "ts/no-require-imports": "off",
1048
1534
  "ts/no-var-requires": "off"
@@ -1055,7 +1541,7 @@ async function typescript(options = {}) {
1055
1541
  async function unicorn() {
1056
1542
  return [
1057
1543
  {
1058
- name: "config:unicorn",
1544
+ name: "config/unicorn",
1059
1545
  plugins: {
1060
1546
  unicorn: default5
1061
1547
  },
@@ -1091,6 +1577,211 @@ async function unicorn() {
1091
1577
  ];
1092
1578
  }
1093
1579
 
1580
+ // src/configs/unocss.ts
1581
+ async function unocss(options = {}) {
1582
+ const {
1583
+ attributify = true,
1584
+ strict = false
1585
+ } = options;
1586
+ await ensurePackages([
1587
+ "@unocss/eslint-plugin"
1588
+ ]);
1589
+ const [
1590
+ pluginUnoCSS
1591
+ ] = await Promise.all([
1592
+ interopDefault(import("@unocss/eslint-plugin"))
1593
+ ]);
1594
+ return [
1595
+ {
1596
+ name: "config/unocss/rules",
1597
+ plugins: {
1598
+ unocss: pluginUnoCSS
1599
+ },
1600
+ rules: {
1601
+ "unocss/order": "warn",
1602
+ ...attributify ? {
1603
+ "unocss/order-attributify": "warn"
1604
+ } : {},
1605
+ ...strict ? {
1606
+ "unocss/blocklist": "error"
1607
+ } : {}
1608
+ }
1609
+ }
1610
+ ];
1611
+ }
1612
+
1613
+ // src/configs/vue.ts
1614
+ import { mergeProcessors as mergeProcessors2 } from "eslint-merge-processors";
1615
+ async function vue(options = {}) {
1616
+ const {
1617
+ files = [GLOB_VUE],
1618
+ overrides = {},
1619
+ stylistic: stylistic2 = true,
1620
+ vueVersion = 3
1621
+ } = options;
1622
+ await ensurePackages([
1623
+ "vue-eslint-parser",
1624
+ "eslint-plugin-vue",
1625
+ "eslint-processor-vue-blocks"
1626
+ ]);
1627
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1628
+ const {
1629
+ indent = 2
1630
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1631
+ const [
1632
+ pluginVue,
1633
+ parserVue,
1634
+ processorVueBlocks
1635
+ ] = await Promise.all([
1636
+ // @ts-expect-error missing types
1637
+ interopDefault(import("eslint-plugin-vue")),
1638
+ interopDefault(import("vue-eslint-parser")),
1639
+ interopDefault(import("eslint-processor-vue-blocks"))
1640
+ ]);
1641
+ return [
1642
+ {
1643
+ // This allows Vue plugin to work with auto imports
1644
+ // https://github.com/vuejs/eslint-plugin-vue/pull/2422
1645
+ languageOptions: {
1646
+ globals: {
1647
+ computed: "readonly",
1648
+ defineEmits: "readonly",
1649
+ defineExpose: "readonly",
1650
+ defineProps: "readonly",
1651
+ onMounted: "readonly",
1652
+ onUnmounted: "readonly",
1653
+ reactive: "readonly",
1654
+ ref: "readonly",
1655
+ shallowReactive: "readonly",
1656
+ shallowRef: "readonly",
1657
+ toRef: "readonly",
1658
+ toRefs: "readonly",
1659
+ watch: "readonly",
1660
+ watchEffect: "readonly"
1661
+ }
1662
+ },
1663
+ name: "config/vue/setup",
1664
+ plugins: {
1665
+ vue: pluginVue
1666
+ }
1667
+ },
1668
+ {
1669
+ files,
1670
+ languageOptions: {
1671
+ parser: parserVue,
1672
+ parserOptions: {
1673
+ ecmaFeatures: {
1674
+ jsx: true
1675
+ },
1676
+ extraFileExtensions: [".vue"],
1677
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1678
+ sourceType: "module"
1679
+ }
1680
+ },
1681
+ name: "config/vue/rules",
1682
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors2([
1683
+ pluginVue.processors[".vue"],
1684
+ processorVueBlocks({
1685
+ ...sfcBlocks,
1686
+ blocks: {
1687
+ styles: true,
1688
+ ...sfcBlocks.blocks
1689
+ }
1690
+ })
1691
+ ]),
1692
+ rules: {
1693
+ ...pluginVue.configs.base.rules,
1694
+ ...vueVersion === 2 ? {
1695
+ ...pluginVue.configs.essential.rules,
1696
+ ...pluginVue.configs["strongly-recommended"].rules,
1697
+ ...pluginVue.configs.recommended.rules
1698
+ } : {
1699
+ ...pluginVue.configs["vue3-essential"].rules,
1700
+ ...pluginVue.configs["vue3-strongly-recommended"].rules,
1701
+ ...pluginVue.configs["vue3-recommended"].rules
1702
+ },
1703
+ "node/prefer-global/process": "off",
1704
+ "vue/block-order": ["error", {
1705
+ order: ["script", "template", "style"]
1706
+ }],
1707
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1708
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1709
+ // this is deprecated
1710
+ "vue/component-tags-order": "off",
1711
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1712
+ "vue/define-macros-order": ["error", {
1713
+ order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1714
+ }],
1715
+ "vue/dot-location": ["error", "property"],
1716
+ "vue/dot-notation": ["error", { allowKeywords: true }],
1717
+ "vue/eqeqeq": ["error", "smart"],
1718
+ "vue/html-indent": ["error", indent],
1719
+ "vue/html-quotes": ["error", "double"],
1720
+ "vue/max-attributes-per-line": "off",
1721
+ "vue/multi-word-component-names": "off",
1722
+ "vue/no-dupe-keys": "off",
1723
+ "vue/no-empty-pattern": "error",
1724
+ "vue/no-irregular-whitespace": "error",
1725
+ "vue/no-loss-of-precision": "error",
1726
+ "vue/no-restricted-syntax": [
1727
+ "error",
1728
+ "DebuggerStatement",
1729
+ "LabeledStatement",
1730
+ "WithStatement"
1731
+ ],
1732
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1733
+ "vue/no-setup-props-reactivity-loss": "off",
1734
+ "vue/no-sparse-arrays": "error",
1735
+ "vue/no-unused-refs": "error",
1736
+ "vue/no-useless-v-bind": "error",
1737
+ "vue/no-v-html": "off",
1738
+ "vue/object-shorthand": [
1739
+ "error",
1740
+ "always",
1741
+ {
1742
+ avoidQuotes: true,
1743
+ ignoreConstructors: false
1744
+ }
1745
+ ],
1746
+ "vue/prefer-separate-static-class": "error",
1747
+ "vue/prefer-template": "error",
1748
+ "vue/prop-name-casing": ["error", "camelCase"],
1749
+ "vue/require-default-prop": "off",
1750
+ "vue/require-prop-types": "off",
1751
+ "vue/space-infix-ops": "error",
1752
+ "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1753
+ ...stylistic2 ? {
1754
+ "vue/array-bracket-spacing": ["error", "never"],
1755
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
1756
+ "vue/block-spacing": ["error", "always"],
1757
+ "vue/block-tag-newline": ["error", {
1758
+ multiline: "always",
1759
+ singleline: "always"
1760
+ }],
1761
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1762
+ "vue/comma-dangle": ["error", "always-multiline"],
1763
+ "vue/comma-spacing": ["error", { after: true, before: false }],
1764
+ "vue/comma-style": ["error", "last"],
1765
+ "vue/html-comment-content-spacing": ["error", "always", {
1766
+ exceptions: ["-"]
1767
+ }],
1768
+ "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1769
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
1770
+ "vue/object-curly-newline": "off",
1771
+ "vue/object-curly-spacing": ["error", "always"],
1772
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1773
+ "vue/operator-linebreak": ["error", "before"],
1774
+ "vue/padding-line-between-blocks": ["error", "always"],
1775
+ "vue/quote-props": ["error", "consistent-as-needed"],
1776
+ "vue/space-in-parens": ["error", "never"],
1777
+ "vue/template-curly-spacing": "error"
1778
+ } : {},
1779
+ ...overrides
1780
+ }
1781
+ }
1782
+ ];
1783
+ }
1784
+
1094
1785
  // src/configs/yaml.ts
1095
1786
  async function yaml(options = {}) {
1096
1787
  const {
@@ -1111,7 +1802,7 @@ async function yaml(options = {}) {
1111
1802
  ]);
1112
1803
  return [
1113
1804
  {
1114
- name: "config:yaml:setup",
1805
+ name: "config/yaml/setup",
1115
1806
  plugins: {
1116
1807
  yaml: pluginYaml
1117
1808
  }
@@ -1121,7 +1812,7 @@ async function yaml(options = {}) {
1121
1812
  languageOptions: {
1122
1813
  parser: parserYaml
1123
1814
  },
1124
- name: "config:yaml:rules",
1815
+ name: "config/yaml/rules",
1125
1816
  rules: {
1126
1817
  "style/spaced-comment": "off",
1127
1818
  "yaml/block-mapping": "error",
@@ -1150,151 +1841,6 @@ async function yaml(options = {}) {
1150
1841
  ];
1151
1842
  }
1152
1843
 
1153
- // src/configs/test.ts
1154
- async function test(options = {}) {
1155
- const {
1156
- files = GLOB_TESTS,
1157
- isInEditor = false,
1158
- overrides = {}
1159
- } = options;
1160
- const [
1161
- pluginVitest,
1162
- pluginNoOnlyTests
1163
- ] = await Promise.all([
1164
- interopDefault(import("eslint-plugin-vitest")),
1165
- // @ts-expect-error missing types
1166
- interopDefault(import("eslint-plugin-no-only-tests"))
1167
- ]);
1168
- return [
1169
- {
1170
- name: "config:test:setup",
1171
- plugins: {
1172
- test: {
1173
- ...pluginVitest,
1174
- rules: {
1175
- ...pluginVitest.rules,
1176
- // extend `test/no-only-tests` rule
1177
- ...pluginNoOnlyTests.rules
1178
- }
1179
- }
1180
- }
1181
- },
1182
- {
1183
- files,
1184
- name: "config:test:rules",
1185
- rules: {
1186
- "node/prefer-global/process": "off",
1187
- "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1188
- "test/no-identical-title": "error",
1189
- "test/no-import-node-test": "error",
1190
- "test/no-only-tests": isInEditor ? "off" : "error",
1191
- "test/prefer-hooks-in-order": "error",
1192
- "test/prefer-lowercase-title": "error",
1193
- ...overrides
1194
- }
1195
- }
1196
- ];
1197
- }
1198
-
1199
- // src/configs/perfectionist.ts
1200
- async function perfectionist() {
1201
- return [
1202
- {
1203
- name: "config:perfectionist",
1204
- plugins: {
1205
- perfectionist: default7
1206
- }
1207
- }
1208
- ];
1209
- }
1210
-
1211
- // src/configs/unocss.ts
1212
- import { isPackageExists } from "local-pkg";
1213
- var unocssPackages = ["@unocss/eslint-plugin"];
1214
- async function unocss(options = {}) {
1215
- const {
1216
- attributify = true,
1217
- strict = false
1218
- } = options;
1219
- const unInstalled = unocssPackages.filter((i) => !isPackageExists(i));
1220
- if (unInstalled.length > 0) {
1221
- console.warn(`${unInstalled.join(", ")} is not installed, please install it first.
1222
- Run \`npm install -D ${unInstalled.join(" ")}\``);
1223
- return [];
1224
- }
1225
- const [
1226
- pluginUnoCSS
1227
- ] = await Promise.all([
1228
- interopDefault(import("@unocss/eslint-plugin"))
1229
- ]);
1230
- return [
1231
- {
1232
- name: "config:unocss",
1233
- plugins: {
1234
- unocss: pluginUnoCSS
1235
- },
1236
- rules: {
1237
- "unocss/order": "warn",
1238
- ...attributify ? {
1239
- "unocss/order-attributify": "warn"
1240
- } : {},
1241
- ...strict ? {
1242
- "unocss/blocklist": "error"
1243
- } : {}
1244
- }
1245
- }
1246
- ];
1247
- }
1248
-
1249
- // src/configs/tailwindcss.ts
1250
- import { isPackageExists as isPackageExists2 } from "local-pkg";
1251
- var tailwindPackages = ["eslint-plugin-tailwindcss"];
1252
- async function tailwindcss(options = {}) {
1253
- const { whitelist, cssFiles: cssFilesFilter, customClassNames = true } = options;
1254
- const unInstalled = tailwindPackages.filter((i) => !isPackageExists2(i));
1255
- if (unInstalled.length > 0) {
1256
- console.warn(`${unInstalled.join(", ")} is not installed, please install it first.
1257
- Run \`npm install -D ${unInstalled.join(" ")}\``);
1258
- return [];
1259
- }
1260
- const [
1261
- pluginTailwindcss
1262
- ] = await Promise.all([
1263
- interopDefault(import("eslint-plugin-tailwindcss"))
1264
- ]);
1265
- const cssFiles = cssFilesFilter ? [.../* @__PURE__ */ new Set([
1266
- "**/*.css",
1267
- "!**/node_modules",
1268
- "!**/.*",
1269
- "!**/dist",
1270
- "!**/build",
1271
- ...cssFilesFilter
1272
- ])] : void 0;
1273
- return [
1274
- {
1275
- name: "config:tailwindcss:setup",
1276
- plugins: {
1277
- tailwindcss: pluginTailwindcss
1278
- },
1279
- settings: {
1280
- tailwindcss: {
1281
- cssFiles,
1282
- whitelist
1283
- }
1284
- }
1285
- },
1286
- {
1287
- name: "config:tailwindcss:rules",
1288
- rules: {
1289
- ...pluginTailwindcss.configs.recommended.rules,
1290
- ...customClassNames ? {
1291
- "tailwindcss/no-custom-classname": "off"
1292
- } : {}
1293
- }
1294
- }
1295
- ];
1296
- }
1297
-
1298
1844
  // src/configs/toml.ts
1299
1845
  async function toml(options = {}) {
1300
1846
  const {
@@ -1314,7 +1860,7 @@ async function toml(options = {}) {
1314
1860
  ]);
1315
1861
  return [
1316
1862
  {
1317
- name: "config:toml:setup",
1863
+ name: "config/toml/setup",
1318
1864
  plugins: {
1319
1865
  toml: pluginToml
1320
1866
  }
@@ -1324,7 +1870,7 @@ async function toml(options = {}) {
1324
1870
  languageOptions: {
1325
1871
  parser: parserToml
1326
1872
  },
1327
- name: "config:toml:rules",
1873
+ name: "config/toml/rules",
1328
1874
  rules: {
1329
1875
  "style/spaced-comment": "off",
1330
1876
  "toml/comma-style": "error",
@@ -1354,227 +1900,283 @@ async function toml(options = {}) {
1354
1900
  ];
1355
1901
  }
1356
1902
 
1357
- // src/configs/formatters.ts
1358
- import { isPackageExists as isPackageExists3 } from "local-pkg";
1359
- var formatPackages = ["eslint-plugin-format"];
1360
- async function formatters(options = {}, stylistic2 = {}) {
1361
- const unInstalled = formatPackages.filter((i) => !isPackageExists3(i));
1362
- if (unInstalled.length > 0) {
1363
- console.warn(`${unInstalled.join(", ")} is not installed, please install it first.
1364
- Run \`npm install -D ${unInstalled.join(" ")}\``);
1365
- return [];
1366
- }
1367
- if (options === true) {
1368
- options = {
1369
- astro: isPackageExists3("astro"),
1370
- css: true,
1371
- graphql: true,
1372
- html: true,
1373
- markdown: true
1374
- };
1375
- }
1903
+ // src/configs/astro.ts
1904
+ async function astro(options = {}) {
1376
1905
  const {
1377
- indent,
1378
- quotes,
1379
- semi
1380
- } = {
1381
- ...StylisticConfigDefaults,
1382
- ...stylistic2
1383
- };
1384
- const prettierOptions = Object.assign(
1385
- {
1386
- endOfLine: "auto",
1387
- semi,
1388
- singleQuote: quotes === "single",
1389
- tabWidth: typeof indent === "number" ? indent : 2,
1390
- trailingComma: "all",
1391
- useTabs: indent === "tab"
1392
- },
1393
- options.prettierOptions || {}
1394
- );
1395
- const dprintOptions = Object.assign(
1396
- {
1397
- indentWidth: typeof indent === "number" ? indent : 2,
1398
- quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
1399
- useTabs: indent === "tab"
1400
- },
1401
- options.dprintOptions || {}
1402
- );
1403
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
1404
- const configs = [
1405
- {
1406
- name: "config:formatters:setup",
1407
- plugins: {
1408
- format: pluginFormat
1409
- }
1410
- }
1411
- ];
1412
- if (options.css) {
1413
- configs.push(
1414
- {
1415
- files: [GLOB_CSS, GLOB_POSTCSS],
1416
- languageOptions: {
1417
- parser: parserPlain
1418
- },
1419
- name: "config:formatter:css",
1420
- rules: {
1421
- "format/prettier": [
1422
- "error",
1423
- {
1424
- ...prettierOptions,
1425
- parser: "css"
1426
- }
1427
- ]
1428
- }
1429
- },
1430
- {
1431
- files: [GLOB_SCSS],
1432
- languageOptions: {
1433
- parser: parserPlain
1434
- },
1435
- name: "config:formatter:scss",
1436
- rules: {
1437
- "format/prettier": [
1438
- "error",
1439
- {
1440
- ...prettierOptions,
1441
- parser: "scss"
1442
- }
1443
- ]
1444
- }
1445
- },
1446
- {
1447
- files: [GLOB_LESS],
1448
- languageOptions: {
1449
- parser: parserPlain
1450
- },
1451
- name: "config:formatter:less",
1452
- rules: {
1453
- "format/prettier": [
1454
- "error",
1455
- {
1456
- ...prettierOptions,
1457
- parser: "less"
1458
- }
1459
- ]
1460
- }
1461
- }
1462
- );
1463
- }
1464
- if (options.html) {
1465
- configs.push({
1466
- files: ["**/*.html"],
1467
- languageOptions: {
1468
- parser: parserPlain
1469
- },
1470
- name: "config:formatter:html",
1471
- rules: {
1472
- "format/prettier": [
1473
- "error",
1474
- {
1475
- ...prettierOptions,
1476
- parser: "html"
1477
- }
1478
- ]
1906
+ files = [GLOB_ASTRO],
1907
+ overrides = {},
1908
+ stylistic: stylistic2 = true
1909
+ } = options;
1910
+ const [pluginAstro, parserAstro, parserTs] = await Promise.all([
1911
+ interopDefault(import("eslint-plugin-astro")),
1912
+ interopDefault(import("astro-eslint-parser")),
1913
+ interopDefault(import("@typescript-eslint/parser"))
1914
+ ]);
1915
+ return [
1916
+ {
1917
+ name: "config/astro/setup",
1918
+ plugins: {
1919
+ astro: pluginAstro
1479
1920
  }
1480
- });
1481
- }
1482
- if (options.markdown) {
1483
- const formater = options.markdown === true ? "prettier" : options.markdown;
1484
- configs.push({
1485
- files: [GLOB_MARKDOWN],
1921
+ },
1922
+ {
1923
+ files,
1486
1924
  languageOptions: {
1487
- parser: parserPlain
1925
+ parser: parserAstro,
1926
+ parserOptions: {
1927
+ extraFileExtensions: [".astro"],
1928
+ parser: parserTs
1929
+ }
1488
1930
  },
1489
- name: "config:formatter:markdown",
1931
+ name: "config/astro/rules",
1490
1932
  rules: {
1491
- [`format/${formater}`]: [
1492
- "error",
1493
- formater === "prettier" ? {
1494
- printWidth: 120,
1495
- ...prettierOptions,
1496
- embeddedLanguageFormatting: "off",
1497
- parser: "markdown"
1498
- } : {
1499
- ...dprintOptions,
1500
- language: "markdown"
1501
- }
1502
- ]
1933
+ "astro/no-set-html-directive": "off",
1934
+ "astro/semi": "off",
1935
+ ...stylistic2 ? {
1936
+ "style/indent": "off",
1937
+ "style/jsx-closing-tag-location": "off",
1938
+ "style/jsx-indent": "off",
1939
+ "style/jsx-one-expression-per-line": "off",
1940
+ "style/no-multiple-empty-lines": "off"
1941
+ } : {},
1942
+ ...overrides
1503
1943
  }
1504
- });
1944
+ }
1945
+ ];
1946
+ }
1947
+
1948
+ // src/configs/tailwindcss.ts
1949
+ import { isPackageExists as isPackageExists4 } from "local-pkg";
1950
+ var tailwindPackages = ["eslint-plugin-tailwindcss"];
1951
+ async function tailwindcss(options = {}) {
1952
+ const { whitelist, cssFiles: cssFilesFilter, customClassNames = true } = options;
1953
+ const unInstalled = tailwindPackages.filter((i) => !isPackageExists4(i));
1954
+ if (unInstalled.length > 0) {
1955
+ console.warn(`${unInstalled.join(", ")} is not installed, please install it first.
1956
+ Run \`npm install -D ${unInstalled.join(" ")}\``);
1957
+ return [];
1505
1958
  }
1506
- if (options.graphql) {
1507
- configs.push({
1508
- files: ["**/*.graphql"],
1509
- languageOptions: {
1510
- parser: parserPlain
1959
+ const [
1960
+ pluginTailwindcss
1961
+ ] = await Promise.all([
1962
+ interopDefault(import("eslint-plugin-tailwindcss"))
1963
+ ]);
1964
+ const cssFiles = cssFilesFilter ? [.../* @__PURE__ */ new Set([
1965
+ "**/*.css",
1966
+ "!**/node_modules",
1967
+ "!**/.*",
1968
+ "!**/dist",
1969
+ "!**/build",
1970
+ ...cssFilesFilter
1971
+ ])] : void 0;
1972
+ return [
1973
+ {
1974
+ name: "config/tailwindcss/setup",
1975
+ plugins: {
1976
+ tailwindcss: pluginTailwindcss
1511
1977
  },
1512
- name: "config:formatter:graphql",
1513
- rules: {
1514
- "format/prettier": [
1515
- "error",
1516
- {
1517
- ...prettierOptions,
1518
- parser: "graphql"
1519
- }
1520
- ]
1978
+ settings: {
1979
+ tailwindcss: {
1980
+ cssFiles,
1981
+ whitelist
1982
+ }
1521
1983
  }
1522
- });
1523
- }
1524
- if (options.astro) {
1525
- configs.push({
1526
- files: [GLOB_ASTRO],
1527
- languageOptions: {
1528
- parser: parserPlain
1529
- },
1530
- name: "config:formatter:astro",
1984
+ },
1985
+ {
1986
+ name: "config/tailwindcss/rules",
1531
1987
  rules: {
1532
- "format/prettier": [
1533
- "error",
1534
- {
1535
- ...prettierOptions,
1536
- parser: "astro",
1537
- plugins: [
1538
- "prettier-plugin-astro"
1539
- ]
1540
- }
1541
- ]
1988
+ ...pluginTailwindcss.configs.recommended.rules,
1989
+ ...customClassNames ? {
1990
+ "tailwindcss/no-custom-classname": "off"
1991
+ } : {}
1542
1992
  }
1543
- });
1544
- }
1545
- return configs;
1993
+ }
1994
+ ];
1546
1995
  }
1547
1996
 
1548
- // src/resolveSubOptions.ts
1549
- function resolveSubOptions(options, key) {
1550
- return typeof options[key] === "boolean" ? {} : options[key] || {};
1997
+ // src/configs/nextjs.ts
1998
+ async function nextjs(options = {}) {
1999
+ const { overrides = {}, pagesDir } = options;
2000
+ await ensurePackages(["@next/eslint-plugin-next"]);
2001
+ const nextPlugin = await interopDefault(import("@next/eslint-plugin-next"));
2002
+ return [
2003
+ {
2004
+ name: "config/nextjs/setup",
2005
+ plugins: {
2006
+ "@next/next": nextPlugin
2007
+ }
2008
+ },
2009
+ {
2010
+ name: "config/nextjs/rules",
2011
+ rules: {
2012
+ // warnings
2013
+ "@next/next/google-font-display": "warn",
2014
+ "@next/next/google-font-preconnect": "warn",
2015
+ "@next/next/next-script-for-ga": "warn",
2016
+ "@next/next/no-async-client-component": "warn",
2017
+ "@next/next/no-before-interactive-script-outside-document": "warn",
2018
+ "@next/next/no-css-tags": "warn",
2019
+ "@next/next/no-head-element": "warn",
2020
+ "@next/next/no-img-element": "warn",
2021
+ "@next/next/no-page-custom-font": "warn",
2022
+ "@next/next/no-styled-jsx-in-document": "warn",
2023
+ "@next/next/no-title-in-document-head": "warn",
2024
+ "@next/next/no-typos": "warn",
2025
+ "@next/next/no-unwanted-polyfillio": "warn",
2026
+ // errors
2027
+ "@next/next/inline-script-id": "error",
2028
+ "@next/next/no-assign-module-variable": "error",
2029
+ "@next/next/no-document-import-in-page": "error",
2030
+ "@next/next/no-duplicate-head": "error",
2031
+ "@next/next/no-head-import-in-document": "error",
2032
+ "@next/next/no-script-component-in-head": "error",
2033
+ "@next/next/no-html-link-for-pages": pagesDir ? ["warn", pagesDir] : "warn",
2034
+ "@next/next/no-sync-scripts": "warn",
2035
+ "import/no-anonymous-default-export": "warn",
2036
+ "react/no-unknown-property": "off",
2037
+ "react/react-in-jsx-scope": "off",
2038
+ "react/prop-types": "off",
2039
+ "react/jsx-no-target-blank": "off",
2040
+ "react-refresh/only-export-components": "off",
2041
+ ...overrides
2042
+ }
2043
+ }
2044
+ ];
1551
2045
  }
1552
- function getOverrides(options, key) {
1553
- const sub = resolveSubOptions(options, key);
1554
- return "overrides" in sub ? sub.overrides : {};
2046
+
2047
+ // src/configs/solid.ts
2048
+ async function solid(options = {}) {
2049
+ const {
2050
+ files = [GLOB_JSX, GLOB_TSX],
2051
+ overrides = {},
2052
+ typescript: typescript2 = true
2053
+ } = options;
2054
+ await ensurePackages(["eslint-plugin-solid"]);
2055
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
2056
+ const isTypeAware = !!tsconfigPath;
2057
+ const [
2058
+ pluginSolid,
2059
+ parserTs
2060
+ ] = await Promise.all([
2061
+ interopDefault(import("eslint-plugin-solid")),
2062
+ interopDefault(import("@typescript-eslint/parser"))
2063
+ ]);
2064
+ return [
2065
+ {
2066
+ name: "antfu/solid/setup",
2067
+ plugins: {
2068
+ solid: pluginSolid
2069
+ }
2070
+ },
2071
+ {
2072
+ files,
2073
+ languageOptions: {
2074
+ parser: parserTs,
2075
+ parserOptions: {
2076
+ ecmaFeatures: {
2077
+ jsx: true
2078
+ },
2079
+ ...isTypeAware ? { project: tsconfigPath } : {}
2080
+ },
2081
+ sourceType: "module"
2082
+ },
2083
+ name: "antfu/solid/rules",
2084
+ rules: {
2085
+ // reactivity
2086
+ "solid/components-return-once": "warn",
2087
+ "solid/event-handlers": ["error", {
2088
+ // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
2089
+ ignoreCase: false,
2090
+ // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
2091
+ warnOnSpread: false
2092
+ }],
2093
+ // these rules are mostly style suggestions
2094
+ "solid/imports": "error",
2095
+ // identifier usage is important
2096
+ "solid/jsx-no-duplicate-props": "error",
2097
+ "solid/jsx-no-script-url": "error",
2098
+ "solid/jsx-no-undef": "error",
2099
+ "solid/jsx-uses-vars": "error",
2100
+ "solid/no-array-handlers": "off",
2101
+ "solid/no-destructure": "error",
2102
+ // security problems
2103
+ "solid/no-innerhtml": ["error", { allowStatic: true }],
2104
+ // only necessary for resource-constrained environments
2105
+ "solid/no-proxy-apis": "off",
2106
+ "solid/no-react-deps": "error",
2107
+ "solid/no-react-specific-props": "error",
2108
+ "solid/no-unknown-namespaces": "error",
2109
+ // deprecated
2110
+ "solid/prefer-classlist": "off",
2111
+ "solid/prefer-for": "error",
2112
+ // handled by Solid compiler, opt-in style suggestion
2113
+ "solid/prefer-show": "off",
2114
+ "solid/reactivity": "warn",
2115
+ "solid/self-closing-comp": "error",
2116
+ "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
2117
+ ...typescript2 ? {
2118
+ "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
2119
+ "solid/no-unknown-namespaces": "off"
2120
+ } : {},
2121
+ // overrides
2122
+ ...overrides
2123
+ }
2124
+ }
2125
+ ];
1555
2126
  }
1556
2127
 
1557
- // src/preset.ts
1558
- var defaultPreset = (options) => {
2128
+ // src/factory.ts
2129
+ var flatConfigProps = [
2130
+ "name",
2131
+ "files",
2132
+ "ignores",
2133
+ "languageOptions",
2134
+ "linterOptions",
2135
+ "processor",
2136
+ "plugins",
2137
+ "rules",
2138
+ "settings"
2139
+ ];
2140
+ var VuePackages = [
2141
+ "vue",
2142
+ "nuxt",
2143
+ "vitepress",
2144
+ "vuepress"
2145
+ ];
2146
+ var defaultPluginRenaming = {
2147
+ "@stylistic": "style",
2148
+ "@typescript-eslint": "ts",
2149
+ "import-x": "import",
2150
+ "n": "node",
2151
+ "vitest": "test",
2152
+ "yml": "yaml"
2153
+ };
2154
+ function eslintFlatConfig(options = {}, ...userConfigs) {
1559
2155
  const {
1560
- componentExts,
1561
- gitignore: enableGitignore,
1562
- isInEditor,
1563
- typescript: enableTypeScript,
1564
- stylistic: stylisticOptions
2156
+ astro: enableAstro = false,
2157
+ autoRenamePlugins = true,
2158
+ componentExts = [],
2159
+ gitignore: enableGitignore = true,
2160
+ isInEditor = !!((process2.env.VSCODE_PID || process2.env.VSCODE_CWD || process2.env.JETBRAINS_IDE || process2.env.VIM) && !process2.env.CI),
2161
+ react: enableReact = false,
2162
+ nextjs: enableNextJS = false,
2163
+ svelte: enableSvelte = false,
2164
+ solid: enableSolid = false,
2165
+ typescript: enableTypeScript = isPackageExists5("typescript"),
2166
+ unocss: enableUnoCSS = false,
2167
+ tailwindcss: enableTailwindcss = false,
2168
+ vue: enableVue = VuePackages.some((i) => isPackageExists5(i))
1565
2169
  } = options;
2170
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2171
+ if (stylisticOptions && !("jsx" in stylisticOptions))
2172
+ stylisticOptions.jsx = options.jsx ?? true;
1566
2173
  const configs = [];
1567
2174
  if (enableGitignore) {
1568
2175
  if (typeof enableGitignore !== "boolean") {
1569
- configs.push(
1570
- interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)])
1571
- );
2176
+ configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1572
2177
  } else {
1573
- if (fs.existsSync(".gitignore")) {
1574
- configs.push(
1575
- interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()])
1576
- );
1577
- }
2178
+ if (fs.existsSync(".gitignore"))
2179
+ configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1578
2180
  }
1579
2181
  }
1580
2182
  configs.push(
@@ -1595,6 +2197,8 @@ var defaultPreset = (options) => {
1595
2197
  // Optional plugins (installed but not enabled by default)
1596
2198
  perfectionist()
1597
2199
  );
2200
+ if (enableVue)
2201
+ componentExts.push("vue");
1598
2202
  if (enableTypeScript) {
1599
2203
  configs.push(typescript({
1600
2204
  ...resolveSubOptions(options, "typescript"),
@@ -1604,17 +2208,68 @@ var defaultPreset = (options) => {
1604
2208
  }
1605
2209
  if (stylisticOptions) {
1606
2210
  configs.push(stylistic({
1607
- ...typeof stylisticOptions === "boolean" ? {} : stylisticOptions,
2211
+ ...stylisticOptions,
1608
2212
  overrides: getOverrides(options, "stylistic")
1609
2213
  }));
1610
2214
  }
1611
- if (options.test) {
2215
+ if (options.test ?? true) {
1612
2216
  configs.push(test({
1613
2217
  isInEditor,
1614
2218
  overrides: getOverrides(options, "test")
1615
2219
  }));
1616
2220
  }
1617
- if (options.jsonc) {
2221
+ if (enableVue) {
2222
+ configs.push(vue({
2223
+ ...resolveSubOptions(options, "vue"),
2224
+ overrides: getOverrides(options, "vue"),
2225
+ stylistic: stylisticOptions,
2226
+ typescript: !!enableTypeScript
2227
+ }));
2228
+ }
2229
+ if (enableReact) {
2230
+ configs.push(react({
2231
+ overrides: getOverrides(options, "react"),
2232
+ typescript: !!enableTypeScript
2233
+ }));
2234
+ }
2235
+ if (enableNextJS) {
2236
+ configs.push(nextjs({
2237
+ overrides: getOverrides(options, "nextjs")
2238
+ }));
2239
+ }
2240
+ if (enableSvelte) {
2241
+ configs.push(svelte({
2242
+ overrides: getOverrides(options, "svelte"),
2243
+ stylistic: stylisticOptions,
2244
+ typescript: !!enableTypeScript
2245
+ }));
2246
+ }
2247
+ if (enableSolid) {
2248
+ configs.push(solid({
2249
+ overrides: getOverrides(options, "solid"),
2250
+ tsconfigPath: getOverrides(options, "typescript").tsconfigPath,
2251
+ typescript: !!enableTypeScript
2252
+ }));
2253
+ }
2254
+ if (enableUnoCSS) {
2255
+ configs.push(unocss({
2256
+ ...resolveSubOptions(options, "unocss"),
2257
+ overrides: getOverrides(options, "unocss")
2258
+ }));
2259
+ }
2260
+ if (enableTailwindcss) {
2261
+ configs.push(tailwindcss({
2262
+ ...resolveSubOptions(options, "tailwindcss"),
2263
+ overrides: getOverrides(options, "tailwindcss")
2264
+ }));
2265
+ }
2266
+ if (enableAstro) {
2267
+ configs.push(astro({
2268
+ overrides: getOverrides(options, "astro"),
2269
+ stylistic: stylisticOptions
2270
+ }));
2271
+ }
2272
+ if (options.jsonc ?? true) {
1618
2273
  configs.push(
1619
2274
  jsonc({
1620
2275
  overrides: getOverrides(options, "jsonc"),
@@ -1624,36 +2279,26 @@ var defaultPreset = (options) => {
1624
2279
  sortTsconfig()
1625
2280
  );
1626
2281
  }
1627
- if (options.yaml) {
2282
+ if (options.yaml ?? true) {
1628
2283
  configs.push(yaml({
1629
2284
  overrides: getOverrides(options, "yaml"),
1630
2285
  stylistic: stylisticOptions
1631
2286
  }));
1632
2287
  }
1633
- if (options.toml) {
2288
+ if (options.toml ?? true) {
1634
2289
  configs.push(toml({
1635
2290
  overrides: getOverrides(options, "toml"),
1636
2291
  stylistic: stylisticOptions
1637
2292
  }));
1638
2293
  }
1639
- if (options.unocss) {
1640
- configs.push(unocss({
1641
- ...resolveSubOptions(options, "unocss"),
1642
- overrides: getOverrides(options, "unocss")
1643
- }));
1644
- }
1645
- if (options.tailwindcss) {
1646
- configs.push(tailwindcss({
1647
- ...resolveSubOptions(options, "tailwindcss"),
1648
- overrides: getOverrides(options, "tailwindcss")
1649
- }));
1650
- }
1651
- if (options.markdown) {
2294
+ if (options.markdown ?? true) {
1652
2295
  configs.push(
1653
- markdown({
1654
- componentExts,
1655
- overrides: getOverrides(options, "markdown")
1656
- })
2296
+ markdown(
2297
+ {
2298
+ componentExts,
2299
+ overrides: getOverrides(options, "markdown")
2300
+ }
2301
+ )
1657
2302
  );
1658
2303
  }
1659
2304
  if (options.formatters) {
@@ -1662,84 +2307,6 @@ var defaultPreset = (options) => {
1662
2307
  typeof stylisticOptions === "boolean" ? {} : stylisticOptions
1663
2308
  ));
1664
2309
  }
1665
- return configs;
1666
- };
1667
-
1668
- // src/resolvedOptions.ts
1669
- import process2 from "process";
1670
- import { isPackageExists as isPackageExists4 } from "local-pkg";
1671
- var VuePackages = [
1672
- "vue",
1673
- "nuxt",
1674
- "vitepress",
1675
- "@slidev/cli"
1676
- ];
1677
- function resolveOptions(options = {}) {
1678
- const {
1679
- componentExts = [],
1680
- preset = [],
1681
- gitignore = true,
1682
- isInEditor = !!((process2.env.VSCODE_PID || process2.env.VSCODE_CWD || process2.env.JETBRAINS_IDE || process2.env.VIM) && !process2.env.CI),
1683
- typescript: typescript2 = isPackageExists4("typescript"),
1684
- jsx = true,
1685
- test: test2 = true,
1686
- jsonc: jsonc2 = true,
1687
- yaml: yaml2 = true,
1688
- toml: toml2 = true,
1689
- markdown: markdown2 = true,
1690
- formatters: formatters2 = false,
1691
- unocss: enableUnocss = false,
1692
- tailwindcss: enableTailwindcss = false
1693
- } = options;
1694
- const stylistic2 = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1695
- if (stylistic2 && !("jsx" in stylistic2))
1696
- stylistic2.jsx = options.jsx ?? true;
1697
- const unocss2 = enableUnocss === false ? false : typeof enableUnocss === "object" ? enableUnocss : {};
1698
- const tailwindcss2 = enableTailwindcss === false ? false : typeof enableTailwindcss === "object" ? enableTailwindcss : {};
1699
- if (VuePackages.some((i) => isPackageExists4(i)))
1700
- componentExts.push("vue");
1701
- if (isPackageExists4("astro"))
1702
- componentExts.push("astro");
1703
- if (isPackageExists4("svelte"))
1704
- componentExts.push("svelte");
1705
- return {
1706
- ...options,
1707
- componentExts,
1708
- preset,
1709
- gitignore,
1710
- isInEditor,
1711
- typescript: typescript2,
1712
- stylistic: stylistic2,
1713
- jsx,
1714
- test: test2,
1715
- jsonc: jsonc2,
1716
- toml: toml2,
1717
- yaml: yaml2,
1718
- markdown: markdown2,
1719
- unocss: unocss2,
1720
- tailwindcss: tailwindcss2,
1721
- formatters: formatters2
1722
- };
1723
- }
1724
-
1725
- // src/factory.ts
1726
- var flatConfigProps = [
1727
- "name",
1728
- "files",
1729
- "ignores",
1730
- "languageOptions",
1731
- "linterOptions",
1732
- "processor",
1733
- "plugins",
1734
- "rules",
1735
- "settings"
1736
- ];
1737
- function eslintFlatConfig(options = {}, ...userConfigs) {
1738
- const { preset = [], ...resolvedOptions } = resolveOptions(options);
1739
- const presetList = Array.from(/* @__PURE__ */ new Set([defaultPreset, ...preset]));
1740
- const configs = [];
1741
- for (const preset2 of presetList)
1742
- configs.push(...preset2(resolvedOptions));
1743
2310
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1744
2311
  if (key in options)
1745
2312
  acc[key] = options[key];
@@ -1747,21 +2314,23 @@ function eslintFlatConfig(options = {}, ...userConfigs) {
1747
2314
  }, {});
1748
2315
  if (Object.keys(fusedConfig).length)
1749
2316
  configs.push([fusedConfig]);
1750
- const merged = combine(
2317
+ let pipeline = new FlatConfigComposer();
2318
+ pipeline = pipeline.append(
1751
2319
  ...configs,
1752
2320
  ...userConfigs
1753
2321
  );
1754
- return merged;
2322
+ if (autoRenamePlugins) {
2323
+ pipeline = pipeline.renamePlugins(defaultPluginRenaming);
2324
+ }
2325
+ return pipeline;
1755
2326
  }
1756
-
1757
- // src/createConfig.ts
1758
- function createConfig(preset) {
1759
- return function(options = {}, ...userConfigs) {
1760
- const userPreset = options.preset || [];
1761
- const presetList = Array.isArray(preset) ? preset : [preset];
1762
- presetList.push(...userPreset);
1763
- options.preset = presetList;
1764
- return eslintFlatConfig(options, ...userConfigs);
2327
+ function resolveSubOptions(options, key) {
2328
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
2329
+ }
2330
+ function getOverrides(options, key) {
2331
+ const sub = resolveSubOptions(options, key);
2332
+ return {
2333
+ ..."overrides" in sub ? sub.overrides : {}
1765
2334
  };
1766
2335
  }
1767
2336
 
@@ -1772,6 +2341,7 @@ export {
1772
2341
  GLOB_ASTRO,
1773
2342
  GLOB_CSS,
1774
2343
  GLOB_EXCLUDE,
2344
+ GLOB_GRAPHQL,
1775
2345
  GLOB_HTML,
1776
2346
  GLOB_JS,
1777
2347
  GLOB_JSON,
@@ -1795,11 +2365,13 @@ export {
1795
2365
  GLOB_VUE,
1796
2366
  GLOB_YAML,
1797
2367
  StylisticConfigDefaults,
2368
+ astro,
1798
2369
  combine,
1799
2370
  comments,
1800
- createConfig,
1801
2371
  src_default as default,
1802
- defaultPreset,
2372
+ defaultPluginRenaming,
2373
+ ensurePackages,
2374
+ eslintFlatConfig,
1803
2375
  formatters,
1804
2376
  getOverrides,
1805
2377
  ignores,
@@ -1809,6 +2381,7 @@ export {
1809
2381
  jsdoc,
1810
2382
  jsonc,
1811
2383
  markdown,
2384
+ nextjs,
1812
2385
  node,
1813
2386
  parserPlain,
1814
2387
  perfectionist,
@@ -1819,11 +2392,15 @@ export {
1819
2392
  default7 as pluginPerfectionist,
1820
2393
  default5 as pluginUnicorn,
1821
2394
  default6 as pluginUnusedImports,
2395
+ react,
2396
+ renamePluginInConfigs,
1822
2397
  renameRules,
1823
2398
  resolveSubOptions,
2399
+ solid,
1824
2400
  sortPackageJson,
1825
2401
  sortTsconfig,
1826
2402
  stylistic,
2403
+ svelte,
1827
2404
  tailwindcss,
1828
2405
  test,
1829
2406
  toArray,
@@ -1831,5 +2408,6 @@ export {
1831
2408
  typescript,
1832
2409
  unicorn,
1833
2410
  unocss,
2411
+ vue,
1834
2412
  yaml
1835
2413
  };