@coderwyd/eslint-config 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -30,63 +30,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- GLOB_ALL_SRC: () => GLOB_ALL_SRC,
34
- GLOB_CSS: () => GLOB_CSS,
35
- GLOB_EXCLUDE: () => GLOB_EXCLUDE,
36
- GLOB_HTML: () => GLOB_HTML,
37
- GLOB_JS: () => GLOB_JS,
38
- GLOB_JSON: () => GLOB_JSON,
39
- GLOB_JSON5: () => GLOB_JSON5,
40
- GLOB_JSONC: () => GLOB_JSONC,
41
- GLOB_JSX: () => GLOB_JSX,
42
- GLOB_LESS: () => GLOB_LESS,
43
- GLOB_MARKDOWN: () => GLOB_MARKDOWN,
44
- GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
45
- GLOB_SCSS: () => GLOB_SCSS,
46
- GLOB_SRC: () => GLOB_SRC,
47
- GLOB_SRC_EXT: () => GLOB_SRC_EXT,
48
- GLOB_STYLE: () => GLOB_STYLE,
49
- GLOB_TESTS: () => GLOB_TESTS,
50
- GLOB_TS: () => GLOB_TS,
51
- GLOB_TSX: () => GLOB_TSX,
52
- GLOB_VUE: () => GLOB_VUE,
53
- GLOB_YAML: () => GLOB_YAML,
54
- coderwyd: () => coderwyd,
55
- combine: () => combine,
56
- comments: () => comments,
57
- default: () => src_default,
58
- ensurePackages: () => ensurePackages,
59
- getVueVersion: () => getVueVersion,
60
- ignores: () => ignores,
61
- imports: () => imports,
62
- interopDefault: () => interopDefault,
63
- javascript: () => javascript,
64
- jsdoc: () => jsdoc,
65
- jsonc: () => jsonc,
66
- markdown: () => markdown,
67
- node: () => node,
68
- perfectionist: () => perfectionist,
69
- react: () => react,
70
- renameRules: () => renameRules,
71
- sortPackageJson: () => sortPackageJson,
72
- sortTsconfig: () => sortTsconfig,
73
- stylistic: () => stylistic,
74
- test: () => test,
75
- toArray: () => toArray,
76
- typescript: () => typescript,
77
- unicorn: () => unicorn,
78
- unocss: () => unocss,
79
- vue: () => vue,
80
- yaml: () => yaml
33
+ defineConfig: () => defineConfig
81
34
  });
82
35
  module.exports = __toCommonJS(src_exports);
83
-
84
- // src/factory.ts
85
36
  var import_node_process3 = __toESM(require("process"), 1);
86
37
  var import_node_fs = __toESM(require("fs"), 1);
87
38
  var import_local_pkg3 = require("local-pkg");
88
39
 
89
- // src/plugins.ts
40
+ // src/constants/prettier.ts
41
+ var DEFAULT_PRETTIER_RULES = {
42
+ arrowParens: "avoid",
43
+ htmlWhitespaceSensitivity: "ignore",
44
+ printWidth: 80,
45
+ semi: false,
46
+ singleQuote: true
47
+ };
48
+
49
+ // src/plugins/index.ts
90
50
  var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
91
51
  var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
92
52
  var pluginImport = __toESM(require("eslint-plugin-i"), 1);
@@ -113,24 +73,26 @@ async function comments() {
113
73
  ];
114
74
  }
115
75
 
116
- // src/globs.ts
76
+ // src/constants/glob.ts
117
77
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
118
78
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
119
- var GLOB_JS = "**/*.?([cm])js";
120
79
  var GLOB_JSX = "**/*.?([cm])jsx";
121
80
  var GLOB_TS = "**/*.?([cm])ts";
122
81
  var GLOB_TSX = "**/*.?([cm])tsx";
123
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
82
+ var GLOB_VUE = "**/*.vue";
83
+ var GLOB_HTML = "**/*.htm?(l)";
124
84
  var GLOB_CSS = "**/*.css";
85
+ var GLOB_POSTCSS = "**/*.{p,post}css";
125
86
  var GLOB_LESS = "**/*.less";
126
87
  var GLOB_SCSS = "**/*.scss";
127
88
  var GLOB_JSON = "**/*.json";
128
89
  var GLOB_JSON5 = "**/*.json5";
129
90
  var GLOB_JSONC = "**/*.jsonc";
130
91
  var GLOB_MARKDOWN = "**/*.md";
131
- var GLOB_VUE = "**/*.vue";
132
92
  var GLOB_YAML = "**/*.y?(a)ml";
