@dhzh/eslint-config 0.1.3 → 0.2.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
@@ -2,7 +2,7 @@
2
2
  import process3 from "node:process";
3
3
  import fs from "node:fs";
4
4
  import { isPackageExists as isPackageExists4 } from "local-pkg";
5
- import { FlatConfigPipeline } from "eslint-flat-config-utils";
5
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
6
6
 
7
7
  // src/plugins.ts
8
8
  import { default as default2 } from "eslint-plugin-antfu";
@@ -17,7 +17,7 @@ import { default as default7 } from "eslint-plugin-perfectionist";
17
17
  async function comments() {
18
18
  return [
19
19
  {
20
- name: "antfu:eslint-comments",
20
+ name: "antfu/eslint-comments/rules",
21
21
  plugins: {
22
22
  "eslint-comments": default3
23
23
  },
@@ -111,6 +111,8 @@ async function ignores() {
111
111
  return [
112
112
  {
113
113
  ignores: GLOB_EXCLUDE
114
+ // Awaits https://github.com/humanwhocodes/config-array/pull/131
115
+ // name: 'antfu/ignores',
114
116
  }
115
117
  ];
116
118
  }
@@ -122,7 +124,7 @@ async function imports(options = {}) {
122
124
  } = options;
123
125
  return [
124
126
  {
125
- name: "antfu:imports",
127
+ name: "antfu/imports/rules",
126
128
  plugins: {
127
129
  antfu: default2,
128
130
  import: pluginImport
@@ -145,7 +147,7 @@ async function imports(options = {}) {
145
147
  },
146
148
  {
147
149
  files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
148
- name: "antfu:imports:bin",
150
+ name: "antfu/imports/disables/bin",
149
151
  rules: {
150
152
  "antfu/no-import-dist": "off",
151
153
  "antfu/no-import-node-modules-by-path": "off"
@@ -185,7 +187,7 @@ async function javascript(options = {}) {
185
187
  linterOptions: {
186
188
  reportUnusedDisableDirectives: true
187
189
  },
188
- name: "antfu:javascript",
190
+ name: "antfu/javascript/rules",
189
191
  plugins: {
190
192
  "antfu": default2,
191
193
  "unused-imports": default6
@@ -239,7 +241,7 @@ async function javascript(options = {}) {
239
241
  "no-multi-str": "error",
240
242
  "no-new": "error",
241
243
  "no-new-func": "error",
242
- "no-new-symbol": "error",
244
+ "no-new-native-nonconstructor": "error",
243
245
  "no-new-wrappers": "error",
244
246
  "no-obj-calls": "error",
245
247
  "no-octal": "error",
@@ -351,7 +353,13 @@ async function javascript(options = {}) {
351
353
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
352
354
  "unused-imports/no-unused-vars": [
353
355
  "error",
354
- { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
356
+ {
357
+ args: "after-used",
358
+ argsIgnorePattern: "^_",
359
+ ignoreRestSiblings: true,
360
+ vars: "all",
361
+ varsIgnorePattern: "^_"
362
+ }
355
363
  ],
356
364
  "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
357
365
  "valid-typeof": ["error", { requireStringLiterals: true }],
@@ -362,7 +370,7 @@ async function javascript(options = {}) {
362
370
  },
363
371
  {
364
372
  files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
365
- name: "antfu:scripts-overrides",
373
+ name: "antfu/javascript/disables/cli",
366
374
  rules: {
367
375
  "no-console": "off"
368
376
  }
@@ -401,8 +409,9 @@ function renameRules(rules, map) {
401
409
  return Object.fromEntries(
402
410
  Object.entries(rules).map(([key, value]) => {
403
411
  for (const [from, to] of Object.entries(map)) {
404
- if (key.startsWith(`${from}/`))
412
+ if (key.startsWith(`${from}/`)) {
405
413
  return [to + key.slice(from.length), value];
414
+ }
406
415
  }
407
416
  return [key, value];
408
417
  })
@@ -411,13 +420,15 @@ function renameRules(rules, map) {
411
420
  function renamePluginInConfigs(configs, map) {
412
421
  return configs.map((i) => {
413
422
  const clone = { ...i };
414
- if (clone.rules)
423
+ if (clone.rules) {
415
424
  clone.rules = renameRules(clone.rules, map);
425
+ }
416
426
  if (clone.plugins) {
417
427
  clone.plugins = Object.fromEntries(
418
428
  Object.entries(clone.plugins).map(([key, value]) => {
419
- if (key in map)
429
+ if (key in map) {
420
430
  return [map[key], value];
431
+ }
421
432
  return [key, value];
422
433
  })
423
434
  );
@@ -433,17 +444,20 @@ async function interopDefault(m) {
433
444
  return resolved.default || resolved;
434
445
  }
435
446
  async function ensurePackages(packages) {
436
- if (process.env.CI || process.stdout.isTTY === false)
447
+ if (process.env.CI || process.stdout.isTTY === false) {
437
448
  return;
449
+ }
438
450
  const nonExistingPackages = packages.filter((i) => i && !isPackageExists(i));
439
- if (nonExistingPackages.length === 0)
451
+ if (nonExistingPackages.length === 0) {
440
452
  return;
453
+ }
441
454
  const p = await import("@clack/prompts");
442
455
  const result = await p.confirm({
443
456
  message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
444
457
  });
445
- if (result)
458
+ if (result) {
446
459
  await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
460
+ }
447
461
  }
448
462
 
449
463
  // src/configs/jsdoc.ts
@@ -453,7 +467,7 @@ async function jsdoc(options = {}) {
453
467
  } = options;
454
468
  return [
455
469
  {
456
- name: "antfu:jsdoc",
470
+ name: "antfu/jsdoc/rules",
457
471
  plugins: {
458
472
  jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
459
473
  },
@@ -501,7 +515,7 @@ async function jsonc(options = {}) {
501
515
  ]);
502
516
  return [
503
517
  {
504
- name: "antfu:jsonc:setup",
518
+ name: "antfu/jsonc/setup",
505
519
  plugins: {
506
520
  jsonc: pluginJsonc
507
521
  }
@@ -511,7 +525,7 @@ async function jsonc(options = {}) {
511
525
  languageOptions: {
512
526
  parser: parserJsonc
513
527
  },
514
- name: "antfu:jsonc:rules",
528
+ name: "antfu/jsonc/rules",
515
529
  rules: {
516
530
  "jsonc/no-bigint-literals": "error",
517
531
  "jsonc/no-binary-expression": "error",
@@ -568,7 +582,7 @@ async function markdown(options = {}) {
568
582
  const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
569
583
  return [
570
584
  {
571
- name: "antfu:markdown:setup",
585
+ name: "antfu/markdown/setup",
572
586
  plugins: {
573
587
  markdown: markdown2
574
588
  }
@@ -576,7 +590,7 @@ async function markdown(options = {}) {
576
590
  {
577
591
  files,
578
592
  ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
579
- name: "antfu:markdown:processor",
593
+ name: "antfu/markdown/processor",
580
594
  // `eslint-plugin-markdown` only creates virtual files for code blocks,
581
595
  // but not the markdown file itself. We use `eslint-merge-processors` to
582
596
  // add a pass-through processor for the markdown file itself.
@@ -590,7 +604,7 @@ async function markdown(options = {}) {
590
604
  languageOptions: {
591
605
  parser: parserPlain
592
606
  },
593
- name: "antfu:markdown:parser"
607
+ name: "antfu/markdown/parser"
594
608
  },
595
609
  {
596
610
  files: [
@@ -604,7 +618,7 @@ async function markdown(options = {}) {
604
618
  }
605
619
  }
606
620
  },
607
- name: "antfu:markdown:disables",
621
+ name: "antfu/markdown/disables",
608
622
  rules: {
609
623
  "import/newline-after-import": "off",
610
624
  "no-alert": "off",
@@ -658,7 +672,7 @@ async function markdown(options = {}) {
658
672
  async function node() {
659
673
  return [
660
674
  {
661
- name: "antfu:node",
675
+ name: "antfu/node/rules",
662
676
  plugins: {
663
677
  node: default4
664
678
  },
@@ -680,7 +694,7 @@ async function node() {
680
694
  async function perfectionist() {
681
695
  return [
682
696
  {
683
- name: "antfu:perfectionist",
697
+ name: "antfu/perfectionist/setup",
684
698
  plugins: {
685
699
  perfectionist: default7
686
700
  }
@@ -702,6 +716,7 @@ async function stylistic(options = {}) {
702
716
  const {
703
717
  indent,
704
718
  jsx,
719
+ lessOpinionated = false,
705
720
  overrides = {},
706
721
  quotes,
707
722
  semi
@@ -722,7 +737,7 @@ async function stylistic(options = {}) {
722
737
  });
723
738
  return [
724
739
  {
725
- name: "antfu:stylistic",
740
+ name: "antfu/stylistic/rules",
726
741
  plugins: {
727
742
  antfu: default2,
728
743
  style: pluginStylistic
@@ -730,9 +745,13 @@ async function stylistic(options = {}) {
730
745
  rules: {
731
746
  ...config.rules,
732
747
  "antfu/consistent-list-newline": "error",
733
- "antfu/if-newline": "error",
734
- "antfu/top-level-function": "error",
735
- "curly": ["error", "all"],
748
+ ...lessOpinionated ? {
749
+ curly: ["error", "all"]
750
+ } : {
751
+ "antfu/if-newline": "error",
752
+ "antfu/top-level-function": "off",
753
+ "curly": ["error", "all"]
754
+ },
736
755
  ...overrides
737
756
  }
738
757
  }
@@ -756,8 +775,9 @@ async function formatters(options = {}, stylistic2 = {}) {
756
775
  options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
757
776
  options.astro ? "prettier-plugin-astro" : void 0
758
777
  ]);
759
- if (options.slidev && options.markdown !== true && options.markdown !== "prettier")
778
+ if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
760
779
  throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
780
+ }
761
781
  const {
762
782
  indent,
763
783
  quotes,
@@ -788,7 +808,7 @@ async function formatters(options = {}, stylistic2 = {}) {
788
808
  const pluginFormat = await interopDefault(import("eslint-plugin-format"));
789
809
  const configs = [
790
810
  {
791
- name: "antfu:formatters:setup",
811
+ name: "antfu/formatter/setup",
792
812
  plugins: {
793
813
  format: pluginFormat
794
814
  }
@@ -801,7 +821,7 @@ async function formatters(options = {}, stylistic2 = {}) {
801
821
  languageOptions: {
802
822
  parser: parserPlain
803
823
  },
804
- name: "antfu:formatter:css",
824
+ name: "antfu/formatter/css",
805
825
  rules: {
806
826
  "format/prettier": [
807
827
  "error",
@@ -817,7 +837,7 @@ async function formatters(options = {}, stylistic2 = {}) {
817
837
  languageOptions: {
818
838
  parser: parserPlain
819
839
  },
820
- name: "antfu:formatter:scss",
840
+ name: "antfu/formatter/scss",
821
841
  rules: {
822
842
  "format/prettier": [
823
843
  "error",
@@ -833,7 +853,7 @@ async function formatters(options = {}, stylistic2 = {}) {
833
853
  languageOptions: {
834
854
  parser: parserPlain
835
855
  },
836
- name: "antfu:formatter:less",
856
+ name: "antfu/formatter/less",
837
857
  rules: {
838
858
  "format/prettier": [
839
859
  "error",
@@ -848,11 +868,11 @@ async function formatters(options = {}, stylistic2 = {}) {
848
868
  }
849
869
  if (options.html) {
850
870
  configs.push({
851
- files: ["**/*.html"],
871
+ files: [GLOB_HTML],
852
872
  languageOptions: {
853
873
  parser: parserPlain
854
874
  },
855
- name: "antfu:formatter:html",
875
+ name: "antfu/formatter/html",
856
876
  rules: {
857
877
  "format/prettier": [
858
878
  "error",
@@ -873,7 +893,7 @@ async function formatters(options = {}, stylistic2 = {}) {
873
893
  languageOptions: {
874
894
  parser: parserPlain
875
895
  },
876
- name: "antfu:formatter:markdown",
896
+ name: "antfu/formatter/markdown",
877
897
  rules: {
878
898
  [`format/${formater}`]: [
879
899
  "error",
@@ -895,7 +915,7 @@ async function formatters(options = {}, stylistic2 = {}) {
895
915
  languageOptions: {
896
916
  parser: parserPlain
897
917
  },
898
- name: "antfu:formatter:slidev",
918
+ name: "antfu/formatter/slidev",
899
919
  rules: {
900
920
  "format/prettier": [
901
921
  "error",
@@ -919,7 +939,7 @@ async function formatters(options = {}, stylistic2 = {}) {
919
939
  languageOptions: {
920
940
  parser: parserPlain
921
941
  },
922
- name: "antfu:formatter:astro",
942
+ name: "antfu/formatter/astro",
923
943
  rules: {
924
944
  "format/prettier": [
925
945
  "error",
@@ -940,7 +960,7 @@ async function formatters(options = {}, stylistic2 = {}) {
940
960
  languageOptions: {
941
961
  parser: parserPlain
942
962
  },
943
- name: "antfu:formatter:graphql",
963
+ name: "antfu/formatter/graphql",
944
964
  rules: {
945
965
  "format/prettier": [
946
966
  "error",
@@ -985,7 +1005,7 @@ async function react(options = {}) {
985
1005
  );
986
1006
  return [
987
1007
  {
988
- name: "antfu:react:setup",
1008
+ name: "antfu/react/setup",
989
1009
  plugins: {
990
1010
  "react": pluginReact,
991
1011
  "react-hooks": pluginReactHooks,
@@ -1006,7 +1026,7 @@ async function react(options = {}) {
1006
1026
  }
1007
1027
  }
1008
1028
  },
1009
- name: "antfu:react:rules",
1029
+ name: "antfu/react/rules",
1010
1030
  rules: {
1011
1031
  // recommended rules react-hooks
1012
1032
  "react-hooks/exhaustive-deps": "warn",
@@ -1055,7 +1075,7 @@ async function sortPackageJson() {
1055
1075
  return [
1056
1076
  {
1057
1077
  files: ["**/package.json"],
1058
- name: "antfu:sort-package-json",
1078
+ name: "antfu/sort/package-json",
1059
1079
  rules: {
1060
1080
  "jsonc/sort-array-values": [
1061
1081
  "error",
@@ -1156,7 +1176,7 @@ function sortTsconfig() {
1156
1176
  return [
1157
1177
  {
1158
1178
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1159
- name: "antfu:sort-tsconfig",
1179
+ name: "antfu/sort/tsconfig-json",
1160
1180
  rules: {
1161
1181
  "jsonc/sort-keys": [
1162
1182
  "error",
@@ -1301,7 +1321,7 @@ async function svelte(options = {}) {
1301
1321
  ]);
1302
1322
  return [
1303
1323
  {
1304
- name: "antfu:svelte:setup",
1324
+ name: "antfu/svelte/setup",
1305
1325
  plugins: {
1306
1326
  svelte: pluginSvelte
1307
1327
  }
@@ -1315,7 +1335,7 @@ async function svelte(options = {}) {
1315
1335
  parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1316
1336
  }
1317
1337
  },
1318
- name: "antfu:svelte:rules",
1338
+ name: "antfu/svelte/rules",
1319
1339
  processor: pluginSvelte.processors[".svelte"],
1320
1340
  rules: {
1321
1341
  "import/no-mutable-exports": "off",
@@ -1326,7 +1346,7 @@ async function svelte(options = {}) {
1326
1346
  caughtErrors: "none",
1327
1347
  ignoreRestSiblings: true,
1328
1348
  vars: "all",
1329
- varsIgnorePattern: "^\\$\\$Props$"
1349
+ varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1330
1350
  }],
1331
1351
  "svelte/comment-directive": "error",
1332
1352
  "svelte/no-at-debug-tags": "warn",
@@ -1351,7 +1371,7 @@ async function svelte(options = {}) {
1351
1371
  "svelte/valid-each-key": "error",
1352
1372
  "unused-imports/no-unused-vars": [
1353
1373
  "error",
1354
- { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
1374
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)" }
1355
1375
  ],
1356
1376
  ...stylistic2 ? {
1357
1377
  "style/indent": "off",
@@ -1374,6 +1394,7 @@ async function svelte(options = {}) {
1374
1394
  }
1375
1395
 
1376
1396
  // src/configs/test.ts
1397
+ var _pluginTest;
1377
1398
  async function test(options = {}) {
1378
1399
  const {
1379
1400
  files = GLOB_TESTS,
@@ -1388,23 +1409,24 @@ async function test(options = {}) {
1388
1409
  // @ts-expect-error missing types
1389
1410
  interopDefault(import("eslint-plugin-no-only-tests"))
1390
1411
  ]);
1412
+ _pluginTest = _pluginTest || {
1413
+ ...pluginVitest,
1414
+ rules: {
1415
+ ...pluginVitest.rules,
1416
+ // extend `test/no-only-tests` rule
1417
+ ...pluginNoOnlyTests.rules
1418
+ }
1419
+ };
1391
1420
  return [
1392
1421
  {
1393
- name: "antfu:test:setup",
1422
+ name: "antfu/test/setup",
1394
1423
  plugins: {
1395
- test: {
1396
- ...pluginVitest,
1397
- rules: {
1398
- ...pluginVitest.rules,
1399
- // extend `test/no-only-tests` rule
1400
- ...pluginNoOnlyTests.rules
1401
- }
1402
- }
1424
+ test: _pluginTest
1403
1425
  }
1404
1426
  },
1405
1427
  {
1406
1428
  files,
1407
- name: "antfu:test:rules",
1429
+ name: "antfu/test/rules",
1408
1430
  rules: {
1409
1431
  "node/prefer-global/process": "off",
1410
1432
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
@@ -1478,13 +1500,13 @@ async function typescript(options = {}) {
1478
1500
  ...parserOptions
1479
1501
  }
1480
1502
  },
1481
- name: `antfu:typescript:${typeAware ? "type-aware-parser" : "parser"}`
1503
+ name: `antfu/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1482
1504
  };
1483
1505
  }
1484
1506
  return [
1485
1507
  {
1486
1508
  // Install the plugins without globs, so they can be configured separately.
1487
- name: "antfu:typescript:setup",
1509
+ name: "antfu/typescript/setup",
1488
1510
  plugins: {
1489
1511
  antfu: default2,
1490
1512
  ts: pluginTs
@@ -1497,7 +1519,7 @@ async function typescript(options = {}) {
1497
1519
  ] : [makeParser(false, files)],
1498
1520
  {
1499
1521
  files,
1500
- name: "antfu:typescript:rules",
1522
+ name: "antfu/typescript/rules",
1501
1523
  rules: {
1502
1524
  ...renameRules(
1503
1525
  pluginTs.configs["eslint-recommended"].overrides[0].rules,
@@ -1537,17 +1559,17 @@ async function typescript(options = {}) {
1537
1559
  ...overrides
1538
1560
  }
1539
1561
  },
1540
- {
1562
+ ...isTypeAware ? [{
1541
1563
  files: filesTypeAware,
1542
- name: "antfu:typescript:rules-type-aware",
1564
+ name: "antfu/typescript/rules-type-aware",
1543
1565
  rules: {
1544
1566
  ...tsconfigPath ? typeAwareRules : {},
1545
1567
  ...overrides
1546
1568
  }
1547
- },
1569
+ }] : [],
1548
1570
  {
1549
1571
  files: ["**/*.d.ts"],
1550
- name: "antfu:typescript:dts-overrides",
1572
+ name: "antfu/typescript/disables/dts",
1551
1573
  rules: {
1552
1574
  "eslint-comments/no-unlimited-disable": "off",
1553
1575
  "import/no-duplicates": "off",
@@ -1557,14 +1579,14 @@ async function typescript(options = {}) {
1557
1579
  },
1558
1580
  {
1559
1581
  files: ["**/*.{test,spec}.ts?(x)"],
1560
- name: "antfu:typescript:tests-overrides",
1582
+ name: "antfu/typescript/disables/test",
1561
1583
  rules: {
1562
1584
  "no-unused-expressions": "off"
1563
1585
  }
1564
1586
  },
1565
1587
  {
1566
1588
  files: ["**/*.js", "**/*.cjs"],
1567
- name: "antfu:typescript:javascript-overrides",
1589
+ name: "antfu/typescript/disables/cjs",
1568
1590
  rules: {
1569
1591
  "ts/no-require-imports": "off",
1570
1592
  "ts/no-var-requires": "off"
@@ -1577,7 +1599,7 @@ async function typescript(options = {}) {
1577
1599
  async function unicorn() {
1578
1600
  return [
1579
1601
  {
1580
- name: "antfu:unicorn",
1602
+ name: "antfu/unicorn/rules",
1581
1603
  plugins: {
1582
1604
  unicorn: default5
1583
1605
  },
@@ -1629,7 +1651,7 @@ async function unocss(options = {}) {
1629
1651
  ]);
1630
1652
  return [
1631
1653
  {
1632
- name: "antfu:unocss",
1654
+ name: "antfu/unocss",
1633
1655
  plugins: {
1634
1656
  unocss: pluginUnoCSS
1635
1657
  },
@@ -1691,7 +1713,7 @@ async function vue(options = {}) {
1691
1713
  watchEffect: "readonly"
1692
1714
  }
1693
1715
  },
1694
- name: "antfu:vue:setup",
1716
+ name: "antfu/vue/setup",
1695
1717
  plugins: {
1696
1718
  vue: pluginVue
1697
1719
  }
@@ -1709,7 +1731,7 @@ async function vue(options = {}) {
1709
1731
  sourceType: "module"
1710
1732
  }
1711
1733
  },
1712
- name: "antfu:vue:rules",
1734
+ name: "antfu/vue/rules",
1713
1735
  processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors2([
1714
1736
  pluginVue.processors[".vue"],
1715
1737
  processorVueBlocks({
@@ -1833,7 +1855,7 @@ async function yaml(options = {}) {
1833
1855
  ]);
1834
1856
  return [
1835
1857
  {
1836
- name: "antfu:yaml:setup",
1858
+ name: "antfu/yaml/setup",
1837
1859
  plugins: {
1838
1860
  yaml: pluginYaml
1839
1861
  }
@@ -1843,7 +1865,7 @@ async function yaml(options = {}) {
1843
1865
  languageOptions: {
1844
1866
  parser: parserYaml
1845
1867
  },
1846
- name: "antfu:yaml:rules",
1868
+ name: "antfu/yaml/rules",
1847
1869
  rules: {
1848
1870
  "style/spaced-comment": "off",
1849
1871
  "yaml/block-mapping": "error",
@@ -1891,7 +1913,7 @@ async function toml(options = {}) {
1891
1913
  ]);
1892
1914
  return [
1893
1915
  {
1894
- name: "antfu:toml:setup",
1916
+ name: "antfu/toml/setup",
1895
1917
  plugins: {
1896
1918
  toml: pluginToml
1897
1919
  }
@@ -1901,7 +1923,7 @@ async function toml(options = {}) {
1901
1923
  languageOptions: {
1902
1924
  parser: parserToml
1903
1925
  },
1904
- name: "antfu:toml:rules",
1926
+ name: "antfu/toml/rules",
1905
1927
  rules: {
1906
1928
  "style/spaced-comment": "off",
1907
1929
  "toml/comma-style": "error",
@@ -1949,7 +1971,7 @@ async function astro(options = {}) {
1949
1971
  ]);
1950
1972
  return [
1951
1973
  {
1952
- name: "antfu:astro:setup",
1974
+ name: "antfu/astro/setup",
1953
1975
  plugins: {
1954
1976
  astro: pluginAstro
1955
1977
  }
@@ -1963,7 +1985,7 @@ async function astro(options = {}) {
1963
1985
  parser: parserTs
1964
1986
  }
1965
1987
  },
1966
- name: "antfu:astro:rules",
1988
+ name: "antfu/astro/rules",
1967
1989
  rules: {
1968
1990
  "astro/no-set-html-directive": "off",
1969
1991
  "astro/semi": "off",
@@ -1980,6 +2002,82 @@ async function astro(options = {}) {
1980
2002
  ];
1981
2003
  }
1982
2004
 
2005
+ // src/configs/solid.ts
2006
+ async function solid(options = {}) {
2007
+ const {
2008
+ files = [GLOB_JSX, GLOB_TSX],
2009
+ overrides = {},
2010
+ typescript: typescript2 = true
2011
+ } = options;
2012
+ await ensurePackages([
2013
+ "eslint-plugin-solid"
2014
+ ]);
2015
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
2016
+ const isTypeAware = !!tsconfigPath;
2017
+ const [
2018
+ pluginSolid,
2019
+ parserTs
2020
+ ] = await Promise.all([
2021
+ interopDefault(import("eslint-plugin-solid")),
2022
+ interopDefault(import("@typescript-eslint/parser"))
2023
+ ]);
2024
+ return [
2025
+ {
2026
+ name: "antfu/solid/setup",
2027
+ plugins: {
2028
+ solid: pluginSolid
2029
+ }
2030
+ },
2031
+ {
2032
+ files,
2033
+ languageOptions: {
2034
+ parser: parserTs,
2035
+ parserOptions: {
2036
+ ecmaFeatures: {
2037
+ jsx: true
2038
+ },
2039
+ ...isTypeAware ? { project: tsconfigPath } : {}
2040
+ },
2041
+ sourceType: "module"
2042
+ },
2043
+ name: "antfu/solid/rules",
2044
+ rules: {
2045
+ // reactivity
2046
+ "solid/components-return-once": "warn",
2047
+ "solid/event-handlers": ["error", {
2048
+ // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
2049
+ ignoreCase: false,
2050
+ // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
2051
+ warnOnSpread: false
2052
+ }],
2053
+ // these rules are mostly style suggestions
2054
+ "solid/imports": "error",
2055
+ // identifier usage is important
2056
+ "solid/jsx-no-duplicate-props": "error",
2057
+ "solid/jsx-no-script-url": "error",
2058
+ "solid/jsx-no-undef": "error",
2059
+ "solid/jsx-uses-vars": "error",
2060
+ "solid/no-destructure": "error",
2061
+ // security problems
2062
+ "solid/no-innerhtml": ["error", { allowStatic: true }],
2063
+ "solid/no-react-deps": "error",
2064
+ "solid/no-react-specific-props": "error",
2065
+ "solid/no-unknown-namespaces": "error",
2066
+ "solid/prefer-for": "error",
2067
+ "solid/reactivity": "warn",
2068
+ "solid/self-closing-comp": "error",
2069
+ "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
2070
+ ...typescript2 ? {
2071
+ "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
2072
+ "solid/no-unknown-namespaces": "off"
2073
+ } : {},
2074
+ // overrides
2075
+ ...overrides
2076
+ }
2077
+ }
2078
+ ];
2079
+ }
2080
+
1983
2081
  // src/factory.ts
1984
2082
  var flatConfigProps = [
1985
2083
  "name",
@@ -2014,21 +2112,24 @@ function dhzh(options = {}, ...userConfigs) {
2014
2112
  gitignore: enableGitignore = true,
2015
2113
  isInEditor = !!((process3.env.VSCODE_PID || process3.env.VSCODE_CWD || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
2016
2114
  react: enableReact = false,
2115
+ solid: enableSolid = false,
2017
2116
  svelte: enableSvelte = false,
2018
2117
  typescript: enableTypeScript = isPackageExists4("typescript"),
2019
2118
  unocss: enableUnoCSS = false,
2020
2119
  vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
2021
2120
  } = options;
2022
2121
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2023
- if (stylisticOptions && !("jsx" in stylisticOptions))
2122
+ if (stylisticOptions && !("jsx" in stylisticOptions)) {
2024
2123
  stylisticOptions.jsx = options.jsx ?? true;
2124
+ }
2025
2125
  const configs = [];
2026
2126
  if (enableGitignore) {
2027
2127
  if (typeof enableGitignore !== "boolean") {
2028
2128
  configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
2029
2129
  } else {
2030
- if (fs.existsSync(".gitignore"))
2130
+ if (fs.existsSync(".gitignore")) {
2031
2131
  configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
2132
+ }
2032
2133
  }
2033
2134
  }
2034
2135
  configs.push(
@@ -2049,8 +2150,9 @@ function dhzh(options = {}, ...userConfigs) {
2049
2150
  // Optional plugins (installed but not enabled by default)
2050
2151
  perfectionist()
2051
2152
  );
2052
- if (enableVue)
2153
+ if (enableVue) {
2053
2154
  componentExts.push("vue");
2155
+ }
2054
2156
  if (enableTypeScript) {
2055
2157
  configs.push(typescript({
2056
2158
  ...resolveSubOptions(options, "typescript"),
@@ -2061,6 +2163,7 @@ function dhzh(options = {}, ...userConfigs) {
2061
2163
  if (stylisticOptions) {
2062
2164
  configs.push(stylistic({
2063
2165
  ...stylisticOptions,
2166
+ lessOpinionated: options.lessOpinionated,
2064
2167
  overrides: getOverrides(options, "stylistic")
2065
2168
  }));
2066
2169
  }
@@ -2084,6 +2187,13 @@ function dhzh(options = {}, ...userConfigs) {
2084
2187
  typescript: !!enableTypeScript
2085
2188
  }));
2086
2189
  }
2190
+ if (enableSolid) {
2191
+ configs.push(solid({
2192
+ overrides: getOverrides(options, "solid"),
2193
+ tsconfigPath: getOverrides(options, "typescript").tsconfigPath,
2194
+ typescript: !!enableTypeScript
2195
+ }));
2196
+ }
2087
2197
  if (enableSvelte) {
2088
2198
  configs.push(svelte({
2089
2199
  overrides: getOverrides(options, "svelte"),
@@ -2142,21 +2252,23 @@ function dhzh(options = {}, ...userConfigs) {
2142
2252
  ));
2143
2253
  }
2144
2254
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2145
- if (key in options)
2255
+ if (key in options) {
2146
2256
  acc[key] = options[key];
2257
+ }
2147
2258
  return acc;
2148
2259
  }, {});
2149
- if (Object.keys(fusedConfig).length)
2260
+ if (Object.keys(fusedConfig).length) {
2150
2261
  configs.push([fusedConfig]);
2151
- let pipeline = new FlatConfigPipeline();
2152
- pipeline = pipeline.append(
2262
+ }
2263
+ let composer = new FlatConfigComposer();
2264
+ composer = composer.append(
2153
2265
  ...configs,
2154
2266
  ...userConfigs
2155
2267
  );
2156
2268
  if (autoRenamePlugins) {
2157
- pipeline = pipeline.renamePlugins(defaultPluginRenaming);
2269
+ composer = composer.renamePlugins(defaultPluginRenaming);
2158
2270
  }
2159
- return pipeline;
2271
+ return composer;
2160
2272
  }
2161
2273
  function resolveSubOptions(options, key) {
2162
2274
  return typeof options[key] === "boolean" ? {} : options[key] || {};
@@ -2223,6 +2335,7 @@ export {
2223
2335
  renamePluginInConfigs,
2224
2336
  renameRules,
2225
2337
  resolveSubOptions,
2338
+ solid,
2226
2339
  sortPackageJson,
2227
2340
  sortTsconfig,
2228
2341
  stylistic,