@coderwyd/eslint-config 2.4.1 → 2.5.0-beta.1

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,16 +1,6 @@
1
1
  // src/index.ts
2
- import process4 from "node:process";
3
2
  import fs from "node:fs";
4
3
 
5
- // src/constants/prettier.ts
6
- var DEFAULT_PRETTIER_RULES = {
7
- arrowParens: "avoid",
8
- htmlWhitespaceSensitivity: "ignore",
9
- printWidth: 80,
10
- semi: false,
11
- singleQuote: true
12
- };
13
-
14
4
  // src/plugins/index.ts
15
5
  import { default as default2 } from "eslint-plugin-antfu";
16
6
  import { default as default3 } from "eslint-plugin-eslint-comments";
@@ -41,7 +31,6 @@ async function comments() {
41
31
  // src/constants/glob.ts
42
32
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
43
33
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
44
- var GLOB_JSX = "**/*.?([cm])jsx";
45
34
  var GLOB_TS = "**/*.?([cm])ts";
46
35
  var GLOB_TSX = "**/*.?([cm])tsx";
47
36
  var GLOB_VUE = "**/*.vue";
@@ -58,7 +47,6 @@ var GLOB_MARKDOWN = "**/*.md";
58
47
  var GLOB_YAML = "**/*.y?(a)ml";
59
48
  var GLOB_TOML = "**/*.toml";
60
49
  var GLOB_GRAPHQL = "**/*.{g,graph}ql";
61
- var GLOB_PRETTIER_LINT = [GLOB_SRC, GLOB_VUE];
62
50
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
63
51
  var GLOB_TESTS = [
64
52
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -109,7 +97,8 @@ async function ignores() {
109
97
  }
110
98
 
111
99
  // src/configs/imports.ts
112
- async function imports() {
100
+ async function imports(options = {}) {
101
+ const { stylistic: stylistic2 = true } = options;
113
102
  return [
114
103
  {
115
104
  name: "coderwyd/imports/rules",
@@ -144,10 +133,9 @@ async function imports() {
144
133
  pathGroupsExcludedImportTypes: ["type"]
145
134
  }
146
135
  ],
147
- ...{
148
- // format
136
+ ...stylistic2 ? {
149
137
  "import/newline-after-import": ["error", { count: 1 }]
150
- }
138
+ } : {}
151
139
  }
152
140
  },
153
141
  {
@@ -203,7 +191,7 @@ async function javascript(options = {}) {
203
191
  "constructor-super": "error",
204
192
  "default-case-last": "error",
205
193
  "dot-notation": ["error", { allowKeywords: true }],
206
- eqeqeq: ["error", "smart"],
194
+ "eqeqeq": ["error", "smart"],
207
195
  "for-direction": "error",
208
196
  "getter-return": "error",
209
197
  "new-cap": [
@@ -403,7 +391,7 @@ async function javascript(options = {}) {
403
391
  ],
404
392
  "valid-typeof": ["error", { requireStringLiterals: true }],
405
393
  "vars-on-top": "error",
406
- yoda: ["error", "never"],
394
+ "yoda": ["error", "never"],
407
395
  ...overrides
408
396
  }
409
397
  },
@@ -426,8 +414,6 @@ async function javascript(options = {}) {
426
414
 
427
415
  // src/shared/index.ts
428
416
  import process from "node:process";
429
- import { readFile } from "node:fs/promises";
430
- import path from "node:path";
431
417
  import { getPackageInfoSync, isPackageExists } from "local-pkg";
432
418
  var parserPlain = {
433
419
  meta: {
@@ -508,19 +494,11 @@ async function ensurePackages(packages) {
508
494
  type: "confirm"
509
495
  }
510
496
  ]);
511
- if (result)
497
+ if (result) {
512
498
  await import("@antfu/install-pkg").then(
513
499
  (i) => i.installPackage(nonExistingPackages, { dev: true })
514
500
  );
515
- }
516
- async function loadPrettierConfig(cwd) {
517
- let prettierConfig = {};
518
- try {
519
- const prettierrc = await readFile(path.join(cwd, ".prettierrc"), "utf-8");
520
- prettierConfig = JSON.parse(prettierrc);
521
- } catch {
522
501
  }
523
- return prettierConfig;
524
502
  }
525
503
  function resolveSubOptions(options, key) {
526
504
  return typeof options[key] === "boolean" ? {} : options[key] || {};
@@ -533,7 +511,8 @@ function getOverrides(options, key) {
533
511
  }
534
512
 
535
513
  // src/configs/jsdoc.ts
536
- async function jsdoc() {
514
+ async function jsdoc(options = {}) {
515
+ const { stylistic: stylistic2 = true } = options;
537
516
  return [
538
517
  {
539
518
  name: "coderwyd/jsdoc/rules",
@@ -556,11 +535,10 @@ async function jsdoc() {
556
535
  "jsdoc/require-returns-check": "warn",
557
536
  "jsdoc/require-returns-description": "warn",
558
537
  "jsdoc/require-yields-check": "warn",
559
- ...{
560
- // format
538
+ ...stylistic2 ? {
561
539
  "jsdoc/check-alignment": "warn",
562
540
  "jsdoc/multiline-blocks": "warn"
563
- }
541
+ } : {}
564
542
  }
565
543
  }
566
544
  ];
@@ -568,7 +546,14 @@ async function jsdoc() {
568
546
 
569
547
  // src/configs/jsonc.ts
570
548
  async function jsonc(options = {}) {
571
- const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides = {} } = options || {};
549
+ const {
550
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
551
+ overrides = {},
552
+ stylistic: stylistic2 = true
553
+ } = options || {};
554
+ const {
555
+ indent = 2
556
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
572
557
  const [pluginJsonc, parserJsonc] = await Promise.all([
573
558
  interopDefault(import("eslint-plugin-jsonc")),
574
559
  interopDefault(import("jsonc-eslint-parser"))
@@ -613,12 +598,11 @@ async function jsonc(options = {}) {
613
598
  "jsonc/space-unary-ops": "error",
614
599
  "jsonc/valid-json-number": "error",
615
600
  "jsonc/vue-custom-block/no-parsing-error": "error",
616
- ...{
617
- // format
601
+ ...stylistic2 ? {
618
602
  "jsonc/array-bracket-spacing": ["error", "never"],
619
603
  "jsonc/comma-dangle": ["error", "never"],
620
604
  "jsonc/comma-style": ["error", "last"],
621
- "jsonc/indent": ["error", 2],
605
+ "jsonc/indent": ["error", indent],
622
606
  "jsonc/key-spacing": [
623
607
  "error",
624
608
  { afterColon: true, beforeColon: false }
@@ -634,7 +618,7 @@ async function jsonc(options = {}) {
634
618
  ],
635
619
  "jsonc/quote-props": "error",
636
620
  "jsonc/quotes": "error"
637
- },
621
+ } : {},
638
622
  ...overrides
639
623
  }
640
624
  }
@@ -886,34 +870,52 @@ function sortTsconfig() {
886
870
  ];
887
871
  }
888
872
 
889
- // src/configs/prettier.ts
890
- import prettierRules from "eslint-config-prettier";
891
- var { rules: eslintRules } = prettierRules;
892
- async function prettier(rules = {}) {
893
- const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
894
- const pRules = {
895
- ...rules
873
+ // src/configs/stylistic.ts
874
+ var StylisticConfigDefaults = {
875
+ indent: 2,
876
+ jsx: true,
877
+ quotes: "single",
878
+ semi: false
879
+ };
880
+ async function stylistic(options = {}) {
881
+ const {
882
+ indent,
883
+ jsx,
884
+ overrides = {},
885
+ quotes,
886
+ semi
887
+ } = {
888
+ ...StylisticConfigDefaults,
889
+ ...options
896
890
  };
897
- const configs2 = [
891
+ const pluginStylistic = await interopDefault(
892
+ import("@stylistic/eslint-plugin")
893
+ );
894
+ const config = pluginStylistic.configs.customize({
895
+ flat: true,
896
+ indent,
897
+ jsx,
898
+ pluginName: "style",
899
+ quotes,
900
+ semi
901
+ });
902
+ return [
898
903
  {
899
- name: "coderwyd/prettier/setup",
904
+ name: "coderwyd/stylistic/rules",
900
905
  plugins: {
901
- prettier: pluginPrettier
902
- }
903
- },
904
- {
905
- files: GLOB_PRETTIER_LINT,
906
- name: "coderwyd/prettier/rules",
906
+ antfu: default2,
907
+ style: pluginStylistic
908
+ },
907
909
  rules: {
908
- ...eslintRules,
909
- "prettier/prettier": ["warn", pRules],
910
- // eslint-disable-next-line perfectionist/sort-objects
911
- "arrow-body-style": "off",
912
- "prefer-arrow-callback": "off"
910
+ ...config.rules,
911
+ "antfu/consistent-list-newline": "error",
912
+ "antfu/if-newline": "warn",
913
+ "antfu/top-level-function": "warn",
914
+ "curly": ["error", "multi-or-nest", "consistent"],
915
+ ...overrides
913
916
  }
914
917
  }
915
918
  ];
916
- return configs2;
917
919
  }
918
920
 
919
921
  // src/configs/typescript.ts
@@ -1084,9 +1086,9 @@ async function unicorn() {
1084
1086
  rules: {
1085
1087
  // 'unicorn/better-regex': 'error',
1086
1088
  "unicorn/catch-error-name": "error",
1089
+ "unicorn/consistent-empty-array-spread": "error",
1087
1090
  "unicorn/custom-error-definition": "error",
1088
1091
  "unicorn/error-message": "error",
1089
- "unicorn/escape-case": "error",
1090
1092
  // 'unicorn/explicit-length-check': 'error',
1091
1093
  // 'unicorn/filename-case': [
1092
1094
  // 'error',
@@ -1094,6 +1096,7 @@ async function unicorn() {
1094
1096
  // cases: { kebabCase: true, pascalCase: true },
1095
1097
  // ignore: [/^[A-Z]+\..*$/],
1096
1098
  // },
1099
+ "unicorn/escape-case": "error",
1097
1100
  // ],
1098
1101
  "unicorn/new-for-builtins": "error",
1099
1102
  // 'unicorn/no-array-callback-reference': 'error',
@@ -1151,11 +1154,15 @@ async function unicorn() {
1151
1154
  }
1152
1155
 
1153
1156
  // src/configs/vue.ts
1157
+ import { mergeProcessors } from "eslint-merge-processors";
1154
1158
  async function vue(options = {}) {
1155
- const { files = [GLOB_VUE], overrides = {} } = options;
1156
- const [pluginVue, parserVue] = await Promise.all([
1159
+ const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic2 = true } = options;
1160
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1161
+ const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1162
+ const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1157
1163
  interopDefault(import("eslint-plugin-vue")),
1158
- interopDefault(import("vue-eslint-parser"))
1164
+ interopDefault(import("vue-eslint-parser")),
1165
+ interopDefault(import("eslint-processor-vue-blocks"))
1159
1166
  ]);
1160
1167
  const isVue3 = getVueVersion() === 3;
1161
1168
  const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
@@ -1209,7 +1216,16 @@ async function vue(options = {}) {
1209
1216
  }
1210
1217
  },
1211
1218
  name: "coderwyd/vue/rules",
1212
- processor: pluginVue.processors[".vue"],
1219
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([
1220
+ pluginVue.processors[".vue"],
1221
+ processorVueBlocks({
1222
+ ...sfcBlocks,
1223
+ blocks: {
1224
+ styles: true,
1225
+ ...sfcBlocks.blocks
1226
+ }
1227
+ })
1228
+ ]),
1213
1229
  rules: {
1214
1230
  ...pluginVue.configs.base.rules,
1215
1231
  ...vueRules,
@@ -1237,7 +1253,7 @@ async function vue(options = {}) {
1237
1253
  "vue/dot-location": ["error", "property"],
1238
1254
  "vue/dot-notation": ["error", { allowKeywords: true }],
1239
1255
  "vue/eqeqeq": ["error", "smart"],
1240
- "vue/html-indent": ["error", 2],
1256
+ "vue/html-indent": ["error", indent],
1241
1257
  "vue/html-quotes": ["error", "double"],
1242
1258
  "vue/html-self-closing": [
1243
1259
  "error",
@@ -1287,8 +1303,7 @@ async function vue(options = {}) {
1287
1303
  "vue/space-infix-ops": "error",
1288
1304
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1289
1305
  "vue/valid-define-options": "warn",
1290
- ...{
1291
- // format
1306
+ ...stylistic2 ? {
1292
1307
  "vue/array-bracket-spacing": ["error", "never"],
1293
1308
  "vue/arrow-spacing": ["error", { after: true, before: true }],
1294
1309
  "vue/block-spacing": ["error", "always"],
@@ -1299,7 +1314,11 @@ async function vue(options = {}) {
1299
1314
  singleline: "always"
1300
1315
  }
1301
1316
  ],
1302
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1317
+ "vue/brace-style": [
1318
+ "error",
1319
+ "stroustrup",
1320
+ { allowSingleLine: true }
1321
+ ],
1303
1322
  "vue/comma-dangle": ["error", "always-multiline"],
1304
1323
  "vue/comma-spacing": ["error", { after: true, before: false }],
1305
1324
  "vue/comma-style": ["error", "last"],
@@ -1326,7 +1345,7 @@ async function vue(options = {}) {
1326
1345
  "vue/quote-props": ["error", "consistent-as-needed"],
1327
1346
  "vue/space-in-parens": ["error", "never"],
1328
1347
  "vue/template-curly-spacing": "error"
1329
- },
1348
+ } : {},
1330
1349
  ...overrides
1331
1350
  }
1332
1351
  }
@@ -1392,86 +1411,132 @@ async function perfectionist() {
1392
1411
  // src/configs/react.ts
1393
1412
  import { isPackageExists as isPackageExists2 } from "local-pkg";
1394
1413
  var ReactRefreshAllowConstantExportPackages = ["vite"];
1414
+ var RemixPackages = [
1415
+ "@remix-run/node",
1416
+ "@remix-run/react",
1417
+ "@remix-run/serve",
1418
+ "@remix-run/dev"
1419
+ ];
1420
+ var NextJsPackages = ["next"];
1395
1421
  async function react(options = {}) {
1396
- const {
1397
- files = [GLOB_JSX, GLOB_TSX],
1398
- overrides = {},
1399
- typescript: typescript2 = true
1400
- } = options;
1422
+ const { files = [GLOB_TS, GLOB_TSX], overrides = {} } = options;
1401
1423
  await ensurePackages([
1402
- "eslint-plugin-react",
1424
+ "@eslint-react/eslint-plugin",
1403
1425
  "eslint-plugin-react-hooks",
1404
1426
  "eslint-plugin-react-refresh"
1405
1427
  ]);
1406
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
1407
- [
1408
- interopDefault(import("eslint-plugin-react")),
1409
- interopDefault(import("eslint-plugin-react-hooks")),
1410
- interopDefault(import("eslint-plugin-react-refresh"))
1411
- ]
1412
- );
1428
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1429
+ const isTypeAware = !!tsconfigPath;
1430
+ const [pluginReact, pluginReactHooks, pluginReactRefresh, parserTs] = await Promise.all([
1431
+ interopDefault(import("@eslint-react/eslint-plugin")),
1432
+ interopDefault(import("eslint-plugin-react-hooks")),
1433
+ interopDefault(import("eslint-plugin-react-refresh")),
1434
+ interopDefault(import("@typescript-eslint/parser"))
1435
+ ]);
1413
1436
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1414
1437
  (i) => isPackageExists2(i)
1415
1438
  );
1439
+ const isUsingRemix = RemixPackages.some((i) => isPackageExists2(i));
1440
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
1441
+ const plugins = pluginReact.configs.all.plugins;
1416
1442
  return [
1417
1443
  {
1418
1444
  name: "coderwyd/react/setup",
1419
1445
  plugins: {
1420
- react: pluginReact,
1446
+ "react": plugins["@eslint-react"],
1447
+ "react-dom": plugins["@eslint-react/dom"],
1421
1448
  "react-hooks": pluginReactHooks,
1449
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1450
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
1422
1451
  "react-refresh": pluginReactRefresh
1423
- },
1424
- settings: {
1425
- react: {
1426
- version: "detect"
1427
- }
1428
1452
  }
1429
1453
  },
1430
1454
  {
1431
1455
  files,
1432
1456
  languageOptions: {
1457
+ parser: parserTs,
1433
1458
  parserOptions: {
1434
1459
  ecmaFeatures: {
1435
1460
  jsx: true
1436
- }
1437
- }
1461
+ },
1462
+ ...isTypeAware ? { project: tsconfigPath } : {}
1463
+ },
1464
+ sourceType: "module"
1438
1465
  },
1439
1466
  name: "coderwyd/react/rules",
1440
1467
  rules: {
1468
+ // recommended rules from @eslint-react/dom
1469
+ "react-dom/no-children-in-void-dom-elements": "warn",
1470
+ "react-dom/no-dangerously-set-innerhtml": "warn",
1471
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1472
+ "react-dom/no-find-dom-node": "error",
1473
+ "react-dom/no-missing-button-type": "warn",
1474
+ "react-dom/no-missing-iframe-sandbox": "warn",
1475
+ "react-dom/no-namespace": "error",
1476
+ "react-dom/no-render-return-value": "error",
1477
+ "react-dom/no-script-url": "warn",
1478
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
1479
+ "react-dom/no-unsafe-target-blank": "warn",
1441
1480
  // recommended rules react-hooks
1442
1481
  "react-hooks/exhaustive-deps": "warn",
1443
1482
  "react-hooks/rules-of-hooks": "error",
1444
1483
  // react refresh
1445
1484
  "react-refresh/only-export-components": [
1446
1485
  "warn",
1447
- { allowConstantExport: isAllowConstantExport }
1486
+ {
1487
+ allowConstantExport: isAllowConstantExport,
1488
+ allowExportNames: [
1489
+ ...isUsingNext ? [
1490
+ "config",
1491
+ "generateStaticParams",
1492
+ "metadata",
1493
+ "generateMetadata",
1494
+ "viewport",
1495
+ "generateViewport"
1496
+ ] : [],
1497
+ ...isUsingRemix ? ["meta", "links", "headers", "loader", "action"] : []
1498
+ ]
1499
+ }
1448
1500
  ],
1449
- // recommended rules react
1450
- "react/display-name": "error",
1451
- "react/jsx-key": "error",
1452
- "react/jsx-no-comment-textnodes": "error",
1453
- "react/jsx-no-duplicate-props": "error",
1454
- "react/jsx-no-target-blank": "error",
1455
- "react/jsx-no-undef": "error",
1456
- "react/jsx-uses-react": "error",
1457
- "react/jsx-uses-vars": "error",
1458
- "react/no-children-prop": "error",
1459
- "react/no-danger-with-children": "error",
1460
- "react/no-deprecated": "error",
1501
+ // recommended rules from @eslint-react
1502
+ "react/ensure-forward-ref-using-ref": "warn",
1503
+ "react/no-access-state-in-setstate": "error",
1504
+ "react/no-array-index-key": "warn",
1505
+ "react/no-children-count": "warn",
1506
+ "react/no-children-for-each": "warn",
1507
+ "react/no-children-map": "warn",
1508
+ "react/no-children-only": "warn",
1509
+ "react/no-children-prop": "warn",
1510
+ "react/no-children-to-array": "warn",
1511
+ "react/no-clone-element": "warn",
1512
+ "react/no-comment-textnodes": "warn",
1513
+ "react/no-component-will-mount": "error",
1514
+ "react/no-component-will-receive-props": "error",
1515
+ "react/no-component-will-update": "error",
1516
+ "react/no-create-ref": "error",
1461
1517
  "react/no-direct-mutation-state": "error",
1462
- "react/no-find-dom-node": "error",
1463
- "react/no-is-mounted": "error",
1464
- "react/no-render-return-value": "error",
1518
+ "react/no-duplicate-key": "error",
1519
+ "react/no-implicit-key": "error",
1520
+ "react/no-missing-key": "error",
1521
+ "react/no-nested-components": "warn",
1522
+ "react/no-redundant-should-component-update": "error",
1523
+ "react/no-set-state-in-component-did-mount": "warn",
1524
+ "react/no-set-state-in-component-did-update": "warn",
1525
+ "react/no-set-state-in-component-will-update": "warn",
1465
1526
  "react/no-string-refs": "error",
1466
- "react/no-unescaped-entities": "error",
1467
- "react/no-unknown-property": "error",
1468
- "react/no-unsafe": "off",
1469
- "react/prop-types": "error",
1470
- "react/react-in-jsx-scope": "off",
1471
- "react/require-render-return": "error",
1472
- ...typescript2 ? {
1473
- "react/jsx-no-undef": "off",
1474
- "react/prop-type": "off"
1527
+ "react/no-unsafe-component-will-mount": "warn",
1528
+ "react/no-unsafe-component-will-receive-props": "warn",
1529
+ "react/no-unsafe-component-will-update": "warn",
1530
+ "react/no-unstable-context-value": "error",
1531
+ "react/no-unstable-default-props": "error",
1532
+ "react/no-unused-class-component-members": "warn",
1533
+ "react/no-unused-state": "warn",
1534
+ "react/no-useless-fragment": "warn",
1535
+ "react/prefer-destructuring-assignment": "warn",
1536
+ "react/prefer-shorthand-boolean": "warn",
1537
+ "react/prefer-shorthand-fragment": "warn",
1538
+ ...isTypeAware ? {
1539
+ "react/no-leaked-conditional-rendering": "warn"
1475
1540
  } : {},
1476
1541
  // overrides
1477
1542
  ...overrides
@@ -1507,7 +1572,7 @@ async function unocss(options = {}) {
1507
1572
  }
1508
1573
 
1509
1574
  // src/configs/formatter.ts
1510
- async function formatter(options = {}, prettierRules2 = {}) {
1575
+ async function formatter(options = {}, stylistic2 = {}) {
1511
1576
  const { css, graphql, html, markdown, toml, yaml } = options === true ? {
1512
1577
  css: true,
1513
1578
  graphql: true,
@@ -1516,10 +1581,27 @@ async function formatter(options = {}, prettierRules2 = {}) {
1516
1581
  toml: true,
1517
1582
  yaml: true
1518
1583
  } : options;
1519
- const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
1584
+ const { indent, quotes, semi } = {
1585
+ ...StylisticConfigDefaults,
1586
+ ...stylistic2
1587
+ };
1588
+ const prettierOptions = Object.assign(
1589
+ {
1590
+ endOfLine: "auto",
1591
+ printWidth: 80,
1592
+ semi,
1593
+ singleQuote: quotes === "single",
1594
+ tabWidth: typeof indent === "number" ? indent : 2,
1595
+ trailingComma: "all",
1596
+ useTabs: indent === "tab"
1597
+ },
1598
+ typeof options === "boolean" ? {} : options.prettierOptions || {}
1599
+ );
1600
+ await ensurePackages(["eslint-plugin-format"]);
1601
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
1520
1602
  function createPrettierFormatter(files, parser, plugins) {
1521
1603
  const rules = {
1522
- ...prettierRules2,
1604
+ ...prettierOptions,
1523
1605
  parser
1524
1606
  };
1525
1607
  const markdownRules = {
@@ -1527,9 +1609,8 @@ async function formatter(options = {}, prettierRules2 = {}) {
1527
1609
  ...rules,
1528
1610
  embeddedLanguageFormatting: "off"
1529
1611
  };
1530
- if (plugins?.length) {
1612
+ if (plugins?.length)
1531
1613
  rules.plugins = [...rules.plugins || [], ...plugins];
1532
- }
1533
1614
  const config = {
1534
1615
  files,
1535
1616
  languageOptions: {
@@ -1537,10 +1618,10 @@ async function formatter(options = {}, prettierRules2 = {}) {
1537
1618
  },
1538
1619
  name: `coderwyd/formatter/${parser}`,
1539
1620
  plugins: {
1540
- prettier: pluginPrettier
1621
+ format: pluginFormat
1541
1622
  },
1542
1623
  rules: {
1543
- "prettier/prettier": [
1624
+ "format/prettier": [
1544
1625
  "warn",
1545
1626
  parser === "markdown" ? markdownRules : rules
1546
1627
  ]
@@ -1552,7 +1633,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1552
1633
  {
1553
1634
  name: "coderwyd/formatter/setup",
1554
1635
  plugins: {
1555
- prettier: pluginPrettier
1636
+ format: pluginFormat
1556
1637
  }
1557
1638
  }
1558
1639
  ];
@@ -1590,7 +1671,11 @@ async function formatter(options = {}, prettierRules2 = {}) {
1590
1671
 
1591
1672
  // src/configs/svelte.ts
1592
1673
  async function svelte(options = {}) {
1593
- const { files = [GLOB_SVELTE], overrides = {} } = options;
1674
+ const { files = [GLOB_SVELTE], overrides = {}, stylistic: stylistic2 = true } = options;
1675
+ const {
1676
+ indent = 2,
1677
+ quotes = "single"
1678
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1594
1679
  await ensurePackages(["eslint-plugin-svelte"]);
1595
1680
  const [pluginSvelte, parserSvelte] = await Promise.all([
1596
1681
  interopDefault(import("eslint-plugin-svelte")),
@@ -1660,22 +1745,23 @@ async function svelte(options = {}) {
1660
1745
  varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1661
1746
  }
1662
1747
  ],
1663
- ...{
1664
- // format
1748
+ ...stylistic2 ? {
1749
+ "style/indent": "off",
1750
+ // superseded by svelte/indent
1665
1751
  "style/no-trailing-spaces": "off",
1666
1752
  // superseded by svelte/no-trailing-spaces
1667
1753
  "svelte/derived-has-same-inputs-outputs": "error",
1668
1754
  "svelte/html-closing-bracket-spacing": "error",
1669
- "svelte/html-quotes": ["error", { prefer: "single" }],
1755
+ "svelte/html-quotes": ["error", { prefer: quotes }],
1670
1756
  "svelte/indent": [
1671
1757
  "error",
1672
- { alignAttributesVertically: true, indent: 2 }
1758
+ { alignAttributesVertically: true, indent }
1673
1759
  ],
1674
1760
  "svelte/mustache-spacing": "error",
1675
1761
  "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1676
1762
  "svelte/no-trailing-spaces": "error",
1677
1763
  "svelte/spaced-html-comment": "error"
1678
- },
1764
+ } : {},
1679
1765
  ...overrides
1680
1766
  }
1681
1767
  }
@@ -1767,11 +1853,16 @@ var flatConfigProps = [
1767
1853
  "settings"
1768
1854
  ];
1769
1855
  var defaultPluginRenaming = {
1856
+ "@eslint-react": "react",
1857
+ "@eslint-react/dom": "react-dom",
1858
+ "@eslint-react/hooks-extra": "react-hooks-extra",
1859
+ "@eslint-react/naming-convention": "react-naming-convention",
1860
+ "@stylistic": "style",
1770
1861
  "@typescript-eslint": "ts",
1771
1862
  "import-x": "import",
1772
- n: "node",
1773
- vitest: "test",
1774
- yml: "yaml"
1863
+ "n": "node",
1864
+ "vitest": "test",
1865
+ "yml": "yaml"
1775
1866
  };
1776
1867
  async function defineConfig(options = {}, ...userConfigs) {
1777
1868
  const {
@@ -1789,9 +1880,11 @@ async function defineConfig(options = {}, ...userConfigs) {
1789
1880
  tailwindcss: enableTailwindCSS = hasTailwindCSS,
1790
1881
  typescript: enableTypeScript = hasTypeScript,
1791
1882
  unocss: enableUnoCSS = false,
1792
- usePrettierrc = true,
1793
1883
  vue: enableVue = hasVue
1794
1884
  } = options;
1885
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1886
+ if (stylisticOptions && !("jsx" in stylisticOptions))
1887
+ stylisticOptions.jsx = options.jsx ?? true;
1795
1888
  const configs2 = [];
1796
1889
  if (enableGitignore) {
1797
1890
  if (typeof enableGitignore !== "boolean") {
@@ -1801,12 +1894,13 @@ async function defineConfig(options = {}, ...userConfigs) {
1801
1894
  ])
1802
1895
  );
1803
1896
  } else {
1804
- if (fs.existsSync(".gitignore"))
1897
+ if (fs.existsSync(".gitignore")) {
1805
1898
  configs2.push(
1806
1899
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1807
1900
  r()
1808
1901
  ])
1809
1902
  );
1903
+ }
1810
1904
  }
1811
1905
  }
1812
1906
  configs2.push(
@@ -1817,8 +1911,12 @@ async function defineConfig(options = {}, ...userConfigs) {
1817
1911
  }),
1818
1912
  comments(),
1819
1913
  node(),
1820
- jsdoc(),
1821
- imports(),
1914
+ jsdoc({
1915
+ stylistic: stylisticOptions
1916
+ }),
1917
+ imports({
1918
+ stylistic: stylisticOptions
1919
+ }),
1822
1920
  unicorn(),
1823
1921
  command(),
1824
1922
  // Optional plugins (installed but not enabled by default)
@@ -1835,6 +1933,14 @@ async function defineConfig(options = {}, ...userConfigs) {
1835
1933
  })
1836
1934
  );
1837
1935
  }
1936
+ if (stylisticOptions) {
1937
+ configs2.push(
1938
+ stylistic({
1939
+ ...stylisticOptions,
1940
+ overrides: getOverrides(options, "stylistic")
1941
+ })
1942
+ );
1943
+ }
1838
1944
  if (enableRegexp)
1839
1945
  configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1840
1946
  if (options.test ?? true) {
@@ -1850,6 +1956,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1850
1956
  vue({
1851
1957
  ...resolveSubOptions(options, "vue"),
1852
1958
  overrides: getOverrides(options, "typescript"),
1959
+ stylistic: stylisticOptions,
1853
1960
  typescript: !!enableTypeScript
1854
1961
  })
1855
1962
  );
@@ -1858,7 +1965,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1858
1965
  configs2.push(
1859
1966
  react({
1860
1967
  overrides: getOverrides(options, "react"),
1861
- typescript: !!enableTypeScript
1968
+ tsconfigPath: getOverrides(options, "typescript").tsconfigPath
1862
1969
  })
1863
1970
  );
1864
1971
  }
@@ -1866,6 +1973,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1866
1973
  configs2.push(
1867
1974
  svelte({
1868
1975
  overrides: getOverrides(options, "svelte"),
1976
+ stylistic: stylisticOptions,
1869
1977
  typescript: !!enableTypeScript
1870
1978
  })
1871
1979
  );
@@ -1889,31 +1997,20 @@ async function defineConfig(options = {}, ...userConfigs) {
1889
1997
  if (options.jsonc ?? true) {
1890
1998
  configs2.push(
1891
1999
  jsonc({
1892
- overrides: getOverrides(options, "jsonc")
2000
+ overrides: getOverrides(options, "jsonc"),
2001
+ stylistic: stylisticOptions
1893
2002
  }),
1894
2003
  sortPackageJson(),
1895
2004
  sortTsconfig()
1896
2005
  );
1897
2006
  }
1898
2007
  if (formatterOptions) {
1899
- let prettierRules2 = {
1900
- ...DEFAULT_PRETTIER_RULES
1901
- };
1902
- if (options.prettierRules) {
1903
- prettierRules2 = { ...prettierRules2, ...options.prettierRules };
1904
- }
1905
- if (usePrettierrc) {
1906
- const prettierConfig = await loadPrettierConfig(
1907
- options.cwd ?? process4.cwd()
1908
- );
1909
- Object.assign(prettierRules2, prettierConfig);
1910
- }
1911
2008
  configs2.push(
1912
- prettier(prettierRules2),
1913
- formatter(formatterOptions, prettierRules2)
2009
+ formatter(
2010
+ formatterOptions,
2011
+ typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2012
+ )
1914
2013
  );
1915
- } else {
1916
- configs2.push(prettier());
1917
2014
  }
1918
2015
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1919
2016
  if (key in options)
@@ -1935,7 +2032,6 @@ export {
1935
2032
  getOverrides,
1936
2033
  getVueVersion,
1937
2034
  interopDefault,
1938
- loadPrettierConfig,
1939
2035
  parserPlain,
1940
2036
  renamePluginInConfigs,
1941
2037
  renameRules,