@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.cjs CHANGED
@@ -37,7 +37,6 @@ __export(src_exports, {
37
37
  getOverrides: () => getOverrides,
38
38
  getVueVersion: () => getVueVersion,
39
39
  interopDefault: () => interopDefault,
40
- loadPrettierConfig: () => loadPrettierConfig,
41
40
  parserPlain: () => parserPlain,
42
41
  renamePluginInConfigs: () => renamePluginInConfigs,
43
42
  renameRules: () => renameRules,
@@ -45,18 +44,8 @@ __export(src_exports, {
45
44
  toArray: () => toArray
46
45
  });
47
46
  module.exports = __toCommonJS(src_exports);
48
- var import_node_process4 = __toESM(require("process"), 1);
49
47
  var import_node_fs = __toESM(require("fs"), 1);
50
48
 
51
- // src/constants/prettier.ts
52
- var DEFAULT_PRETTIER_RULES = {
53
- arrowParens: "avoid",
54
- htmlWhitespaceSensitivity: "ignore",
55
- printWidth: 80,
56
- semi: false,
57
- singleQuote: true
58
- };
59
-
60
49
  // src/plugins/index.ts
61
50
  var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
62
51
  var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
@@ -87,7 +76,6 @@ async function comments() {
87
76
  // src/constants/glob.ts
88
77
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
89
78
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
90
- var GLOB_JSX = "**/*.?([cm])jsx";
91
79
  var GLOB_TS = "**/*.?([cm])ts";
92
80
  var GLOB_TSX = "**/*.?([cm])tsx";
93
81
  var GLOB_VUE = "**/*.vue";
@@ -104,7 +92,6 @@ var GLOB_MARKDOWN = "**/*.md";
104
92
  var GLOB_YAML = "**/*.y?(a)ml";
105
93
  var GLOB_TOML = "**/*.toml";
106
94
  var GLOB_GRAPHQL = "**/*.{g,graph}ql";
107
- var GLOB_PRETTIER_LINT = [GLOB_SRC, GLOB_VUE];
108
95
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
109
96
  var GLOB_TESTS = [
110
97
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -155,7 +142,8 @@ async function ignores() {
155
142
  }
156
143
 
157
144
  // src/configs/imports.ts
158
- async function imports() {
145
+ async function imports(options = {}) {
146
+ const { stylistic: stylistic2 = true } = options;
159
147
  return [
160
148
  {
161
149
  name: "coderwyd/imports/rules",
@@ -190,10 +178,9 @@ async function imports() {
190
178
  pathGroupsExcludedImportTypes: ["type"]
191
179
  }
192
180
  ],
193
- ...{
194
- // format
181
+ ...stylistic2 ? {
195
182
  "import/newline-after-import": ["error", { count: 1 }]
196
- }
183
+ } : {}
197
184
  }
198
185
  },
199
186
  {
@@ -249,7 +236,7 @@ async function javascript(options = {}) {
249
236
  "constructor-super": "error",
250
237
  "default-case-last": "error",
251
238
  "dot-notation": ["error", { allowKeywords: true }],
252
- eqeqeq: ["error", "smart"],
239
+ "eqeqeq": ["error", "smart"],
253
240
  "for-direction": "error",
254
241
  "getter-return": "error",
255
242
  "new-cap": [
@@ -449,7 +436,7 @@ async function javascript(options = {}) {
449
436
  ],
450
437
  "valid-typeof": ["error", { requireStringLiterals: true }],
451
438
  "vars-on-top": "error",
452
- yoda: ["error", "never"],
439
+ "yoda": ["error", "never"],
453
440
  ...overrides
454
441
  }
455
442
  },
@@ -472,8 +459,6 @@ async function javascript(options = {}) {
472
459
 
473
460
  // src/shared/index.ts
474
461
  var import_node_process = __toESM(require("process"), 1);
475
- var import_promises = require("fs/promises");
476
- var import_node_path = __toESM(require("path"), 1);
477
462
  var import_local_pkg = require("local-pkg");
478
463
  var parserPlain = {
479
464
  meta: {
@@ -554,19 +539,11 @@ async function ensurePackages(packages) {
554
539
  type: "confirm"
555
540
  }
556
541
  ]);
557
- if (result)
542
+ if (result) {
558
543
  await import("@antfu/install-pkg").then(
559
544
  (i) => i.installPackage(nonExistingPackages, { dev: true })
560
545
  );
561
- }
562
- async function loadPrettierConfig(cwd) {
563
- let prettierConfig = {};
564
- try {
565
- const prettierrc = await (0, import_promises.readFile)(import_node_path.default.join(cwd, ".prettierrc"), "utf-8");
566
- prettierConfig = JSON.parse(prettierrc);
567
- } catch {
568
546
  }
569
- return prettierConfig;
570
547
  }
571
548
  function resolveSubOptions(options, key) {
572
549
  return typeof options[key] === "boolean" ? {} : options[key] || {};
@@ -579,7 +556,8 @@ function getOverrides(options, key) {
579
556
  }
580
557
 
581
558
  // src/configs/jsdoc.ts
582
- async function jsdoc() {
559
+ async function jsdoc(options = {}) {
560
+ const { stylistic: stylistic2 = true } = options;
583
561
  return [
584
562
  {
585
563
  name: "coderwyd/jsdoc/rules",
@@ -602,11 +580,10 @@ async function jsdoc() {
602
580
  "jsdoc/require-returns-check": "warn",
603
581
  "jsdoc/require-returns-description": "warn",
604
582
  "jsdoc/require-yields-check": "warn",
605
- ...{
606
- // format
583
+ ...stylistic2 ? {
607
584
  "jsdoc/check-alignment": "warn",
608
585
  "jsdoc/multiline-blocks": "warn"
609
- }
586
+ } : {}
610
587
  }
611
588
  }
612
589
  ];
@@ -614,7 +591,14 @@ async function jsdoc() {
614
591
 
615
592
  // src/configs/jsonc.ts
616
593
  async function jsonc(options = {}) {
617
- const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides = {} } = options || {};
594
+ const {
595
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
596
+ overrides = {},
597
+ stylistic: stylistic2 = true
598
+ } = options || {};
599
+ const {
600
+ indent = 2
601
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
618
602
  const [pluginJsonc, parserJsonc] = await Promise.all([
619
603
  interopDefault(import("eslint-plugin-jsonc")),
620
604
  interopDefault(import("jsonc-eslint-parser"))
@@ -659,12 +643,11 @@ async function jsonc(options = {}) {
659
643
  "jsonc/space-unary-ops": "error",
660
644
  "jsonc/valid-json-number": "error",
661
645
  "jsonc/vue-custom-block/no-parsing-error": "error",
662
- ...{
663
- // format
646
+ ...stylistic2 ? {
664
647
  "jsonc/array-bracket-spacing": ["error", "never"],
665
648
  "jsonc/comma-dangle": ["error", "never"],
666
649
  "jsonc/comma-style": ["error", "last"],
667
- "jsonc/indent": ["error", 2],
650
+ "jsonc/indent": ["error", indent],
668
651
  "jsonc/key-spacing": [
669
652
  "error",
670
653
  { afterColon: true, beforeColon: false }
@@ -680,7 +663,7 @@ async function jsonc(options = {}) {
680
663
  ],
681
664
  "jsonc/quote-props": "error",
682
665
  "jsonc/quotes": "error"
683
- },
666
+ } : {},
684
667
  ...overrides
685
668
  }
686
669
  }
@@ -932,34 +915,52 @@ function sortTsconfig() {
932
915
  ];
933
916
  }
934
917
 
935
- // src/configs/prettier.ts
936
- var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
937
- var { rules: eslintRules } = import_eslint_config_prettier.default;
938
- async function prettier(rules = {}) {
939
- const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
940
- const pRules = {
941
- ...rules
918
+ // src/configs/stylistic.ts
919
+ var StylisticConfigDefaults = {
920
+ indent: 2,
921
+ jsx: true,
922
+ quotes: "single",
923
+ semi: false
924
+ };
925
+ async function stylistic(options = {}) {
926
+ const {
927
+ indent,
928
+ jsx,
929
+ overrides = {},
930
+ quotes,
931
+ semi
932
+ } = {
933
+ ...StylisticConfigDefaults,
934
+ ...options
942
935
  };
943
- const configs2 = [
936
+ const pluginStylistic = await interopDefault(
937
+ import("@stylistic/eslint-plugin")
938
+ );
939
+ const config = pluginStylistic.configs.customize({
940
+ flat: true,
941
+ indent,
942
+ jsx,
943
+ pluginName: "style",
944
+ quotes,
945
+ semi
946
+ });
947
+ return [
944
948
  {
945
- name: "coderwyd/prettier/setup",
949
+ name: "coderwyd/stylistic/rules",
946
950
  plugins: {
947
- prettier: pluginPrettier
948
- }
949
- },
950
- {
951
- files: GLOB_PRETTIER_LINT,
952
- name: "coderwyd/prettier/rules",
951
+ antfu: import_eslint_plugin_antfu.default,
952
+ style: pluginStylistic
953
+ },
953
954
  rules: {
954
- ...eslintRules,
955
- "prettier/prettier": ["warn", pRules],
956
- // eslint-disable-next-line perfectionist/sort-objects
957
- "arrow-body-style": "off",
958
- "prefer-arrow-callback": "off"
955
+ ...config.rules,
956
+ "antfu/consistent-list-newline": "error",
957
+ "antfu/if-newline": "warn",
958
+ "antfu/top-level-function": "warn",
959
+ "curly": ["error", "multi-or-nest", "consistent"],
960
+ ...overrides
959
961
  }
960
962
  }
961
963
  ];
962
- return configs2;
963
964
  }
964
965
 
965
966
  // src/configs/typescript.ts
@@ -1130,9 +1131,9 @@ async function unicorn() {
1130
1131
  rules: {
1131
1132
  // 'unicorn/better-regex': 'error',
1132
1133
  "unicorn/catch-error-name": "error",
1134
+ "unicorn/consistent-empty-array-spread": "error",
1133
1135
  "unicorn/custom-error-definition": "error",
1134
1136
  "unicorn/error-message": "error",
1135
- "unicorn/escape-case": "error",
1136
1137
  // 'unicorn/explicit-length-check': 'error',
1137
1138
  // 'unicorn/filename-case': [
1138
1139
  // 'error',
@@ -1140,6 +1141,7 @@ async function unicorn() {
1140
1141
  // cases: { kebabCase: true, pascalCase: true },
1141
1142
  // ignore: [/^[A-Z]+\..*$/],
1142
1143
  // },
1144
+ "unicorn/escape-case": "error",
1143
1145
  // ],
1144
1146
  "unicorn/new-for-builtins": "error",
1145
1147
  // 'unicorn/no-array-callback-reference': 'error',
@@ -1197,11 +1199,15 @@ async function unicorn() {
1197
1199
  }
1198
1200
 
1199
1201
  // src/configs/vue.ts
1202
+ var import_eslint_merge_processors = require("eslint-merge-processors");
1200
1203
  async function vue(options = {}) {
1201
- const { files = [GLOB_VUE], overrides = {} } = options;
1202
- const [pluginVue, parserVue] = await Promise.all([
1204
+ const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic2 = true } = options;
1205
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1206
+ const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1207
+ const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1203
1208
  interopDefault(import("eslint-plugin-vue")),
1204
- interopDefault(import("vue-eslint-parser"))
1209
+ interopDefault(import("vue-eslint-parser")),
1210
+ interopDefault(import("eslint-processor-vue-blocks"))
1205
1211
  ]);
1206
1212
  const isVue3 = getVueVersion() === 3;
1207
1213
  const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
@@ -1255,7 +1261,16 @@ async function vue(options = {}) {
1255
1261
  }
1256
1262
  },
1257
1263
  name: "coderwyd/vue/rules",
1258
- processor: pluginVue.processors[".vue"],
1264
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors.mergeProcessors)([
1265
+ pluginVue.processors[".vue"],
1266
+ processorVueBlocks({
1267
+ ...sfcBlocks,
1268
+ blocks: {
1269
+ styles: true,
1270
+ ...sfcBlocks.blocks
1271
+ }
1272
+ })
1273
+ ]),
1259
1274
  rules: {
1260
1275
  ...pluginVue.configs.base.rules,
1261
1276
  ...vueRules,
@@ -1283,7 +1298,7 @@ async function vue(options = {}) {
1283
1298
  "vue/dot-location": ["error", "property"],
1284
1299
  "vue/dot-notation": ["error", { allowKeywords: true }],
1285
1300
  "vue/eqeqeq": ["error", "smart"],
1286
- "vue/html-indent": ["error", 2],
1301
+ "vue/html-indent": ["error", indent],
1287
1302
  "vue/html-quotes": ["error", "double"],
1288
1303
  "vue/html-self-closing": [
1289
1304
  "error",
@@ -1333,8 +1348,7 @@ async function vue(options = {}) {
1333
1348
  "vue/space-infix-ops": "error",
1334
1349
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1335
1350
  "vue/valid-define-options": "warn",
1336
- ...{
1337
- // format
1351
+ ...stylistic2 ? {
1338
1352
  "vue/array-bracket-spacing": ["error", "never"],
1339
1353
  "vue/arrow-spacing": ["error", { after: true, before: true }],
1340
1354
  "vue/block-spacing": ["error", "always"],
@@ -1345,7 +1359,11 @@ async function vue(options = {}) {
1345
1359
  singleline: "always"
1346
1360
  }
1347
1361
  ],
1348
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1362
+ "vue/brace-style": [
1363
+ "error",
1364
+ "stroustrup",
1365
+ { allowSingleLine: true }
1366
+ ],
1349
1367
  "vue/comma-dangle": ["error", "always-multiline"],
1350
1368
  "vue/comma-spacing": ["error", { after: true, before: false }],
1351
1369
  "vue/comma-style": ["error", "last"],
@@ -1372,7 +1390,7 @@ async function vue(options = {}) {
1372
1390
  "vue/quote-props": ["error", "consistent-as-needed"],
1373
1391
  "vue/space-in-parens": ["error", "never"],
1374
1392
  "vue/template-curly-spacing": "error"
1375
- },
1393
+ } : {},
1376
1394
  ...overrides
1377
1395
  }
1378
1396
  }
@@ -1438,86 +1456,132 @@ async function perfectionist() {
1438
1456
  // src/configs/react.ts
1439
1457
  var import_local_pkg2 = require("local-pkg");
1440
1458
  var ReactRefreshAllowConstantExportPackages = ["vite"];
1459
+ var RemixPackages = [
1460
+ "@remix-run/node",
1461
+ "@remix-run/react",
1462
+ "@remix-run/serve",
1463
+ "@remix-run/dev"
1464
+ ];
1465
+ var NextJsPackages = ["next"];
1441
1466
  async function react(options = {}) {
1442
- const {
1443
- files = [GLOB_JSX, GLOB_TSX],
1444
- overrides = {},
1445
- typescript: typescript2 = true
1446
- } = options;
1467
+ const { files = [GLOB_TS, GLOB_TSX], overrides = {} } = options;
1447
1468
  await ensurePackages([
1448
- "eslint-plugin-react",
1469
+ "@eslint-react/eslint-plugin",
1449
1470
  "eslint-plugin-react-hooks",
1450
1471
  "eslint-plugin-react-refresh"
1451
1472
  ]);
1452
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
1453
- [
1454
- interopDefault(import("eslint-plugin-react")),
1455
- interopDefault(import("eslint-plugin-react-hooks")),
1456
- interopDefault(import("eslint-plugin-react-refresh"))
1457
- ]
1458
- );
1473
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1474
+ const isTypeAware = !!tsconfigPath;
1475
+ const [pluginReact, pluginReactHooks, pluginReactRefresh, parserTs] = await Promise.all([
1476
+ interopDefault(import("@eslint-react/eslint-plugin")),
1477
+ interopDefault(import("eslint-plugin-react-hooks")),
1478
+ interopDefault(import("eslint-plugin-react-refresh")),
1479
+ interopDefault(import("@typescript-eslint/parser"))
1480
+ ]);
1459
1481
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1460
1482
  (i) => (0, import_local_pkg2.isPackageExists)(i)
1461
1483
  );
1484
+ const isUsingRemix = RemixPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1485
+ const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1486
+ const plugins = pluginReact.configs.all.plugins;
1462
1487
  return [
1463
1488
  {
1464
1489
  name: "coderwyd/react/setup",
1465
1490
  plugins: {
1466
- react: pluginReact,
1491
+ "react": plugins["@eslint-react"],
1492
+ "react-dom": plugins["@eslint-react/dom"],
1467
1493
  "react-hooks": pluginReactHooks,
1494
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1495
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
1468
1496
  "react-refresh": pluginReactRefresh
1469
- },
1470
- settings: {
1471
- react: {
1472
- version: "detect"
1473
- }
1474
1497
  }
1475
1498
  },
1476
1499
  {
1477
1500
  files,
1478
1501
  languageOptions: {
1502
+ parser: parserTs,
1479
1503
  parserOptions: {
1480
1504
  ecmaFeatures: {
1481
1505
  jsx: true
1482
- }
1483
- }
1506
+ },
1507
+ ...isTypeAware ? { project: tsconfigPath } : {}
1508
+ },
1509
+ sourceType: "module"
1484
1510
  },
1485
1511
  name: "coderwyd/react/rules",
1486
1512
  rules: {
1513
+ // recommended rules from @eslint-react/dom
1514
+ "react-dom/no-children-in-void-dom-elements": "warn",
1515
+ "react-dom/no-dangerously-set-innerhtml": "warn",
1516
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1517
+ "react-dom/no-find-dom-node": "error",
1518
+ "react-dom/no-missing-button-type": "warn",
1519
+ "react-dom/no-missing-iframe-sandbox": "warn",
1520
+ "react-dom/no-namespace": "error",
1521
+ "react-dom/no-render-return-value": "error",
1522
+ "react-dom/no-script-url": "warn",
1523
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
1524
+ "react-dom/no-unsafe-target-blank": "warn",
1487
1525
  // recommended rules react-hooks
1488
1526
  "react-hooks/exhaustive-deps": "warn",
1489
1527
  "react-hooks/rules-of-hooks": "error",
1490
1528
  // react refresh
1491
1529
  "react-refresh/only-export-components": [
1492
1530
  "warn",
1493
- { allowConstantExport: isAllowConstantExport }
1531
+ {
1532
+ allowConstantExport: isAllowConstantExport,
1533
+ allowExportNames: [
1534
+ ...isUsingNext ? [
1535
+ "config",
1536
+ "generateStaticParams",
1537
+ "metadata",
1538
+ "generateMetadata",
1539
+ "viewport",
1540
+ "generateViewport"
1541
+ ] : [],
1542
+ ...isUsingRemix ? ["meta", "links", "headers", "loader", "action"] : []
1543
+ ]
1544
+ }
1494
1545
  ],
1495
- // recommended rules react
1496
- "react/display-name": "error",
1497
- "react/jsx-key": "error",
1498
- "react/jsx-no-comment-textnodes": "error",
1499
- "react/jsx-no-duplicate-props": "error",
1500
- "react/jsx-no-target-blank": "error",
1501
- "react/jsx-no-undef": "error",
1502
- "react/jsx-uses-react": "error",
1503
- "react/jsx-uses-vars": "error",
1504
- "react/no-children-prop": "error",
1505
- "react/no-danger-with-children": "error",
1506
- "react/no-deprecated": "error",
1546
+ // recommended rules from @eslint-react
1547
+ "react/ensure-forward-ref-using-ref": "warn",
1548
+ "react/no-access-state-in-setstate": "error",
1549
+ "react/no-array-index-key": "warn",
1550
+ "react/no-children-count": "warn",
1551
+ "react/no-children-for-each": "warn",
1552
+ "react/no-children-map": "warn",
1553
+ "react/no-children-only": "warn",
1554
+ "react/no-children-prop": "warn",
1555
+ "react/no-children-to-array": "warn",
1556
+ "react/no-clone-element": "warn",
1557
+ "react/no-comment-textnodes": "warn",
1558
+ "react/no-component-will-mount": "error",
1559
+ "react/no-component-will-receive-props": "error",
1560
+ "react/no-component-will-update": "error",
1561
+ "react/no-create-ref": "error",
1507
1562
  "react/no-direct-mutation-state": "error",
1508
- "react/no-find-dom-node": "error",
1509
- "react/no-is-mounted": "error",
1510
- "react/no-render-return-value": "error",
1563
+ "react/no-duplicate-key": "error",
1564
+ "react/no-implicit-key": "error",
1565
+ "react/no-missing-key": "error",
1566
+ "react/no-nested-components": "warn",
1567
+ "react/no-redundant-should-component-update": "error",
1568
+ "react/no-set-state-in-component-did-mount": "warn",
1569
+ "react/no-set-state-in-component-did-update": "warn",
1570
+ "react/no-set-state-in-component-will-update": "warn",
1511
1571
  "react/no-string-refs": "error",
1512
- "react/no-unescaped-entities": "error",
1513
- "react/no-unknown-property": "error",
1514
- "react/no-unsafe": "off",
1515
- "react/prop-types": "error",
1516
- "react/react-in-jsx-scope": "off",
1517
- "react/require-render-return": "error",
1518
- ...typescript2 ? {
1519
- "react/jsx-no-undef": "off",
1520
- "react/prop-type": "off"
1572
+ "react/no-unsafe-component-will-mount": "warn",
1573
+ "react/no-unsafe-component-will-receive-props": "warn",
1574
+ "react/no-unsafe-component-will-update": "warn",
1575
+ "react/no-unstable-context-value": "error",
1576
+ "react/no-unstable-default-props": "error",
1577
+ "react/no-unused-class-component-members": "warn",
1578
+ "react/no-unused-state": "warn",
1579
+ "react/no-useless-fragment": "warn",
1580
+ "react/prefer-destructuring-assignment": "warn",
1581
+ "react/prefer-shorthand-boolean": "warn",
1582
+ "react/prefer-shorthand-fragment": "warn",
1583
+ ...isTypeAware ? {
1584
+ "react/no-leaked-conditional-rendering": "warn"
1521
1585
  } : {},
1522
1586
  // overrides
1523
1587
  ...overrides
@@ -1553,7 +1617,7 @@ async function unocss(options = {}) {
1553
1617
  }
1554
1618
 
1555
1619
  // src/configs/formatter.ts
1556
- async function formatter(options = {}, prettierRules2 = {}) {
1620
+ async function formatter(options = {}, stylistic2 = {}) {
1557
1621
  const { css, graphql, html, markdown, toml, yaml } = options === true ? {
1558
1622
  css: true,
1559
1623
  graphql: true,
@@ -1562,10 +1626,27 @@ async function formatter(options = {}, prettierRules2 = {}) {
1562
1626
  toml: true,
1563
1627
  yaml: true
1564
1628
  } : options;
1565
- const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
1629
+ const { indent, quotes, semi } = {
1630
+ ...StylisticConfigDefaults,
1631
+ ...stylistic2
1632
+ };
1633
+ const prettierOptions = Object.assign(
1634
+ {
1635
+ endOfLine: "auto",
1636
+ printWidth: 80,
1637
+ semi,
1638
+ singleQuote: quotes === "single",
1639
+ tabWidth: typeof indent === "number" ? indent : 2,
1640
+ trailingComma: "all",
1641
+ useTabs: indent === "tab"
1642
+ },
1643
+ typeof options === "boolean" ? {} : options.prettierOptions || {}
1644
+ );
1645
+ await ensurePackages(["eslint-plugin-format"]);
1646
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
1566
1647
  function createPrettierFormatter(files, parser, plugins) {
1567
1648
  const rules = {
1568
- ...prettierRules2,
1649
+ ...prettierOptions,
1569
1650
  parser
1570
1651
  };
1571
1652
  const markdownRules = {
@@ -1573,9 +1654,8 @@ async function formatter(options = {}, prettierRules2 = {}) {
1573
1654
  ...rules,
1574
1655
  embeddedLanguageFormatting: "off"
1575
1656
  };
1576
- if (plugins?.length) {
1657
+ if (plugins?.length)
1577
1658
  rules.plugins = [...rules.plugins || [], ...plugins];
1578
- }
1579
1659
  const config = {
1580
1660
  files,
1581
1661
  languageOptions: {
@@ -1583,10 +1663,10 @@ async function formatter(options = {}, prettierRules2 = {}) {
1583
1663
  },
1584
1664
  name: `coderwyd/formatter/${parser}`,
1585
1665
  plugins: {
1586
- prettier: pluginPrettier
1666
+ format: pluginFormat
1587
1667
  },
1588
1668
  rules: {
1589
- "prettier/prettier": [
1669
+ "format/prettier": [
1590
1670
  "warn",
1591
1671
  parser === "markdown" ? markdownRules : rules
1592
1672
  ]
@@ -1598,7 +1678,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1598
1678
  {
1599
1679
  name: "coderwyd/formatter/setup",
1600
1680
  plugins: {
1601
- prettier: pluginPrettier
1681
+ format: pluginFormat
1602
1682
  }
1603
1683
  }
1604
1684
  ];
@@ -1636,7 +1716,11 @@ async function formatter(options = {}, prettierRules2 = {}) {
1636
1716
 
1637
1717
  // src/configs/svelte.ts
1638
1718
  async function svelte(options = {}) {
1639
- const { files = [GLOB_SVELTE], overrides = {} } = options;
1719
+ const { files = [GLOB_SVELTE], overrides = {}, stylistic: stylistic2 = true } = options;
1720
+ const {
1721
+ indent = 2,
1722
+ quotes = "single"
1723
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1640
1724
  await ensurePackages(["eslint-plugin-svelte"]);
1641
1725
  const [pluginSvelte, parserSvelte] = await Promise.all([
1642
1726
  interopDefault(import("eslint-plugin-svelte")),
@@ -1706,22 +1790,23 @@ async function svelte(options = {}) {
1706
1790
  varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1707
1791
  }
1708
1792
  ],
1709
- ...{
1710
- // format
1793
+ ...stylistic2 ? {
1794
+ "style/indent": "off",
1795
+ // superseded by svelte/indent
1711
1796
  "style/no-trailing-spaces": "off",
1712
1797
  // superseded by svelte/no-trailing-spaces
1713
1798
  "svelte/derived-has-same-inputs-outputs": "error",
1714
1799
  "svelte/html-closing-bracket-spacing": "error",
1715
- "svelte/html-quotes": ["error", { prefer: "single" }],
1800
+ "svelte/html-quotes": ["error", { prefer: quotes }],
1716
1801
  "svelte/indent": [
1717
1802
  "error",
1718
- { alignAttributesVertically: true, indent: 2 }
1803
+ { alignAttributesVertically: true, indent }
1719
1804
  ],
1720
1805
  "svelte/mustache-spacing": "error",
1721
1806
  "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1722
1807
  "svelte/no-trailing-spaces": "error",
1723
1808
  "svelte/spaced-html-comment": "error"
1724
- },
1809
+ } : {},
1725
1810
  ...overrides
1726
1811
  }
1727
1812
  }
@@ -1813,11 +1898,16 @@ var flatConfigProps = [
1813
1898
  "settings"
1814
1899
  ];
1815
1900
  var defaultPluginRenaming = {
1901
+ "@eslint-react": "react",
1902
+ "@eslint-react/dom": "react-dom",
1903
+ "@eslint-react/hooks-extra": "react-hooks-extra",
1904
+ "@eslint-react/naming-convention": "react-naming-convention",
1905
+ "@stylistic": "style",
1816
1906
  "@typescript-eslint": "ts",
1817
1907
  "import-x": "import",
1818
- n: "node",
1819
- vitest: "test",
1820
- yml: "yaml"
1908
+ "n": "node",
1909
+ "vitest": "test",
1910
+ "yml": "yaml"
1821
1911
  };
1822
1912
  async function defineConfig(options = {}, ...userConfigs) {
1823
1913
  const {
@@ -1835,9 +1925,11 @@ async function defineConfig(options = {}, ...userConfigs) {
1835
1925
  tailwindcss: enableTailwindCSS = hasTailwindCSS,
1836
1926
  typescript: enableTypeScript = hasTypeScript,
1837
1927
  unocss: enableUnoCSS = false,
1838
- usePrettierrc = true,
1839
1928
  vue: enableVue = hasVue
1840
1929
  } = options;
1930
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1931
+ if (stylisticOptions && !("jsx" in stylisticOptions))
1932
+ stylisticOptions.jsx = options.jsx ?? true;
1841
1933
  const configs2 = [];
1842
1934
  if (enableGitignore) {
1843
1935
  if (typeof enableGitignore !== "boolean") {
@@ -1847,12 +1939,13 @@ async function defineConfig(options = {}, ...userConfigs) {
1847
1939
  ])
1848
1940
  );
1849
1941
  } else {
1850
- if (import_node_fs.default.existsSync(".gitignore"))
1942
+ if (import_node_fs.default.existsSync(".gitignore")) {
1851
1943
  configs2.push(
1852
1944
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1853
1945
  r()
1854
1946
  ])
1855
1947
  );
1948
+ }
1856
1949
  }
1857
1950
  }
1858
1951
  configs2.push(
@@ -1863,8 +1956,12 @@ async function defineConfig(options = {}, ...userConfigs) {
1863
1956
  }),
1864
1957
  comments(),
1865
1958
  node(),
1866
- jsdoc(),
1867
- imports(),
1959
+ jsdoc({
1960
+ stylistic: stylisticOptions
1961
+ }),
1962
+ imports({
1963
+ stylistic: stylisticOptions
1964
+ }),
1868
1965
  unicorn(),
1869
1966
  command(),
1870
1967
  // Optional plugins (installed but not enabled by default)
@@ -1881,6 +1978,14 @@ async function defineConfig(options = {}, ...userConfigs) {
1881
1978
  })
1882
1979
  );
1883
1980
  }
1981
+ if (stylisticOptions) {
1982
+ configs2.push(
1983
+ stylistic({
1984
+ ...stylisticOptions,
1985
+ overrides: getOverrides(options, "stylistic")
1986
+ })
1987
+ );
1988
+ }
1884
1989
  if (enableRegexp)
1885
1990
  configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1886
1991
  if (options.test ?? true) {
@@ -1896,6 +2001,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1896
2001
  vue({
1897
2002
  ...resolveSubOptions(options, "vue"),
1898
2003
  overrides: getOverrides(options, "typescript"),
2004
+ stylistic: stylisticOptions,
1899
2005
  typescript: !!enableTypeScript
1900
2006
  })
1901
2007
  );
@@ -1904,7 +2010,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1904
2010
  configs2.push(
1905
2011
  react({
1906
2012
  overrides: getOverrides(options, "react"),
1907
- typescript: !!enableTypeScript
2013
+ tsconfigPath: getOverrides(options, "typescript").tsconfigPath
1908
2014
  })
1909
2015
  );
1910
2016
  }
@@ -1912,6 +2018,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1912
2018
  configs2.push(
1913
2019
  svelte({
1914
2020
  overrides: getOverrides(options, "svelte"),
2021
+ stylistic: stylisticOptions,
1915
2022
  typescript: !!enableTypeScript
1916
2023
  })
1917
2024
  );
@@ -1935,31 +2042,20 @@ async function defineConfig(options = {}, ...userConfigs) {
1935
2042
  if (options.jsonc ?? true) {
1936
2043
  configs2.push(
1937
2044
  jsonc({
1938
- overrides: getOverrides(options, "jsonc")
2045
+ overrides: getOverrides(options, "jsonc"),
2046
+ stylistic: stylisticOptions
1939
2047
  }),
1940
2048
  sortPackageJson(),
1941
2049
  sortTsconfig()
1942
2050
  );
1943
2051
  }
1944
2052
  if (formatterOptions) {
1945
- let prettierRules2 = {
1946
- ...DEFAULT_PRETTIER_RULES
1947
- };
1948
- if (options.prettierRules) {
1949
- prettierRules2 = { ...prettierRules2, ...options.prettierRules };
1950
- }
1951
- if (usePrettierrc) {
1952
- const prettierConfig = await loadPrettierConfig(
1953
- options.cwd ?? import_node_process4.default.cwd()
1954
- );
1955
- Object.assign(prettierRules2, prettierConfig);
1956
- }
1957
2053
  configs2.push(
1958
- prettier(prettierRules2),
1959
- formatter(formatterOptions, prettierRules2)
2054
+ formatter(
2055
+ formatterOptions,
2056
+ typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2057
+ )
1960
2058
  );
1961
- } else {
1962
- configs2.push(prettier());
1963
2059
  }
1964
2060
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1965
2061
  if (key in options)
@@ -1982,7 +2078,6 @@ async function defineConfig(options = {}, ...userConfigs) {
1982
2078
  getOverrides,
1983
2079
  getVueVersion,
1984
2080
  interopDefault,
1985
- loadPrettierConfig,
1986
2081
  parserPlain,
1987
2082
  renamePluginInConfigs,
1988
2083
  renameRules,