133
- var GLOB_HTML = "**/*.htm?(l)";
93
+ var GLOB_TOML = "**/*.toml";
94
+ var GLOB_GRAPHQL = "**/*.graphql";
95
+ var GLOB_PRETTIER_LINT = [GLOB_SRC, GLOB_VUE];
134
96
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
135
97
  var GLOB_TESTS = [
136
98
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -139,16 +101,6 @@ var GLOB_TESTS = [
139
101
  `**/*.bench.${GLOB_SRC_EXT}`,
140
102
  `**/*.benchmark.${GLOB_SRC_EXT}`
141
103
  ];
142
- var GLOB_ALL_SRC = [
143
- GLOB_SRC,
144
- GLOB_STYLE,
145
- GLOB_JSON,
146
- GLOB_JSON5,
147
- GLOB_MARKDOWN,
148
- GLOB_VUE,
149
- GLOB_YAML,
150
- GLOB_HTML
151
- ];
152
104
  var GLOB_EXCLUDE = [
153
105
  "**/node_modules",
154
106
  "**/dist",
@@ -190,10 +142,7 @@ async function ignores() {
190
142
  }
191
143
 
192
144
  // src/configs/imports.ts
193
- async function imports(options = {}) {
194
- const {
195
- stylistic: stylistic2 = true
196
- } = options;
145
+ async function imports() {
197
146
  return [
198
147
  {
199
148
  name: "coderwyd:imports",
@@ -203,17 +152,61 @@ async function imports(options = {}) {
203
152
  },
204
153
  rules: {
205
154
  "antfu/import-dedupe": "error",
155
+ "antfu/no-import-dist": "error",
206
156
  "antfu/no-import-node-modules-by-path": "error",
207
157
  "import/first": "error",
158
+ "import/newline-after-import": [
159
+ "error",
160
+ { considerComments: true, count: 1 }
161
+ ],
162
+ "import/no-default-export": "error",
208
163
  "import/no-duplicates": "error",
209
164
  "import/no-mutable-exports": "error",
210
165
  "import/no-named-default": "error",
211
166
  "import/no-self-import": "error",
212
167
  "import/no-webpack-loader-syntax": "error",
213
- "import/order": "error",
214
- ...stylistic2 ? {
215
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
216
- } : {}
168
+ "import/order": [
169
+ "error",
170
+ {
171
+ groups: [
172
+ "builtin",
173
+ "external",
174
+ "internal",
175
+ "parent",
176
+ "sibling",
177
+ "index",
178
+ "object",
179
+ "type"
180
+ ],
181
+ pathGroups: [{ group: "internal", pattern: "{{@,~}/,#}**" }],
182
+ pathGroupsExcludedImportTypes: ["type"]
183
+ }
184
+ ]
185
+ }
186
+ },
187
+ {
188
+ files: [
189
+ `**/*config*.${GLOB_SRC_EXT}`,
190
+ `**/views/${GLOB_SRC}`,
191
+ `**/pages/${GLOB_SRC}`,
192
+ `**/{index,vite,esbuild,rollup,webpack,rspack}.ts`,
193
+ "**/*.d.ts",
194
+ `${GLOB_MARKDOWN}/**`,
195
+ "**/.prettierrc*"
196
+ ],
197
+ plugins: {
198
+ import: pluginImport
199
+ },
200
+ rules: {
201
+ "import/no-default-export": "off"
202
+ }
203
+ },
204
+ {
205
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
206
+ name: "antfu:imports:bin",
207
+ rules: {
208
+ "antfu/no-import-dist": "off",
209
+ "antfu/no-import-node-modules-by-path": "off"
217
210
  }
218
211
  }
219
212
  ];
@@ -222,10 +215,7 @@ async function imports(options = {}) {
222
215
  // src/configs/javascript.ts
223
216
  var import_globals = __toESM(require("globals"), 1);
224
217
  async function javascript(options = {}) {
225
- const {
226
- isInEditor = false,
227
- overrides = {}
228
- } = options;
218
+ const { isInEditor = false, overrides = {} } = options;
229
219
  return [
230
220
  {
231
221
  languageOptions: {
@@ -252,18 +242,23 @@ async function javascript(options = {}) {
252
242
  },
253
243
  name: "coderwyd:javascript",
254
244
  plugins: {
255
- "antfu": import_eslint_plugin_antfu.default,
256
245
  "unused-imports": import_eslint_plugin_unused_imports.default
257
246
  },
258
247
  rules: {
259
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
248
+ "accessor-pairs": [
249
+ "error",
250
+ { enforceForClassMembers: true, setWithoutGet: true }
251
+ ],
260
252
  "array-callback-return": "error",
261
253
  "block-scoped-var": "error",
262
254
  "constructor-super": "error",
263
255
  "default-case-last": "error",
264
256
  "dot-notation": ["error", { allowKeywords: true }],
265
- "eqeqeq": ["error", "smart"],
266
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
257
+ eqeqeq: ["error", "smart"],
258
+ "new-cap": [
259
+ "error",
260
+ { capIsNew: false, newIsCap: true, properties: true }
261
+ ],
267
262
  "no-alert": "error",
268
263
  "no-array-constructor": "error",
269
264
  "no-async-promise-executor": "error",
@@ -321,11 +316,26 @@ async function javascript(options = {}) {
321
316
  ],
322
317
  "no-restricted-properties": [
323
318
  "error",
324
- { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
325
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
326
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
327
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
328
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
319
+ {
320
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
321
+ property: "__proto__"
322
+ },
323
+ {
324
+ message: "Use `Object.defineProperty` instead.",
325
+ property: "__defineGetter__"
326
+ },
327
+ {
328
+ message: "Use `Object.defineProperty` instead.",
329
+ property: "__defineSetter__"
330
+ },
331
+ {
332
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
333
+ property: "__lookupGetter__"
334
+ },
335
+ {
336
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
337
+ property: "__lookupSetter__"
338
+ }
329
339
  ],
330
340
  "no-restricted-syntax": [
331
341
  "error",
@@ -352,18 +362,27 @@ async function javascript(options = {}) {
352
362
  "no-unreachable-loop": "error",
353
363
  "no-unsafe-finally": "error",
354
364
  "no-unsafe-negation": "error",
355
- "no-unused-expressions": ["error", {
356
- allowShortCircuit: true,
357
- allowTaggedTemplates: true,
358
- allowTernary: true
359
- }],
360
- "no-unused-vars": ["error", {
361
- args: "none",
362
- caughtErrors: "none",
363
- ignoreRestSiblings: true,
364
- vars: "all"
365
- }],
366
- "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
365
+ "no-unused-expressions": [
366
+ "error",
367
+ {
368
+ allowShortCircuit: true,
369
+ allowTaggedTemplates: true,
370
+ allowTernary: true
371
+ }
372
+ ],
373
+ "no-unused-vars": [
374
+ "error",
375
+ {
376
+ args: "none",
377
+ caughtErrors: "none",
378
+ ignoreRestSiblings: true,
379
+ vars: "all"
380
+ }
381
+ ],
382
+ "no-use-before-define": [
383
+ "error",
384
+ { classes: false, functions: false, variables: true }
385
+ ],
367
386
  "no-useless-backreference": "error",
368
387
  "no-useless-call": "error",
369
388
  "no-useless-catch": "error",
@@ -417,12 +436,20 @@ async function javascript(options = {}) {
417
436
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
418
437
  "unused-imports/no-unused-vars": [
419
438
  "error",
420
- { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
439
+ {
440
+ args: "after-used",
441
+ argsIgnorePattern: "^_",
442
+ vars: "all",
443
+ varsIgnorePattern: "^_"
444
+ }
445
+ ],
446
+ "use-isnan": [
447
+ "error",
448
+ { enforceForIndexOf: true, enforceForSwitchCase: true }
421
449
  ],
422
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
423
450
  "valid-typeof": ["error", { requireStringLiterals: true }],
424
451
  "vars-on-top": "error",
425
- "yoda": ["error", "never"],
452
+ yoda: ["error", "never"],
426
453
  ...overrides
427
454
  }
428
455
  },
@@ -436,9 +463,31 @@ async function javascript(options = {}) {
436
463
  ];
437
464
  }
438
465
 
439
- // src/utils.ts
466
+ // src/shared/index.ts
440
467
  var import_node_process = __toESM(require("process"), 1);
468
+ var import_promises = require("fs/promises");
469
+ var import_node_path = __toESM(require("path"), 1);
441
470
  var import_local_pkg = require("local-pkg");
471
+ var parserPlain = {
472
+ meta: {
473
+ name: "parser-plain"
474
+ },
475
+ parseForESLint: (code) => ({
476
+ ast: {
477
+ body: [],
478
+ comments: [],
479
+ loc: { end: code.length, start: 0 },
480
+ range: [0, code.length],
481
+ tokens: [],
482
+ type: "Program"
483
+ },
484
+ scopeManager: null,
485
+ services: { isPlain: true },
486
+ visitorKeys: {
487
+ Program: []
488
+ }
489
+ })
490
+ };
442
491
  async function combine(...configs) {
443
492
  const resolved = await Promise.all(configs);
444
493
  return resolved.flat();
@@ -474,20 +523,41 @@ async function ensurePackages(packages) {
474
523
  const { default: prompts } = await import("prompts");
475
524
  const { result } = await prompts([
476
525
  {
477
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
526
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(
527
+ ", "
528
+ )}. Do you want to install them?`,
478
529
  name: "result",
479
530
  type: "confirm"
480
531
  }
481
532
  ]);
482
533
  if (result)
483
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
534
+ await import("@antfu/install-pkg").then(
535
+ (i) => i.installPackage(nonExistingPackages, { dev: true })
536
+ );
537
+ }
538
+ async function loadPrettierConfig(cwd) {
539
+ let prettierConfig = {};
540
+ try {
541
+ const prettierrc = await (0, import_promises.readFile)(import_node_path.default.join(cwd, ".prettierrc"), "utf-8");
542
+ prettierConfig = JSON.parse(prettierrc);
543
+ } catch {
544
+ }
545
+ return prettierConfig;
546
+ }
547
+ function resolveSubOptions(options, key) {
548
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
549
+ }
550
+ function getOverrides(options, key) {
551
+ var _a;
552
+ const sub = resolveSubOptions(options, key);
553
+ return {
554
+ ...(_a = options.overrides) == null ? void 0 : _a[key],
555
+ ..."overrides" in sub ? sub.overrides : {}
556
+ };
484
557
  }
485
558
 
486
559
  // src/configs/jsdoc.ts
487
- async function jsdoc(options = {}) {
488
- const {
489
- stylistic: stylistic2 = true
490
- } = options;
560
+ async function jsdoc() {
491
561
  return [
492
562
  {
493
563
  name: "coderwyd:jsdoc",
@@ -510,11 +580,12 @@ async function jsdoc(options = {}) {
510
580
  "jsdoc/require-property-name": "warn",
511
581
  "jsdoc/require-returns-check": "warn",
512
582
  "jsdoc/require-returns-description": "warn",
513
- "jsdoc/require-yields-check": "warn",
514
- ...stylistic2 ? {
515
- "jsdoc/check-alignment": "warn",
516
- "jsdoc/multiline-blocks": "warn"
517
- } : {}
583
+ "jsdoc/require-yields-check": "warn"
584
+ // style
585
+ // ...{
586
+ // 'jsdoc/check-alignment': 'warn',
587
+ // 'jsdoc/multiline-blocks': 'warn',
588
+ // }
518
589
  }
519
590
  }
520
591
  ];
@@ -522,18 +593,8 @@ async function jsdoc(options = {}) {
522
593
 
523
594
  // src/configs/jsonc.ts
524
595
  async function jsonc(options = {}) {
525
- const {
526
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
527
- overrides = {},
528
- stylistic: stylistic2 = true
529
- } = options;
530
- const {
531
- indent = 2
532
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
533
- const [
534
- pluginJsonc,
535
- parserJsonc
536
- ] = await Promise.all([
596
+ const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides = {} } = options || {};
597
+ const [pluginJsonc, parserJsonc] = await Promise.all([
537
598
  interopDefault(import("eslint-plugin-jsonc")),
538
599
  interopDefault(import("jsonc-eslint-parser"))
539
600
  ]);
@@ -577,101 +638,19 @@ async function jsonc(options = {}) {
577
638
  "jsonc/space-unary-ops": "error",
578
639
  "jsonc/valid-json-number": "error",
579
640
  "jsonc/vue-custom-block/no-parsing-error": "error",
580
- ...stylistic2 ? {
581
- "jsonc/array-bracket-spacing": ["error", "never"],
582
- "jsonc/comma-dangle": ["error", "never"],
583
- "jsonc/comma-style": ["error", "last"],
584
- "jsonc/indent": ["error", indent],
585
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
586
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
587
- "jsonc/object-curly-spacing": ["error", "always"],
588
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
589
- "jsonc/quote-props": "error",
590
- "jsonc/quotes": "error"
591
- } : {},
592
- ...overrides
593
- }
594
- }
595
- ];
596
- }
597
-
598
- // src/configs/markdown.ts
599
- async function markdown(options = {}) {
600
- const {
601
- componentExts = [],
602
- files = [GLOB_MARKDOWN],
603
- overrides = {}
604
- } = options;
605
- return [
606
- {
607
- name: "coderwyd:markdown:setup",
608
- plugins: {
609
- // @ts-expect-error missing types
610
- markdown: await interopDefault(import("eslint-plugin-markdown"))
611
- }
612
- },
613
- {
614
- files,
615
- name: "coderwyd:markdown:processor",
616
- processor: "markdown/markdown"
617
- },
618
- {
619
- files: [
620
- GLOB_MARKDOWN_CODE,
621
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
622
- ],
623
- languageOptions: {
624
- parserOptions: {
625
- ecmaFeatures: {
626
- impliedStrict: true
627
- }
628
- }
629
- },
630
- name: "coderwyd:markdown:rules",
631
- rules: {
632
- "antfu/no-ts-export-equal": "off",
633
- "import/newline-after-import": "off",
634
- "no-alert": "off",
635
- "no-console": "off",
636
- "no-labels": "off",
637
- "no-lone-blocks": "off",
638
- "no-restricted-syntax": "off",
639
- "no-undef": "off",
640
- "no-unused-expressions": "off",
641
- "no-unused-labels": "off",
642
- "no-unused-vars": "off",
643
- "node/prefer-global/process": "off",
644
- "style/comma-dangle": "off",
645
- "style/eol-last": "off",
646
- "ts/consistent-type-imports": "off",
647
- "ts/no-namespace": "off",
648
- "ts/no-redeclare": "off",
649
- "ts/no-require-imports": "off",
650
- "ts/no-unused-vars": "off",
651
- "ts/no-use-before-define": "off",
652
- "ts/no-var-requires": "off",
653
- "unicode-bom": "off",
654
- "unused-imports/no-unused-imports": "off",
655
- "unused-imports/no-unused-vars": "off",
656
- // Type aware rules
657
- ...{
658
- "ts/await-thenable": "off",
659
- "ts/dot-notation": "off",
660
- "ts/no-floating-promises": "off",
661
- "ts/no-for-in-array": "off",
662
- "ts/no-implied-eval": "off",
663
- "ts/no-misused-promises": "off",
664
- "ts/no-throw-literal": "off",
665
- "ts/no-unnecessary-type-assertion": "off",
666
- "ts/no-unsafe-argument": "off",
667
- "ts/no-unsafe-assignment": "off",
668
- "ts/no-unsafe-call": "off",
669
- "ts/no-unsafe-member-access": "off",
670
- "ts/no-unsafe-return": "off",
671
- "ts/restrict-plus-operands": "off",
672
- "ts/restrict-template-expressions": "off",
673
- "ts/unbound-method": "off"
674
- },
641
+ // style
642
+ // ...{
643
+ // 'jsonc/array-bracket-spacing': ['error', 'never'],
644
+ // 'jsonc/comma-dangle': ['error', 'never'],
645
+ // 'jsonc/comma-style': ['error', 'last'],
646
+ // 'jsonc/indent': ['error', indent],
647
+ // 'jsonc/key-spacing': ['error', { afterColon: true, beforeColon: false }],
648
+ // 'jsonc/object-curly-newline': ['error', { consistent: true, multiline: true }],
649
+ // 'jsonc/object-curly-spacing': ['error', 'always'],
650
+ // 'jsonc/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
651
+ // 'jsonc/quote-props': 'error',
652
+ // 'jsonc/quotes': 'error',
653
+ // },
675
654
  ...overrides
676
655
  }
677
656
  }
@@ -766,23 +745,14 @@ async function sortPackageJson() {
766
745
  },
767
746
  {
768
747
  order: { type: "asc" },
769
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
748
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
770
749
  },
771
750
  {
772
751
  order: { type: "asc" },
773
- pathPattern: "^resolutions$"
752
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
774
753
  },
775
754
  {
776
- order: { type: "asc" },
777
- pathPattern: "^pnpm.overrides$"
778
- },
779
- {
780
- order: [
781
- "types",
782
- "import",
783
- "require",
784
- "default"
785
- ],
755
+ order: ["types", "import", "require", "default"],
786
756
  pathPattern: "^exports.*$"
787
757
  }
788
758
  ]
@@ -916,54 +886,40 @@ function sortTsconfig() {
916
886
  ];
917
887
  }
918
888
 
919
- // src/configs/stylistic.ts
920
- async function stylistic(options = {}) {
921
- const {
922
- indent = 2,
923
- jsx = true,
924
- quotes = "single",
925
- semi = false
926
- } = options;
927
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
928
- const config = pluginStylistic.configs.customize({
929
- flat: true,
930
- indent,
931
- jsx,
932
- pluginName: "style",
933
- quotes,
934
- semi
935
- });
936
- return [
889
+ // src/configs/prettier.ts
890
+ var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
891
+ var { rules: eslintRules } = import_eslint_config_prettier.default;
892
+ async function prettier(rules) {
893
+ const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
894
+ const pRules = {
895
+ ...rules
896
+ };
897
+ const configs = [
937
898
  {
938
- name: "coderwyd:stylistic",
899
+ files: GLOB_PRETTIER_LINT,
939
900
  plugins: {
940
- antfu: import_eslint_plugin_antfu.default,
941
- style: pluginStylistic
901
+ prettier: pluginPrettier
942
902
  },
943
903
  rules: {
944
- ...config.rules,
945
- "antfu/consistent-list-newline": "error",
946
- "antfu/if-newline": "error",
947
- "antfu/indent-binary-ops": ["error", { indent }],
948
- "antfu/top-level-function": "error",
949
- "curly": ["error", "multi-or-nest", "consistent"]
904
+ ...eslintRules,
905
+ "arrow-body-style": "off",
906
+ "prefer-arrow-callback": "off",
907
+ "prettier/prettier": ["warn", pRules]
950
908
  }
951
909
  }
952
910
  ];
911
+ return configs;
953
912
  }
954
913
 
955
914
  // src/configs/typescript.ts
956
915
  var import_node_process2 = __toESM(require("process"), 1);
957
916
  async function typescript(options = {}) {
958
- const {
959
- componentExts = [],
960
- overrides = {},
961
- parserOptions = {}
962
- } = options;
917
+ const { componentExts = [], overrides = {}, parserOptions = {} } = options;
963
918
  const files = options.files ?? [
964
919
  GLOB_SRC,
965
920
  ...componentExts.map((ext) => `**/*.${ext}`)
966
921
  ];
922
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
967
923
  const typeAwareRules = {
968
924
  "dot-notation": "off",
969
925
  "no-implied-eval": "off",
@@ -985,11 +941,8 @@ async function typescript(options = {}) {
985
941
  "ts/restrict-template-expressions": "error",
986
942
  "ts/unbound-method": "error"
987
943
  };
988
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
989
- const [
990
- pluginTs,
991
- parserTs
992
- ] = await Promise.all([
944
+ const tsconfigPath = (options == null ? void 0 : options.tsconfigPath) ? toArray(options.tsconfigPath) : void 0;
945
+ const [pluginTs, parserTs] = await Promise.all([
993
946
  interopDefault(import("@typescript-eslint/eslint-plugin")),
994
947
  interopDefault(import("@typescript-eslint/parser"))
995
948
  ]);
@@ -1028,17 +981,21 @@ async function typescript(options = {}) {
1028
981
  "@typescript-eslint/",
1029
982
  "ts/"
1030
983
  ),
1031
- "antfu/generic-spacing": "error",
1032
- "antfu/named-tuple-spacing": "error",
1033
984
  "no-dupe-class-members": "off",
1034
985
  "no-loss-of-precision": "off",
1035
986
  "no-redeclare": "off",
1036
987
  "no-use-before-define": "off",
1037
988
  "no-useless-constructor": "off",
1038
- "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
989
+ "ts/ban-ts-comment": [
990
+ "error",
991
+ { "ts-ignore": "allow-with-description" }
992
+ ],
1039
993
  "ts/ban-types": ["error", { types: { Function: false } }],
1040
994
  "ts/consistent-type-definitions": ["error", "interface"],
1041
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
995
+ "ts/consistent-type-imports": [
996
+ "error",
997
+ { disallowTypeAnnotations: false, prefer: "type-imports" }
998
+ ],
1042
999
  "ts/no-dupe-class-members": "error",
1043
1000
  "ts/no-dynamic-delete": "off",
1044
1001
  "ts/no-explicit-any": "off",
@@ -1050,11 +1007,21 @@ async function typescript(options = {}) {
1050
1007
  "ts/no-redeclare": "error",
1051
1008
  "ts/no-require-imports": "error",
1052
1009
  "ts/no-unused-vars": "off",
1053
- "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1010
+ "ts/no-use-before-define": [
1011
+ "error",
1012
+ { classes: false, functions: false, variables: true }
1013
+ ],
1054
1014
  "ts/no-useless-constructor": "off",
1055
1015
  "ts/prefer-ts-expect-error": "error",
1056
1016
  "ts/triple-slash-reference": "off",
1057
1017
  "ts/unified-signatures": "off",
1018
+ ...overrides
1019
+ }
1020
+ },
1021
+ {
1022
+ files: filesTypeAware,
1023
+ name: "coderwyd:typescript:rules-type-aware",
1024
+ rules: {
1058
1025
  ...tsconfigPath ? typeAwareRules : {},
1059
1026
  ...overrides
1060
1027
  }
@@ -1130,35 +1097,20 @@ async function unicorn() {
1130
1097
 
1131
1098
  // src/configs/vue.ts
1132
1099
  async function vue(options = {}) {
1133
- const {
1134
- files = [GLOB_VUE],
1135
- overrides = {},
1136
- stylistic: stylistic2 = true
1137
- } = options;
1138
- const {
1139
- indent = 2
1140
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1100
+ const { files = [GLOB_VUE], overrides = {} } = options;
1141
1101
  const isVue3 = getVueVersion() === 3;
1142
- const [
1143
- pluginVue,
1144
- parserVue
1145
- ] = await Promise.all([
1146
- // @ts-expect-error missing types
1102
+ const [pluginVue, parserVue] = await Promise.all([
1147
1103
  interopDefault(import("eslint-plugin-vue")),
1148
1104
  interopDefault(import("vue-eslint-parser"))
1149
1105
  ]);
1150
- const vue3Rules = {
1151
- ...pluginVue.configs.base.rules,
1152
- ...pluginVue.configs["vue3-essential"].rules,
1153
- ...pluginVue.configs["vue3-strongly-recommended"].rules,
1154
- ...pluginVue.configs["vue3-recommended"].rules
1155
- };
1156
- const vue2Rules = {
1157
- ...pluginVue.configs.base.rules,
1158
- ...pluginVue.configs.essential.rules,
1159
- ...pluginVue.configs["strongly-recommended"].rules,
1160
- ...pluginVue.configs.recommended.rules
1161
- };
1106
+ const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
1107
+ const vueRules = configKeys.reduce((preRules, key) => {
1108
+ const config = pluginVue.configs[key];
1109
+ return {
1110
+ ...preRules,
1111
+ ...config.rules
1112
+ };
1113
+ }, {});
1162
1114
  return [
1163
1115
  {
1164
1116
  name: "coderwyd:vue:setup",
@@ -1175,28 +1127,42 @@ async function vue(options = {}) {
1175
1127
  jsx: true
1176
1128
  },
1177
1129
  extraFileExtensions: [".vue"],
1178
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1130
+ parser: options.typescript ? await interopDefault(
1131
+ import("@typescript-eslint/parser")
1132
+ ) : null,
1179
1133
  sourceType: "module"
1180
1134
  }
1181
1135
  },
1182
1136
  name: "coderwyd:vue:rules",
1183
1137
  processor: pluginVue.processors[".vue"],
1184
1138
  rules: {
1185
- ...isVue3 ? vue3Rules : vue2Rules,
1139
+ ...pluginVue.configs.base.rules,
1140
+ ...vueRules,
1186
1141
  "node/prefer-global/process": "off",
1187
- "vue/block-order": ["error", {
1188
- order: ["script", "template", "style"]
1189
- }],
1142
+ "vue/block-order": [
1143
+ "error",
1144
+ {
1145
+ order: ["script", "template", "style"]
1146
+ }
1147
+ ],
1190
1148
  "vue/component-name-in-template-casing": ["error", "PascalCase"],
1191
1149
  "vue/component-options-name-casing": ["error", "PascalCase"],
1192
1150
  "vue/custom-event-name-casing": ["error", "camelCase"],
1193
- "vue/define-macros-order": ["error", {
1194
- order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1195
- }],
1151
+ "vue/define-macros-order": [
1152
+ "error",
1153
+ {
1154
+ order: [
1155
+ "defineOptions",
1156
+ "defineProps",
1157
+ "defineEmits",
1158
+ "defineSlots"
1159
+ ]
1160
+ }
1161
+ ],
1196
1162
  "vue/dot-location": ["error", "property"],
1197
1163
  "vue/dot-notation": ["error", { allowKeywords: true }],
1198
1164
  "vue/eqeqeq": ["error", "smart"],
1199
- "vue/html-indent": ["error", indent],
1165
+ "vue/html-indent": ["error", 2],
1200
1166
  "vue/html-quotes": ["error", "double"],
1201
1167
  "vue/max-attributes-per-line": "off",
1202
1168
  "vue/multi-word-component-names": "off",
@@ -1232,91 +1198,7 @@ async function vue(options = {}) {
1232
1198
  "vue/require-prop-types": "off",
1233
1199
  "vue/space-infix-ops": "error",
1234
1200
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1235
- ...stylistic2 ? {
1236
- "vue/array-bracket-spacing": ["error", "never"],
1237
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1238
- "vue/block-spacing": ["error", "always"],
1239
- "vue/block-tag-newline": ["error", {
1240
- multiline: "always",
1241
- singleline: "always"
1242
- }],
1243
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1244
- "vue/comma-dangle": ["error", "always-multiline"],
1245
- "vue/comma-spacing": ["error", { after: true, before: false }],
1246
- "vue/comma-style": ["error", "last"],
1247
- "vue/html-comment-content-spacing": ["error", "always", {
1248
- exceptions: ["-"]
1249
- }],
1250
- "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1251
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1252
- "vue/object-curly-newline": "off",
1253
- "vue/object-curly-spacing": ["error", "always"],
1254
- "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1255
- "vue/operator-linebreak": ["error", "before"],
1256
- "vue/padding-line-between-blocks": ["error", "always"],
1257
- "vue/quote-props": ["error", "consistent-as-needed"],
1258
- "vue/space-in-parens": ["error", "never"],
1259
- "vue/template-curly-spacing": "error"
1260
- } : {},
1261
- ...overrides
1262
- }
1263
- }
1264
- ];
1265
- }
1266
-
1267
- // src/configs/yaml.ts
1268
- async function yaml(options = {}) {
1269
- const {
1270
- files = [GLOB_YAML],
1271
- overrides = {},
1272
- stylistic: stylistic2 = true
1273
- } = options;
1274
- const {
1275
- indent = 2,
1276
- quotes = "single"
1277
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1278
- const [
1279
- pluginYaml,
1280
- parserYaml
1281
- ] = await Promise.all([
1282
- interopDefault(import("eslint-plugin-yml")),
1283
- interopDefault(import("yaml-eslint-parser"))
1284
- ]);
1285
- return [
1286
- {
1287
- name: "coderwyd:yaml:setup",
1288
- plugins: {
1289
- yaml: pluginYaml
1290
- }
1291
- },
1292
- {
1293
- files,
1294
- languageOptions: {
1295
- parser: parserYaml
1296
- },
1297
- name: "coderwyd:yaml:rules",
1298
- rules: {
1299
- "style/spaced-comment": "off",
1300
- "yaml/block-mapping": "error",
1301
- "yaml/block-sequence": "error",
1302
- "yaml/no-empty-key": "error",
1303
- "yaml/no-empty-sequence-entry": "error",
1304
- "yaml/no-irregular-whitespace": "error",
1305
- "yaml/plain-scalar": "error",
1306
- "yaml/vue-custom-block/no-parsing-error": "error",
1307
- ...stylistic2 ? {
1308
- "yaml/block-mapping-question-indicator-newline": "error",
1309
- "yaml/block-sequence-hyphen-indicator-newline": "error",
1310
- "yaml/flow-mapping-curly-newline": "error",
1311
- "yaml/flow-mapping-curly-spacing": "error",
1312
- "yaml/flow-sequence-bracket-newline": "error",
1313
- "yaml/flow-sequence-bracket-spacing": "error",
1314
- "yaml/indent": ["error", indent === "tab" ? 2 : indent],
1315
- "yaml/key-spacing": "error",
1316
- "yaml/no-tab-indent": "error",
1317
- "yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
1318
- "yaml/spaced-comment": "error"
1319
- } : {},
1201
+ "vue/valid-define-options": "warn",
1320
1202
  ...overrides
1321
1203
  }
1322
1204
  }
@@ -1325,15 +1207,8 @@ async function yaml(options = {}) {
1325
1207
 
1326
1208
  // src/configs/test.ts
1327
1209
  async function test(options = {}) {
1328
- const {
1329
- files = GLOB_TESTS,
1330
- isInEditor = false,
1331
- overrides = {}
1332
- } = options;
1333
- const [
1334
- pluginVitest,
1335
- pluginNoOnlyTests
1336
- ] = await Promise.all([
1210
+ const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
1211
+ const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
1337
1212
  interopDefault(import("eslint-plugin-vitest")),
1338
1213
  // @ts-expect-error missing types
1339
1214
  interopDefault(import("eslint-plugin-no-only-tests"))
@@ -1357,8 +1232,12 @@ async function test(options = {}) {
1357
1232
  name: "coderwyd:test:rules",
1358
1233
  rules: {
1359
1234
  "node/prefer-global/process": "off",
1360
- "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1235
+ "test/consistent-test-it": [
1236
+ "error",
1237
+ { fn: "it", withinDescribe: "it" }
1238
+ ],
1361
1239
  "test/no-identical-title": "error",
1240
+ "test/no-import-node-test": "error",
1362
1241
  "test/no-only-tests": isInEditor ? "off" : "error",
1363
1242
  "test/prefer-hooks-in-order": "error",
1364
1243
  "test/prefer-lowercase-title": "error",
@@ -1382,9 +1261,7 @@ async function perfectionist() {
1382
1261
 
1383
1262
  // src/configs/react.ts
1384
1263
  var import_local_pkg2 = require("local-pkg");
1385
- var ReactRefreshAllowConstantExportPackages = [
1386
- "vite"
1387
- ];
1264
+ var ReactRefreshAllowConstantExportPackages = ["vite"];
1388
1265
  async function react(options = {}) {
1389
1266
  const {
1390
1267
  files = [GLOB_JSX, GLOB_TSX],
@@ -1396,15 +1273,13 @@ async function react(options = {}) {
1396
1273
  "eslint-plugin-react-hooks",
1397
1274
  "eslint-plugin-react-refresh"
1398
1275
  ]);
1399
- const [
1400
- pluginReact,
1401
- pluginReactHooks,
1402
- pluginReactRefresh
1403
- ] = await Promise.all([
1404
- interopDefault(import("eslint-plugin-react")),
1405
- interopDefault(import("eslint-plugin-react-hooks")),
1406
- interopDefault(import("eslint-plugin-react-refresh"))
1407
- ]);
1276
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
1277
+ [
1278
+ interopDefault(import("eslint-plugin-react")),
1279
+ interopDefault(import("eslint-plugin-react-hooks")),
1280
+ interopDefault(import("eslint-plugin-react-refresh"))
1281
+ ]
1282
+ );
1408
1283
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1409
1284
  (i) => (0, import_local_pkg2.isPackageExists)(i)
1410
1285
  );
@@ -1412,9 +1287,14 @@ async function react(options = {}) {
1412
1287
  {
1413
1288
  name: "coderwyd:react:setup",
1414
1289
  plugins: {
1415
- "react": pluginReact,
1290
+ react: pluginReact,
1416
1291
  "react-hooks": pluginReactHooks,
1417
1292
  "react-refresh": pluginReactRefresh
1293
+ },
1294
+ settings: {
1295
+ react: {
1296
+ version: "detect"
1297
+ }
1418
1298
  }
1419
1299
  },
1420
1300
  {
@@ -1472,16 +1352,9 @@ async function react(options = {}) {
1472
1352
 
1473
1353
  // src/configs/unocss.ts
1474
1354
  async function unocss(options = {}) {
1475
- const {
1476
- attributify = true,
1477
- strict = false
1478
- } = options;
1479
- await ensurePackages([
1480
- "@unocss/eslint-plugin"
1481
- ]);
1482
- const [
1483
- pluginUnoCSS
1484
- ] = await Promise.all([
1355
+ const { attributify = true, strict = false } = options;
1356
+ await ensurePackages(["@unocss/eslint-plugin"]);
1357
+ const [pluginUnoCSS] = await Promise.all([
1485
1358
  interopDefault(import("@unocss/eslint-plugin"))
1486
1359
  ]);
1487
1360
  return [
@@ -1503,7 +1376,82 @@ async function unocss(options = {}) {
1503
1376
  ];
1504
1377
  }
1505
1378
 
1506
- // src/factory.ts
1379
+ // src/configs/formatter.ts
1380
+ async function formatter(options = {}, prettierRules2 = {}) {
1381
+ await ensurePackages(["eslint-plugin-prettier"]);
1382
+ const {
1383
+ css = true,
1384
+ graphql,
1385
+ html = true,
1386
+ markdown,
1387
+ toml,
1388
+ yaml
1389
+ } = options || {};
1390
+ const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
1391
+ function createPrettierFormatter(files, parser, plugins) {
1392
+ const rules = {
1393
+ ...prettierRules2,
1394
+ parser
1395
+ };
1396
+ if (plugins == null ? void 0 : plugins.length) {
1397
+ rules.plugins = [...rules.plugins || [], ...plugins];
1398
+ }
1399
+ const config = {
1400
+ files,
1401
+ languageOptions: {
1402
+ parser: parserPlain
1403
+ },
1404
+ name: `coderwyd:formatter:${parser}`,
1405
+ plugins: {
1406
+ prettier: pluginPrettier
1407
+ },
1408
+ rules: {
1409
+ "prettier/prettier": ["warn", rules]
1410
+ }
1411
+ };
1412
+ return config;
1413
+ }
1414
+ const configs = [
1415
+ {
1416
+ name: "coderwyd:formatter:setup",
1417
+ plugins: {
1418
+ prettier: pluginPrettier
1419
+ }
1420
+ }
1421
+ ];
1422
+ if (css) {
1423
+ const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
1424
+ const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
1425
+ const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
1426
+ configs.push(cssConfig, scssConfig, lessConfig);
1427
+ }
1428
+ if (html) {
1429
+ const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1430
+ configs.push(htmlConfig);
1431
+ }
1432
+ if (markdown) {
1433
+ const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
1434
+ configs.push(markdownConfig);
1435
+ }
1436
+ if (graphql) {
1437
+ const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
1438
+ configs.push(graphqlConfig);
1439
+ }
1440
+ if (yaml) {
1441
+ const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
1442
+ configs.push(yamlConfig);
1443
+ }
1444
+ if (toml) {
1445
+ await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1446
+ const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1447
+ "prettier-plugin-toml"
1448
+ ]);
1449
+ configs.push(tomlConfig);
1450
+ }
1451
+ return configs;
1452
+ }
1453
+
1454
+ // src/index.ts
1507
1455
  var flatConfigProps = [
1508
1456
  "files",
1509
1457
  "ignores",
@@ -1514,49 +1462,45 @@ var flatConfigProps = [
1514
1462
  "rules",
1515
1463
  "settings"
1516
1464
  ];
1517
- var VuePackages = [
1518
- "vue",
1519
- "nuxt",
1520
- "vitepress",
1521
- "@slidev/cli"
1522
- ];
1523
- async function coderwyd(options = {}, ...userConfigs) {
1465
+ var VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
1466
+ async function defineConfig(options = {}, ...userConfigs) {
1524
1467
  const {
1525
1468
  componentExts = [],
1526
1469
  gitignore: enableGitignore = true,
1527
- isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
1528
- overrides = {},
1470
+ isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
1529
1471
  react: enableReact = false,
1530
1472
  typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
1531
1473
  unocss: enableUnoCSS = false,
1474
+ usePrettierrc = true,
1532
1475
  vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
1533
1476
  } = options;
1534
- const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1535
- if (stylisticOptions && !("jsx" in stylisticOptions))
1536
- stylisticOptions.jsx = options.jsx ?? true;
1537
1477
  const configs = [];
1538
1478
  if (enableGitignore) {
1539
1479
  if (typeof enableGitignore !== "boolean") {
1540
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1480
+ configs.push(
1481
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1482
+ r(enableGitignore)
1483
+ ])
1484
+ );
1541
1485
  } else {
1542
1486
  if (import_node_fs.default.existsSync(".gitignore"))
1543
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1487
+ configs.push(
1488
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1489
+ r()
1490
+ ])
1491
+ );
1544
1492
  }
1545
1493
  }
1546
1494
  configs.push(
1547
1495
  ignores(),
1548
1496
  javascript({
1549
1497
  isInEditor,
1550
- overrides: overrides.javascript
1498
+ overrides: getOverrides(options, "javascript")
1551
1499
  }),
1552
1500
  comments(),
1553
1501
  node(),
1554
- jsdoc({
1555
- stylistic: stylisticOptions
1556
- }),
1557
- imports({
1558
- stylistic: stylisticOptions
1559
- }),
1502
+ jsdoc(),
1503
+ imports(),
1560
1504
  unicorn(),
1561
1505
  // Optional plugins (installed but not enabled by default)
1562
1506
  perfectionist()
@@ -1564,60 +1508,70 @@ async function coderwyd(options = {}, ...userConfigs) {
1564
1508
  if (enableVue)
1565
1509
  componentExts.push("vue");
1566
1510
  if (enableTypeScript) {
1567
- configs.push(typescript({
1568
- ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1569
- componentExts,
1570
- overrides: overrides.typescript
1571
- }));
1511
+ configs.push(
1512
+ typescript({
1513
+ ...resolveSubOptions(options, "typescript"),
1514
+ componentExts
1515
+ })
1516
+ );
1572
1517
  }
1573
- if (stylisticOptions)
1574
- configs.push(stylistic(stylisticOptions));
1575
1518
  if (options.test ?? true) {
1576
- configs.push(test({
1577
- isInEditor,
1578
- overrides: overrides.test
1579
- }));
1519
+ configs.push(
1520
+ test({
1521
+ isInEditor,
1522
+ overrides: getOverrides(options, "test")
1523
+ })
1524
+ );
1580
1525
  }
1581
1526
  if (enableVue) {
1582
- configs.push(vue({
1583
- overrides: overrides.vue,
1584
- stylistic: stylisticOptions,
1585
- typescript: !!enableTypeScript
1586
- }));
1527
+ configs.push(
1528
+ vue({
1529
+ ...resolveSubOptions(options, "vue"),
1530
+ typescript: !!enableTypeScript
1531
+ })
1532
+ );
1587
1533
  }
1588
1534
  if (enableReact) {
1589
- configs.push(react({
1590
- overrides: overrides.react,
1591
- typescript: !!enableTypeScript
1592
- }));
1535
+ configs.push(
1536
+ react({
1537
+ overrides: getOverrides(options, "react"),
1538
+ typescript: !!enableTypeScript
1539
+ })
1540
+ );
1593
1541
  }
1594
1542
  if (enableUnoCSS) {
1595
- configs.push(unocss(
1596
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1597
- ));
1543
+ configs.push(
1544
+ unocss({
1545
+ ...resolveSubOptions(options, "unocss"),
1546
+ overrides: getOverrides(options, "unocss")
1547
+ })
1548
+ );
1598
1549
  }
1599
1550
  if (options.jsonc ?? true) {
1600
1551
  configs.push(
1601
1552
  jsonc({
1602
- overrides: overrides.jsonc,
1603
- stylistic: stylisticOptions
1553
+ overrides: getOverrides(options, "jsonc")
1604
1554
  }),
1605
1555
  sortPackageJson(),
1606
1556
  sortTsconfig()
1607
1557
  );
1608
1558
  }
1609
- if (options.yaml ?? true) {
1610
- configs.push(yaml({
1611
- overrides: overrides.yaml,
1612
- stylistic: stylisticOptions
1613
- }));
1559
+ let prettierRules2 = {
1560
+ ...DEFAULT_PRETTIER_RULES
1561
+ };
1562
+ if (options.prettierRules) {
1563
+ prettierRules2 = { ...prettierRules2, ...options.prettierRules };
1614
1564
  }
1615
- if (options.markdown ?? true) {
1616
- configs.push(markdown({
1617
- componentExts,
1618
- overrides: overrides.markdown
1619
- }));
1565
+ if (usePrettierrc) {
1566
+ const prettierConfig = await loadPrettierConfig(
1567
+ options.cwd ?? import_node_process3.default.cwd()
1568
+ );
1569
+ Object.assign(prettierRules2, prettierConfig);
1620
1570
  }
1571
+ configs.push(
1572
+ prettier(prettierRules2),
1573
+ formatter(options.formatter, prettierRules2)
1574
+ );
1621
1575
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1622
1576
  if (key in options)
1623
1577
  acc[key] = options[key];
@@ -1625,62 +1579,10 @@ async function coderwyd(options = {}, ...userConfigs) {
1625
1579
  }, {});
1626
1580
  if (Object.keys(fusedConfig).length)
1627
1581
  configs.push([fusedConfig]);
1628
- const merged = combine(
1629
- ...configs,
1630
- ...userConfigs
1631
- );
1582
+ const merged = combine(...configs, ...userConfigs);
1632
1583
  return merged;
1633
1584
  }
1634
-
1635
- // src/index.ts
1636
- var src_default = coderwyd;
1637
1585
  // Annotate the CommonJS export names for ESM import in node:
1638
1586
  0 && (module.exports = {
1639
- GLOB_ALL_SRC,
1640
- GLOB_CSS,
1641
- GLOB_EXCLUDE,
1642
- GLOB_HTML,
1643
- GLOB_JS,
1644
- GLOB_JSON,
1645
- GLOB_JSON5,
1646
- GLOB_JSONC,
1647
- GLOB_JSX,
1648
- GLOB_LESS,
1649
- GLOB_MARKDOWN,
1650
- GLOB_MARKDOWN_CODE,
1651
- GLOB_SCSS,
1652
- GLOB_SRC,
1653
- GLOB_SRC_EXT,
1654
- GLOB_STYLE,
1655
- GLOB_TESTS,
1656
- GLOB_TS,
1657
- GLOB_TSX,
1658
- GLOB_VUE,
1659
- GLOB_YAML,
1660
- coderwyd,
1661
- combine,
1662
- comments,
1663
- ensurePackages,
1664
- getVueVersion,
1665
- ignores,
1666
- imports,
1667
- interopDefault,
1668
- javascript,
1669
- jsdoc,
1670
- jsonc,
1671
- markdown,
1672
- node,
1673
- perfectionist,
1674
- react,
1675
- renameRules,
1676
- sortPackageJson,
1677
- sortTsconfig,
1678
- stylistic,
1679
- test,
1680
- toArray,
1681
- typescript,
1682
- unicorn,
1683
- unocss,
1684
- vue,
1685
- yaml
1587
+ defineConfig
1686
1588
  });