@coderwyd/eslint-config 1.1.0 → 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.js CHANGED
@@ -1,9 +1,18 @@
1
- // src/factory.ts
1
+ // src/index.ts
2
2
  import process3 from "process";
3
3
  import fs from "fs";
4
4
  import { isPackageExists as isPackageExists3 } from "local-pkg";
5
5
 
6
- // src/plugins.ts
6
+ // src/constants/prettier.ts
7
+ var DEFAULT_PRETTIER_RULES = {
8
+ arrowParens: "avoid",
9
+ htmlWhitespaceSensitivity: "ignore",
10
+ printWidth: 80,
11
+ semi: false,
12
+ singleQuote: true
13
+ };
14
+
15
+ // src/plugins/index.ts
7
16
  import { default as default2 } from "eslint-plugin-antfu";
8
17
  import { default as default3 } from "eslint-plugin-eslint-comments";
9
18
  import * as pluginImport from "eslint-plugin-i";
@@ -30,24 +39,26 @@ async function comments() {
30
39
  ];
31
40
  }
32
41
 
33
- // src/globs.ts
42
+ // src/constants/glob.ts
34
43
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
35
44
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
36
- var GLOB_JS = "**/*.?([cm])js";
37
45
  var GLOB_JSX = "**/*.?([cm])jsx";
38
46
  var GLOB_TS = "**/*.?([cm])ts";
39
47
  var GLOB_TSX = "**/*.?([cm])tsx";
40
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
48
+ var GLOB_VUE = "**/*.vue";
49
+ var GLOB_HTML = "**/*.htm?(l)";
41
50
  var GLOB_CSS = "**/*.css";
51
+ var GLOB_POSTCSS = "**/*.{p,post}css";
42
52
  var GLOB_LESS = "**/*.less";
43
53
  var GLOB_SCSS = "**/*.scss";
44
54
  var GLOB_JSON = "**/*.json";
45
55
  var GLOB_JSON5 = "**/*.json5";
46
56
  var GLOB_JSONC = "**/*.jsonc";
47
57
  var GLOB_MARKDOWN = "**/*.md";
48
- var GLOB_VUE = "**/*.vue";
49
58
  var GLOB_YAML = "**/*.y?(a)ml";
50
- var GLOB_HTML = "**/*.htm?(l)";
59
+ var GLOB_TOML = "**/*.toml";
60
+ var GLOB_GRAPHQL = "**/*.graphql";
61
+ var GLOB_PRETTIER_LINT = [GLOB_SRC, GLOB_VUE];
51
62
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
52
63
  var GLOB_TESTS = [
53
64
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -56,16 +67,6 @@ var GLOB_TESTS = [
56
67
  `**/*.bench.${GLOB_SRC_EXT}`,
57
68
  `**/*.benchmark.${GLOB_SRC_EXT}`
58
69
  ];
59
- var GLOB_ALL_SRC = [
60
- GLOB_SRC,
61
- GLOB_STYLE,
62
- GLOB_JSON,
63
- GLOB_JSON5,
64
- GLOB_MARKDOWN,
65
- GLOB_VUE,
66
- GLOB_YAML,
67
- GLOB_HTML
68
- ];
69
70
  var GLOB_EXCLUDE = [
70
71
  "**/node_modules",
71
72
  "**/dist",
@@ -107,10 +108,7 @@ async function ignores() {
107
108
  }
108
109
 
109
110
  // src/configs/imports.ts
110
- async function imports(options = {}) {
111
- const {
112
- stylistic: stylistic2 = true
113
- } = options;
111
+ async function imports() {
114
112
  return [
115
113
  {
116
114
  name: "coderwyd:imports",
@@ -120,17 +118,61 @@ async function imports(options = {}) {
120
118
  },
121
119
  rules: {
122
120
  "antfu/import-dedupe": "error",
121
+ "antfu/no-import-dist": "error",
123
122
  "antfu/no-import-node-modules-by-path": "error",
124
123
  "import/first": "error",
124
+ "import/newline-after-import": [
125
+ "error",
126
+ { considerComments: true, count: 1 }
127
+ ],
128
+ "import/no-default-export": "error",
125
129
  "import/no-duplicates": "error",
126
130
  "import/no-mutable-exports": "error",
127
131
  "import/no-named-default": "error",
128
132
  "import/no-self-import": "error",
129
133
  "import/no-webpack-loader-syntax": "error",
130
- "import/order": "error",
131
- ...stylistic2 ? {
132
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
133
- } : {}
134
+ "import/order": [
135
+ "error",
136
+ {
137
+ groups: [
138
+ "builtin",
139
+ "external",
140
+ "internal",
141
+ "parent",
142
+ "sibling",
143
+ "index",
144
+ "object",
145
+ "type"
146
+ ],
147
+ pathGroups: [{ group: "internal", pattern: "{{@,~}/,#}**" }],
148
+ pathGroupsExcludedImportTypes: ["type"]
149
+ }
150
+ ]
151
+ }
152
+ },
153
+ {
154
+ files: [
155
+ `**/*config*.${GLOB_SRC_EXT}`,
156
+ `**/views/${GLOB_SRC}`,
157
+ `**/pages/${GLOB_SRC}`,
158
+ `**/{index,vite,esbuild,rollup,webpack,rspack}.ts`,
159
+ "**/*.d.ts",
160
+ `${GLOB_MARKDOWN}/**`,
161
+ "**/.prettierrc*"
162
+ ],
163
+ plugins: {
164
+ import: pluginImport
165
+ },
166
+ rules: {
167
+ "import/no-default-export": "off"
168
+ }
169
+ },
170
+ {
171
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
172
+ name: "antfu:imports:bin",
173
+ rules: {
174
+ "antfu/no-import-dist": "off",
175
+ "antfu/no-import-node-modules-by-path": "off"
134
176
  }
135
177
  }
136
178
  ];
@@ -139,10 +181,7 @@ async function imports(options = {}) {
139
181
  // src/configs/javascript.ts
140
182
  import globals from "globals";
141
183
  async function javascript(options = {}) {
142
- const {
143
- isInEditor = false,
144
- overrides = {}
145
- } = options;
184
+ const { isInEditor = false, overrides = {} } = options;
146
185
  return [
147
186
  {
148
187
  languageOptions: {
@@ -169,18 +208,23 @@ async function javascript(options = {}) {
169
208
  },
170
209
  name: "coderwyd:javascript",
171
210
  plugins: {
172
- "antfu": default2,
173
211
  "unused-imports": default6
174
212
  },
175
213
  rules: {
176
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
214
+ "accessor-pairs": [
215
+ "error",
216
+ { enforceForClassMembers: true, setWithoutGet: true }
217
+ ],
177
218
  "array-callback-return": "error",
178
219
  "block-scoped-var": "error",
179
220
  "constructor-super": "error",
180
221
  "default-case-last": "error",
181
222
  "dot-notation": ["error", { allowKeywords: true }],
182
- "eqeqeq": ["error", "smart"],
183
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
223
+ eqeqeq: ["error", "smart"],
224
+ "new-cap": [
225
+ "error",
226
+ { capIsNew: false, newIsCap: true, properties: true }
227
+ ],
184
228
  "no-alert": "error",
185
229
  "no-array-constructor": "error",
186
230
  "no-async-promise-executor": "error",
@@ -238,11 +282,26 @@ async function javascript(options = {}) {
238
282
  ],
239
283
  "no-restricted-properties": [
240
284
  "error",
241
- { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
242
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
243
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
244
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
245
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
285
+ {
286
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
287
+ property: "__proto__"
288
+ },
289
+ {
290
+ message: "Use `Object.defineProperty` instead.",
291
+ property: "__defineGetter__"
292
+ },
293
+ {
294
+ message: "Use `Object.defineProperty` instead.",
295
+ property: "__defineSetter__"
296
+ },
297
+ {
298
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
299
+ property: "__lookupGetter__"
300
+ },
301
+ {
302
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
303
+ property: "__lookupSetter__"
304
+ }
246
305
  ],
247
306
  "no-restricted-syntax": [
248
307
  "error",
@@ -269,18 +328,27 @@ async function javascript(options = {}) {
269
328
  "no-unreachable-loop": "error",
270
329
  "no-unsafe-finally": "error",
271
330
  "no-unsafe-negation": "error",
272
- "no-unused-expressions": ["error", {
273
- allowShortCircuit: true,
274
- allowTaggedTemplates: true,
275
- allowTernary: true
276
- }],
277
- "no-unused-vars": ["error", {
278
- args: "none",
279
- caughtErrors: "none",
280
- ignoreRestSiblings: true,
281
- vars: "all"
282
- }],
283
- "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
331
+ "no-unused-expressions": [
332
+ "error",
333
+ {
334
+ allowShortCircuit: true,
335
+ allowTaggedTemplates: true,
336
+ allowTernary: true
337
+ }
338
+ ],
339
+ "no-unused-vars": [
340
+ "error",
341
+ {
342
+ args: "none",
343
+ caughtErrors: "none",
344
+ ignoreRestSiblings: true,
345
+ vars: "all"
346
+ }
347
+ ],
348
+ "no-use-before-define": [
349
+ "error",
350
+ { classes: false, functions: false, variables: true }
351
+ ],
284
352
  "no-useless-backreference": "error",
285
353
  "no-useless-call": "error",
286
354
  "no-useless-catch": "error",
@@ -334,12 +402,20 @@ async function javascript(options = {}) {
334
402
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
335
403
  "unused-imports/no-unused-vars": [
336
404
  "error",
337
- { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
405
+ {
406
+ args: "after-used",
407
+ argsIgnorePattern: "^_",
408
+ vars: "all",
409
+ varsIgnorePattern: "^_"
410
+ }
411
+ ],
412
+ "use-isnan": [
413
+ "error",
414
+ { enforceForIndexOf: true, enforceForSwitchCase: true }
338
415
  ],
339
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
340
416
  "valid-typeof": ["error", { requireStringLiterals: true }],
341
417
  "vars-on-top": "error",
342
- "yoda": ["error", "never"],
418
+ yoda: ["error", "never"],
343
419
  ...overrides
344
420
  }
345
421
  },
@@ -353,9 +429,31 @@ async function javascript(options = {}) {
353
429
  ];
354
430
  }
355
431
 
356
- // src/utils.ts
432
+ // src/shared/index.ts
357
433
  import process from "process";
434
+ import { readFile } from "fs/promises";
435
+ import path from "path";
358
436
  import { getPackageInfoSync, isPackageExists } from "local-pkg";
437
+ var parserPlain = {
438
+ meta: {
439
+ name: "parser-plain"
440
+ },
441
+ parseForESLint: (code) => ({
442
+ ast: {
443
+ body: [],
444
+ comments: [],
445
+ loc: { end: code.length, start: 0 },
446
+ range: [0, code.length],
447
+ tokens: [],
448
+ type: "Program"
449
+ },
450
+ scopeManager: null,
451
+ services: { isPlain: true },
452
+ visitorKeys: {
453
+ Program: []
454
+ }
455
+ })
456
+ };
359
457
  async function combine(...configs) {
360
458
  const resolved = await Promise.all(configs);
361
459
  return resolved.flat();
@@ -391,20 +489,41 @@ async function ensurePackages(packages) {
391
489
  const { default: prompts } = await import("prompts");
392
490
  const { result } = await prompts([
393
491
  {
394
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
492
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(
493
+ ", "
494
+ )}. Do you want to install them?`,
395
495
  name: "result",
396
496
  type: "confirm"
397
497
  }
398
498
  ]);
399
499
  if (result)
400
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
500
+ await import("@antfu/install-pkg").then(
501
+ (i) => i.installPackage(nonExistingPackages, { dev: true })
502
+ );
503
+ }
504
+ async function loadPrettierConfig(cwd) {
505
+ let prettierConfig = {};
506
+ try {
507
+ const prettierrc = await readFile(path.join(cwd, ".prettierrc"), "utf-8");
508
+ prettierConfig = JSON.parse(prettierrc);
509
+ } catch {
510
+ }
511
+ return prettierConfig;
512
+ }
513
+ function resolveSubOptions(options, key) {
514
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
515
+ }
516
+ function getOverrides(options, key) {
517
+ var _a;
518
+ const sub = resolveSubOptions(options, key);
519
+ return {
520
+ ...(_a = options.overrides) == null ? void 0 : _a[key],
521
+ ..."overrides" in sub ? sub.overrides : {}
522
+ };
401
523
  }
402
524
 
403
525
  // src/configs/jsdoc.ts
404
- async function jsdoc(options = {}) {
405
- const {
406
- stylistic: stylistic2 = true
407
- } = options;
526
+ async function jsdoc() {
408
527
  return [
409
528
  {
410
529
  name: "coderwyd:jsdoc",
@@ -427,11 +546,12 @@ async function jsdoc(options = {}) {
427
546
  "jsdoc/require-property-name": "warn",
428
547
  "jsdoc/require-returns-check": "warn",
429
548
  "jsdoc/require-returns-description": "warn",
430
- "jsdoc/require-yields-check": "warn",
431
- ...stylistic2 ? {
432
- "jsdoc/check-alignment": "warn",
433
- "jsdoc/multiline-blocks": "warn"
434
- } : {}
549
+ "jsdoc/require-yields-check": "warn"
550
+ // style
551
+ // ...{
552
+ // 'jsdoc/check-alignment': 'warn',
553
+ // 'jsdoc/multiline-blocks': 'warn',
554
+ // }
435
555
  }
436
556
  }
437
557
  ];
@@ -439,18 +559,8 @@ async function jsdoc(options = {}) {
439
559
 
440
560
  // src/configs/jsonc.ts
441
561
  async function jsonc(options = {}) {
442
- const {
443
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
444
- overrides = {},
445
- stylistic: stylistic2 = true
446
- } = options;
447
- const {
448
- indent = 2
449
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
450
- const [
451
- pluginJsonc,
452
- parserJsonc
453
- ] = await Promise.all([
562
+ const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides = {} } = options || {};
563
+ const [pluginJsonc, parserJsonc] = await Promise.all([
454
564
  interopDefault(import("eslint-plugin-jsonc")),
455
565
  interopDefault(import("jsonc-eslint-parser"))
456
566
  ]);
@@ -494,101 +604,19 @@ async function jsonc(options = {}) {
494
604
  "jsonc/space-unary-ops": "error",
495
605
  "jsonc/valid-json-number": "error",
496
606
  "jsonc/vue-custom-block/no-parsing-error": "error",
497
- ...stylistic2 ? {
498
- "jsonc/array-bracket-spacing": ["error", "never"],
499
- "jsonc/comma-dangle": ["error", "never"],
500
- "jsonc/comma-style": ["error", "last"],
501
- "jsonc/indent": ["error", indent],
502
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
503
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
504
- "jsonc/object-curly-spacing": ["error", "always"],
505
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
506
- "jsonc/quote-props": "error",
507
- "jsonc/quotes": "error"
508
- } : {},
509
- ...overrides
510
- }
511
- }
512
- ];
513
- }
514
-
515
- // src/configs/markdown.ts
516
- async function markdown(options = {}) {
517
- const {
518
- componentExts = [],
519
- files = [GLOB_MARKDOWN],
520
- overrides = {}
521
- } = options;
522
- return [
523
- {
524
- name: "coderwyd:markdown:setup",
525
- plugins: {
526
- // @ts-expect-error missing types
527
- markdown: await interopDefault(import("eslint-plugin-markdown"))
528
- }
529
- },
530
- {
531
- files,
532
- name: "coderwyd:markdown:processor",
533
- processor: "markdown/markdown"
534
- },
535
- {
536
- files: [
537
- GLOB_MARKDOWN_CODE,
538
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
539
- ],
540
- languageOptions: {
541
- parserOptions: {
542
- ecmaFeatures: {
543
- impliedStrict: true
544
- }
545
- }
546
- },
547
- name: "coderwyd:markdown:rules",
548
- rules: {
549
- "antfu/no-ts-export-equal": "off",
550
- "import/newline-after-import": "off",
551
- "no-alert": "off",
552
- "no-console": "off",
553
- "no-labels": "off",
554
- "no-lone-blocks": "off",
555
- "no-restricted-syntax": "off",
556
- "no-undef": "off",
557
- "no-unused-expressions": "off",
558
- "no-unused-labels": "off",
559
- "no-unused-vars": "off",
560
- "node/prefer-global/process": "off",
561
- "style/comma-dangle": "off",
562
- "style/eol-last": "off",
563
- "ts/consistent-type-imports": "off",
564
- "ts/no-namespace": "off",
565
- "ts/no-redeclare": "off",
566
- "ts/no-require-imports": "off",
567
- "ts/no-unused-vars": "off",
568
- "ts/no-use-before-define": "off",
569
- "ts/no-var-requires": "off",
570
- "unicode-bom": "off",
571
- "unused-imports/no-unused-imports": "off",
572
- "unused-imports/no-unused-vars": "off",
573
- // Type aware rules
574
- ...{
575
- "ts/await-thenable": "off",
576
- "ts/dot-notation": "off",
577
- "ts/no-floating-promises": "off",
578
- "ts/no-for-in-array": "off",
579
- "ts/no-implied-eval": "off",
580
- "ts/no-misused-promises": "off",
581
- "ts/no-throw-literal": "off",
582
- "ts/no-unnecessary-type-assertion": "off",
583
- "ts/no-unsafe-argument": "off",
584
- "ts/no-unsafe-assignment": "off",
585
- "ts/no-unsafe-call": "off",
586
- "ts/no-unsafe-member-access": "off",
587
- "ts/no-unsafe-return": "off",
588
- "ts/restrict-plus-operands": "off",
589
- "ts/restrict-template-expressions": "off",
590
- "ts/unbound-method": "off"
591
- },
607
+ // style
608
+ // ...{
609
+ // 'jsonc/array-bracket-spacing': ['error', 'never'],
610
+ // 'jsonc/comma-dangle': ['error', 'never'],
611
+ // 'jsonc/comma-style': ['error', 'last'],
612
+ // 'jsonc/indent': ['error', indent],
613
+ // 'jsonc/key-spacing': ['error', { afterColon: true, beforeColon: false }],
614
+ // 'jsonc/object-curly-newline': ['error', { consistent: true, multiline: true }],
615
+ // 'jsonc/object-curly-spacing': ['error', 'always'],
616
+ // 'jsonc/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
617
+ // 'jsonc/quote-props': 'error',
618
+ // 'jsonc/quotes': 'error',
619
+ // },
592
620
  ...overrides
593
621
  }
594
622
  }
@@ -683,23 +711,14 @@ async function sortPackageJson() {
683
711
  },
684
712
  {
685
713
  order: { type: "asc" },
686
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
714
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
687
715
  },
688
716
  {
689
717
  order: { type: "asc" },
690
- pathPattern: "^resolutions$"
718
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
691
719
  },
692
720
  {
693
- order: { type: "asc" },
694
- pathPattern: "^pnpm.overrides$"
695
- },
696
- {
697
- order: [
698
- "types",
699
- "import",
700
- "require",
701
- "default"
702
- ],
721
+ order: ["types", "import", "require", "default"],
703
722
  pathPattern: "^exports.*$"
704
723
  }
705
724
  ]
@@ -833,54 +852,40 @@ function sortTsconfig() {
833
852
  ];
834
853
  }
835
854
 
836
- // src/configs/stylistic.ts
837
- async function stylistic(options = {}) {
838
- const {
839
- indent = 2,
840
- jsx = true,
841
- quotes = "single",
842
- semi = false
843
- } = options;
844
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
845
- const config = pluginStylistic.configs.customize({
846
- flat: true,
847
- indent,
848
- jsx,
849
- pluginName: "style",
850
- quotes,
851
- semi
852
- });
853
- return [
855
+ // src/configs/prettier.ts
856
+ import prettierRules from "eslint-config-prettier";
857
+ var { rules: eslintRules } = prettierRules;
858
+ async function prettier(rules) {
859
+ const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
860
+ const pRules = {
861
+ ...rules
862
+ };
863
+ const configs = [
854
864
  {
855
- name: "coderwyd:stylistic",
865
+ files: GLOB_PRETTIER_LINT,
856
866
  plugins: {
857
- antfu: default2,
858
- style: pluginStylistic
867
+ prettier: pluginPrettier
859
868
  },
860
869
  rules: {
861
- ...config.rules,
862
- "antfu/consistent-list-newline": "error",
863
- "antfu/if-newline": "error",
864
- "antfu/indent-binary-ops": ["error", { indent }],
865
- "antfu/top-level-function": "error",
866
- "curly": ["error", "multi-or-nest", "consistent"]
870
+ ...eslintRules,
871
+ "arrow-body-style": "off",
872
+ "prefer-arrow-callback": "off",
873
+ "prettier/prettier": ["warn", pRules]
867
874
  }
868
875
  }
869
876
  ];
877
+ return configs;
870
878
  }
871
879
 
872
880
  // src/configs/typescript.ts
873
881
  import process2 from "process";
874
882
  async function typescript(options = {}) {
875
- const {
876
- componentExts = [],
877
- overrides = {},
878
- parserOptions = {}
879
- } = options;
883
+ const { componentExts = [], overrides = {}, parserOptions = {} } = options;
880
884
  const files = options.files ?? [
881
885
  GLOB_SRC,
882
886
  ...componentExts.map((ext) => `**/*.${ext}`)
883
887
  ];
888
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
884
889
  const typeAwareRules = {
885
890
  "dot-notation": "off",
886
891
  "no-implied-eval": "off",
@@ -902,11 +907,8 @@ async function typescript(options = {}) {
902
907
  "ts/restrict-template-expressions": "error",
903
908
  "ts/unbound-method": "error"
904
909
  };
905
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
906
- const [
907
- pluginTs,
908
- parserTs
909
- ] = await Promise.all([
910
+ const tsconfigPath = (options == null ? void 0 : options.tsconfigPath) ? toArray(options.tsconfigPath) : void 0;
911
+ const [pluginTs, parserTs] = await Promise.all([
910
912
  interopDefault(import("@typescript-eslint/eslint-plugin")),
911
913
  interopDefault(import("@typescript-eslint/parser"))
912
914
  ]);
@@ -945,17 +947,21 @@ async function typescript(options = {}) {
945
947
  "@typescript-eslint/",
946
948
  "ts/"
947
949
  ),
948
- "antfu/generic-spacing": "error",
949
- "antfu/named-tuple-spacing": "error",
950
950
  "no-dupe-class-members": "off",
951
951
  "no-loss-of-precision": "off",
952
952
  "no-redeclare": "off",
953
953
  "no-use-before-define": "off",
954
954
  "no-useless-constructor": "off",
955
- "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
955
+ "ts/ban-ts-comment": [
956
+ "error",
957
+ { "ts-ignore": "allow-with-description" }
958
+ ],
956
959
  "ts/ban-types": ["error", { types: { Function: false } }],
957
960
  "ts/consistent-type-definitions": ["error", "interface"],
958
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
961
+ "ts/consistent-type-imports": [
962
+ "error",
963
+ { disallowTypeAnnotations: false, prefer: "type-imports" }
964
+ ],
959
965
  "ts/no-dupe-class-members": "error",
960
966
  "ts/no-dynamic-delete": "off",
961
967
  "ts/no-explicit-any": "off",
@@ -967,11 +973,21 @@ async function typescript(options = {}) {
967
973
  "ts/no-redeclare": "error",
968
974
  "ts/no-require-imports": "error",
969
975
  "ts/no-unused-vars": "off",
970
- "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
976
+ "ts/no-use-before-define": [
977
+ "error",
978
+ { classes: false, functions: false, variables: true }
979
+ ],
971
980
  "ts/no-useless-constructor": "off",
972
981
  "ts/prefer-ts-expect-error": "error",
973
982
  "ts/triple-slash-reference": "off",
974
983
  "ts/unified-signatures": "off",
984
+ ...overrides
985
+ }
986
+ },
987
+ {
988
+ files: filesTypeAware,
989
+ name: "coderwyd:typescript:rules-type-aware",
990
+ rules: {
975
991
  ...tsconfigPath ? typeAwareRules : {},
976
992
  ...overrides
977
993
  }
@@ -1013,6 +1029,7 @@ async function unicorn() {
1013
1029
  unicorn: default5
1014
1030
  },
1015
1031
  rules: {
1032
+ "unicorn/better-regex": "error",
1016
1033
  // Pass error message when throwing errors
1017
1034
  "unicorn/error-message": "error",
1018
1035
  // Uppercase regex escapes
@@ -1046,35 +1063,20 @@ async function unicorn() {
1046
1063
 
1047
1064
  // src/configs/vue.ts
1048
1065
  async function vue(options = {}) {
1049
- const {
1050
- files = [GLOB_VUE],
1051
- overrides = {},
1052
- stylistic: stylistic2 = true
1053
- } = options;
1054
- const {
1055
- indent = 2
1056
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1066
+ const { files = [GLOB_VUE], overrides = {} } = options;
1057
1067
  const isVue3 = getVueVersion() === 3;
1058
- const [
1059
- pluginVue,
1060
- parserVue
1061
- ] = await Promise.all([
1062
- // @ts-expect-error missing types
1068
+ const [pluginVue, parserVue] = await Promise.all([
1063
1069
  interopDefault(import("eslint-plugin-vue")),
1064
1070
  interopDefault(import("vue-eslint-parser"))
1065
1071
  ]);
1066
- const vue3Rules = {
1067
- ...pluginVue.configs.base.rules,
1068
- ...pluginVue.configs["vue3-essential"].rules,
1069
- ...pluginVue.configs["vue3-strongly-recommended"].rules,
1070
- ...pluginVue.configs["vue3-recommended"].rules
1071
- };
1072
- const vue2Rules = {
1073
- ...pluginVue.configs.base.rules,
1074
- ...pluginVue.configs.essential.rules,
1075
- ...pluginVue.configs["strongly-recommended"].rules,
1076
- ...pluginVue.configs.recommended.rules
1077
- };
1072
+ const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
1073
+ const vueRules = configKeys.reduce((preRules, key) => {
1074
+ const config = pluginVue.configs[key];
1075
+ return {
1076
+ ...preRules,
1077
+ ...config.rules
1078
+ };
1079
+ }, {});
1078
1080
  return [
1079
1081
  {
1080
1082
  name: "coderwyd:vue:setup",
@@ -1091,28 +1093,42 @@ async function vue(options = {}) {
1091
1093
  jsx: true
1092
1094
  },
1093
1095
  extraFileExtensions: [".vue"],
1094
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1096
+ parser: options.typescript ? await interopDefault(
1097
+ import("@typescript-eslint/parser")
1098
+ ) : null,
1095
1099
  sourceType: "module"
1096
1100
  }
1097
1101
  },
1098
1102
  name: "coderwyd:vue:rules",
1099
1103
  processor: pluginVue.processors[".vue"],
1100
1104
  rules: {
1101
- ...isVue3 ? vue3Rules : vue2Rules,
1105
+ ...pluginVue.configs.base.rules,
1106
+ ...vueRules,
1102
1107
  "node/prefer-global/process": "off",
1103
- "vue/block-order": ["error", {
1104
- order: ["script", "template", "style"]
1105
- }],
1108
+ "vue/block-order": [
1109
+ "error",
1110
+ {
1111
+ order: ["script", "template", "style"]
1112
+ }
1113
+ ],
1106
1114
  "vue/component-name-in-template-casing": ["error", "PascalCase"],
1107
1115
  "vue/component-options-name-casing": ["error", "PascalCase"],
1108
1116
  "vue/custom-event-name-casing": ["error", "camelCase"],
1109
- "vue/define-macros-order": ["error", {
1110
- order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1111
- }],
1117
+ "vue/define-macros-order": [
1118
+ "error",
1119
+ {
1120
+ order: [
1121
+ "defineOptions",
1122
+ "defineProps",
1123
+ "defineEmits",
1124
+ "defineSlots"
1125
+ ]
1126
+ }
1127
+ ],
1112
1128
  "vue/dot-location": ["error", "property"],
1113
1129
  "vue/dot-notation": ["error", { allowKeywords: true }],
1114
1130
  "vue/eqeqeq": ["error", "smart"],
1115
- "vue/html-indent": ["error", indent],
1131
+ "vue/html-indent": ["error", 2],
1116
1132
  "vue/html-quotes": ["error", "double"],
1117
1133
  "vue/max-attributes-per-line": "off",
1118
1134
  "vue/multi-word-component-names": "off",
@@ -1148,91 +1164,7 @@ async function vue(options = {}) {
1148
1164
  "vue/require-prop-types": "off",
1149
1165
  "vue/space-infix-ops": "error",
1150
1166
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1151
- ...stylistic2 ? {
1152
- "vue/array-bracket-spacing": ["error", "never"],
1153
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1154
- "vue/block-spacing": ["error", "always"],
1155
- "vue/block-tag-newline": ["error", {
1156
- multiline: "always",
1157
- singleline: "always"
1158
- }],
1159
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1160
- "vue/comma-dangle": ["error", "always-multiline"],
1161
- "vue/comma-spacing": ["error", { after: true, before: false }],
1162
- "vue/comma-style": ["error", "last"],
1163
- "vue/html-comment-content-spacing": ["error", "always", {
1164
- exceptions: ["-"]
1165
- }],
1166
- "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1167
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1168
- "vue/object-curly-newline": "off",
1169
- "vue/object-curly-spacing": ["error", "always"],
1170
- "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1171
- "vue/operator-linebreak": ["error", "before"],
1172
- "vue/padding-line-between-blocks": ["error", "always"],
1173
- "vue/quote-props": ["error", "consistent-as-needed"],
1174
- "vue/space-in-parens": ["error", "never"],
1175
- "vue/template-curly-spacing": "error"
1176
- } : {},
1177
- ...overrides
1178
- }
1179
- }
1180
- ];
1181
- }
1182
-
1183
- // src/configs/yaml.ts
1184
- async function yaml(options = {}) {
1185
- const {
1186
- files = [GLOB_YAML],
1187
- overrides = {},
1188
- stylistic: stylistic2 = true
1189
- } = options;
1190
- const {
1191
- indent = 2,
1192
- quotes = "single"
1193
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1194
- const [
1195
- pluginYaml,
1196
- parserYaml
1197
- ] = await Promise.all([
1198
- interopDefault(import("eslint-plugin-yml")),
1199
- interopDefault(import("yaml-eslint-parser"))
1200
- ]);
1201
- return [
1202
- {
1203
- name: "coderwyd:yaml:setup",
1204
- plugins: {
1205
- yaml: pluginYaml
1206
- }
1207
- },
1208
- {
1209
- files,
1210
- languageOptions: {
1211
- parser: parserYaml
1212
- },
1213
- name: "coderwyd:yaml:rules",
1214
- rules: {
1215
- "style/spaced-comment": "off",
1216
- "yaml/block-mapping": "error",
1217
- "yaml/block-sequence": "error",
1218
- "yaml/no-empty-key": "error",
1219
- "yaml/no-empty-sequence-entry": "error",
1220
- "yaml/no-irregular-whitespace": "error",
1221
- "yaml/plain-scalar": "error",
1222
- "yaml/vue-custom-block/no-parsing-error": "error",
1223
- ...stylistic2 ? {
1224
- "yaml/block-mapping-question-indicator-newline": "error",
1225
- "yaml/block-sequence-hyphen-indicator-newline": "error",
1226
- "yaml/flow-mapping-curly-newline": "error",
1227
- "yaml/flow-mapping-curly-spacing": "error",
1228
- "yaml/flow-sequence-bracket-newline": "error",
1229
- "yaml/flow-sequence-bracket-spacing": "error",
1230
- "yaml/indent": ["error", indent === "tab" ? 2 : indent],
1231
- "yaml/key-spacing": "error",
1232
- "yaml/no-tab-indent": "error",
1233
- "yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
1234
- "yaml/spaced-comment": "error"
1235
- } : {},
1167
+ "vue/valid-define-options": "warn",
1236
1168
  ...overrides
1237
1169
  }
1238
1170
  }
@@ -1241,15 +1173,8 @@ async function yaml(options = {}) {
1241
1173
 
1242
1174
  // src/configs/test.ts
1243
1175
  async function test(options = {}) {
1244
- const {
1245
- files = GLOB_TESTS,
1246
- isInEditor = false,
1247
- overrides = {}
1248
- } = options;
1249
- const [
1250
- pluginVitest,
1251
- pluginNoOnlyTests
1252
- ] = await Promise.all([
1176
+ const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
1177
+ const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
1253
1178
  interopDefault(import("eslint-plugin-vitest")),
1254
1179
  // @ts-expect-error missing types
1255
1180
  interopDefault(import("eslint-plugin-no-only-tests"))
@@ -1273,8 +1198,12 @@ async function test(options = {}) {
1273
1198
  name: "coderwyd:test:rules",
1274
1199
  rules: {
1275
1200
  "node/prefer-global/process": "off",
1276
- "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1201
+ "test/consistent-test-it": [
1202
+ "error",
1203
+ { fn: "it", withinDescribe: "it" }
1204
+ ],
1277
1205
  "test/no-identical-title": "error",
1206
+ "test/no-import-node-test": "error",
1278
1207
  "test/no-only-tests": isInEditor ? "off" : "error",
1279
1208
  "test/prefer-hooks-in-order": "error",
1280
1209
  "test/prefer-lowercase-title": "error",
@@ -1298,9 +1227,7 @@ async function perfectionist() {
1298
1227
 
1299
1228
  // src/configs/react.ts
1300
1229
  import { isPackageExists as isPackageExists2 } from "local-pkg";
1301
- var ReactRefreshAllowConstantExportPackages = [
1302
- "vite"
1303
- ];
1230
+ var ReactRefreshAllowConstantExportPackages = ["vite"];
1304
1231
  async function react(options = {}) {
1305
1232
  const {
1306
1233
  files = [GLOB_JSX, GLOB_TSX],
@@ -1312,15 +1239,13 @@ async function react(options = {}) {
1312
1239
  "eslint-plugin-react-hooks",
1313
1240
  "eslint-plugin-react-refresh"
1314
1241
  ]);
1315
- const [
1316
- pluginReact,
1317
- pluginReactHooks,
1318
- pluginReactRefresh
1319
- ] = await Promise.all([
1320
- interopDefault(import("eslint-plugin-react")),
1321
- interopDefault(import("eslint-plugin-react-hooks")),
1322
- interopDefault(import("eslint-plugin-react-refresh"))
1323
- ]);
1242
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
1243
+ [
1244
+ interopDefault(import("eslint-plugin-react")),
1245
+ interopDefault(import("eslint-plugin-react-hooks")),
1246
+ interopDefault(import("eslint-plugin-react-refresh"))
1247
+ ]
1248
+ );
1324
1249
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1325
1250
  (i) => isPackageExists2(i)
1326
1251
  );
@@ -1328,9 +1253,14 @@ async function react(options = {}) {
1328
1253
  {
1329
1254
  name: "coderwyd:react:setup",
1330
1255
  plugins: {
1331
- "react": pluginReact,
1256
+ react: pluginReact,
1332
1257
  "react-hooks": pluginReactHooks,
1333
1258
  "react-refresh": pluginReactRefresh
1259
+ },
1260
+ settings: {
1261
+ react: {
1262
+ version: "detect"
1263
+ }
1334
1264
  }
1335
1265
  },
1336
1266
  {
@@ -1388,21 +1318,14 @@ async function react(options = {}) {
1388
1318
 
1389
1319
  // src/configs/unocss.ts
1390
1320
  async function unocss(options = {}) {
1391
- const {
1392
- attributify = true,
1393
- strict = false
1394
- } = options;
1395
- await ensurePackages([
1396
- "@unocss/eslint-plugin"
1397
- ]);
1398
- const [
1399
- pluginUnoCSS
1400
- ] = await Promise.all([
1321
+ const { attributify = true, strict = false } = options;
1322
+ await ensurePackages(["@unocss/eslint-plugin"]);
1323
+ const [pluginUnoCSS] = await Promise.all([
1401
1324
  interopDefault(import("@unocss/eslint-plugin"))
1402
1325
  ]);
1403
1326
  return [
1404
1327
  {
1405
- name: "antfu:unocss",
1328
+ name: "coderwyd:unocss",
1406
1329
  plugins: {
1407
1330
  unocss: pluginUnoCSS
1408
1331
  },
@@ -1419,7 +1342,82 @@ async function unocss(options = {}) {
1419
1342
  ];
1420
1343
  }
1421
1344
 
1422
- // src/factory.ts
1345
+ // src/configs/formatter.ts
1346
+ async function formatter(options = {}, prettierRules2 = {}) {
1347
+ await ensurePackages(["eslint-plugin-prettier"]);
1348
+ const {
1349
+ css = true,
1350
+ graphql,
1351
+ html = true,
1352
+ markdown,
1353
+ toml,
1354
+ yaml
1355
+ } = options || {};
1356
+ const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
1357
+ function createPrettierFormatter(files, parser, plugins) {
1358
+ const rules = {
1359
+ ...prettierRules2,
1360
+ parser
1361
+ };
1362
+ if (plugins == null ? void 0 : plugins.length) {
1363
+ rules.plugins = [...rules.plugins || [], ...plugins];
1364
+ }
1365
+ const config = {
1366
+ files,
1367
+ languageOptions: {
1368
+ parser: parserPlain
1369
+ },
1370
+ name: `coderwyd:formatter:${parser}`,
1371
+ plugins: {
1372
+ prettier: pluginPrettier
1373
+ },
1374
+ rules: {
1375
+ "prettier/prettier": ["warn", rules]
1376
+ }
1377
+ };
1378
+ return config;
1379
+ }
1380
+ const configs = [
1381
+ {
1382
+ name: "coderwyd:formatter:setup",
1383
+ plugins: {
1384
+ prettier: pluginPrettier
1385
+ }
1386
+ }
1387
+ ];
1388
+ if (css) {
1389
+ const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
1390
+ const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
1391
+ const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
1392
+ configs.push(cssConfig, scssConfig, lessConfig);
1393
+ }
1394
+ if (html) {
1395
+ const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1396
+ configs.push(htmlConfig);
1397
+ }
1398
+ if (markdown) {
1399
+ const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
1400
+ configs.push(markdownConfig);
1401
+ }
1402
+ if (graphql) {
1403
+ const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
1404
+ configs.push(graphqlConfig);
1405
+ }
1406
+ if (yaml) {
1407
+ const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
1408
+ configs.push(yamlConfig);
1409
+ }
1410
+ if (toml) {
1411
+ await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1412
+ const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1413
+ "prettier-plugin-toml"
1414
+ ]);
1415
+ configs.push(tomlConfig);
1416
+ }
1417
+ return configs;
1418
+ }
1419
+
1420
+ // src/index.ts
1423
1421
  var flatConfigProps = [
1424
1422
  "files",
1425
1423
  "ignores",
@@ -1430,49 +1428,45 @@ var flatConfigProps = [
1430
1428
  "rules",
1431
1429
  "settings"
1432
1430
  ];
1433
- var VuePackages = [
1434
- "vue",
1435
- "nuxt",
1436
- "vitepress",
1437
- "@slidev/cli"
1438
- ];
1439
- async function coderwyd(options = {}, ...userConfigs) {
1431
+ var VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
1432
+ async function defineConfig(options = {}, ...userConfigs) {
1440
1433
  const {
1441
1434
  componentExts = [],
1442
1435
  gitignore: enableGitignore = true,
1443
- isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
1444
- overrides = {},
1436
+ isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1445
1437
  react: enableReact = false,
1446
1438
  typescript: enableTypeScript = isPackageExists3("typescript"),
1447
1439
  unocss: enableUnoCSS = false,
1440
+ usePrettierrc = true,
1448
1441
  vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
1449
1442
  } = options;
1450
- const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1451
- if (stylisticOptions && !("jsx" in stylisticOptions))
1452
- stylisticOptions.jsx = options.jsx ?? true;
1453
1443
  const configs = [];
1454
1444
  if (enableGitignore) {
1455
1445
  if (typeof enableGitignore !== "boolean") {
1456
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1446
+ configs.push(
1447
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1448
+ r(enableGitignore)
1449
+ ])
1450
+ );
1457
1451
  } else {
1458
1452
  if (fs.existsSync(".gitignore"))
1459
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1453
+ configs.push(
1454
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1455
+ r()
1456
+ ])
1457
+ );
1460
1458
  }
1461
1459
  }
1462
1460
  configs.push(
1463
1461
  ignores(),
1464
1462
  javascript({
1465
1463
  isInEditor,
1466
- overrides: overrides.javascript
1464
+ overrides: getOverrides(options, "javascript")
1467
1465
  }),
1468
1466
  comments(),
1469
1467
  node(),
1470
- jsdoc({
1471
- stylistic: stylisticOptions
1472
- }),
1473
- imports({
1474
- stylistic: stylisticOptions
1475
- }),
1468
+ jsdoc(),
1469
+ imports(),
1476
1470
  unicorn(),
1477
1471
  // Optional plugins (installed but not enabled by default)
1478
1472
  perfectionist()
@@ -1480,60 +1474,70 @@ async function coderwyd(options = {}, ...userConfigs) {
1480
1474
  if (enableVue)
1481
1475
  componentExts.push("vue");
1482
1476
  if (enableTypeScript) {
1483
- configs.push(typescript({
1484
- ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1485
- componentExts,
1486
- overrides: overrides.typescript
1487
- }));
1477
+ configs.push(
1478
+ typescript({
1479
+ ...resolveSubOptions(options, "typescript"),
1480
+ componentExts
1481
+ })
1482
+ );
1488
1483
  }
1489
- if (stylisticOptions)
1490
- configs.push(stylistic(stylisticOptions));
1491
1484
  if (options.test ?? true) {
1492
- configs.push(test({
1493
- isInEditor,
1494
- overrides: overrides.test
1495
- }));
1485
+ configs.push(
1486
+ test({
1487
+ isInEditor,
1488
+ overrides: getOverrides(options, "test")
1489
+ })
1490
+ );
1496
1491
  }
1497
1492
  if (enableVue) {
1498
- configs.push(vue({
1499
- overrides: overrides.vue,
1500
- stylistic: stylisticOptions,
1501
- typescript: !!enableTypeScript
1502
- }));
1493
+ configs.push(
1494
+ vue({
1495
+ ...resolveSubOptions(options, "vue"),
1496
+ typescript: !!enableTypeScript
1497
+ })
1498
+ );
1503
1499
  }
1504
1500
  if (enableReact) {
1505
- configs.push(react({
1506
- overrides: overrides.react,
1507
- typescript: !!enableTypeScript
1508
- }));
1501
+ configs.push(
1502
+ react({
1503
+ overrides: getOverrides(options, "react"),
1504
+ typescript: !!enableTypeScript
1505
+ })
1506
+ );
1509
1507
  }
1510
1508
  if (enableUnoCSS) {
1511
- configs.push(unocss(
1512
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1513
- ));
1509
+ configs.push(
1510
+ unocss({
1511
+ ...resolveSubOptions(options, "unocss"),
1512
+ overrides: getOverrides(options, "unocss")
1513
+ })
1514
+ );
1514
1515
  }
1515
1516
  if (options.jsonc ?? true) {
1516
1517
  configs.push(
1517
1518
  jsonc({
1518
- overrides: overrides.jsonc,
1519
- stylistic: stylisticOptions
1519
+ overrides: getOverrides(options, "jsonc")
1520
1520
  }),
1521
1521
  sortPackageJson(),
1522
1522
  sortTsconfig()
1523
1523
  );
1524
1524
  }
1525
- if (options.yaml ?? true) {
1526
- configs.push(yaml({
1527
- overrides: overrides.yaml,
1528
- stylistic: stylisticOptions
1529
- }));
1525
+ let prettierRules2 = {
1526
+ ...DEFAULT_PRETTIER_RULES
1527
+ };
1528
+ if (options.prettierRules) {
1529
+ prettierRules2 = { ...prettierRules2, ...options.prettierRules };
1530
1530
  }
1531
- if (options.markdown ?? true) {
1532
- configs.push(markdown({
1533
- componentExts,
1534
- overrides: overrides.markdown
1535
- }));
1531
+ if (usePrettierrc) {
1532
+ const prettierConfig = await loadPrettierConfig(
1533
+ options.cwd ?? process3.cwd()
1534
+ );
1535
+ Object.assign(prettierRules2, prettierConfig);
1536
1536
  }
1537
+ configs.push(
1538
+ prettier(prettierRules2),
1539
+ formatter(options.formatter, prettierRules2)
1540
+ );
1537
1541
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1538
1542
  if (key in options)
1539
1543
  acc[key] = options[key];
@@ -1541,62 +1545,9 @@ async function coderwyd(options = {}, ...userConfigs) {
1541
1545
  }, {});
1542
1546
  if (Object.keys(fusedConfig).length)
1543
1547
  configs.push([fusedConfig]);
1544
- const merged = combine(
1545
- ...configs,
1546
- ...userConfigs
1547
- );
1548
+ const merged = combine(...configs, ...userConfigs);
1548
1549
  return merged;
1549
1550
  }
1550
-
1551
- // src/index.ts
1552
- var src_default = coderwyd;
1553
1551
  export {
1554
- GLOB_ALL_SRC,
1555
- GLOB_CSS,
1556
- GLOB_EXCLUDE,
1557
- GLOB_HTML,
1558
- GLOB_JS,
1559
- GLOB_JSON,
1560
- GLOB_JSON5,
1561
- GLOB_JSONC,
1562
- GLOB_JSX,
1563
- GLOB_LESS,
1564
- GLOB_MARKDOWN,
1565
- GLOB_MARKDOWN_CODE,
1566
- GLOB_SCSS,
1567
- GLOB_SRC,
1568
- GLOB_SRC_EXT,
1569
- GLOB_STYLE,
1570
- GLOB_TESTS,
1571
- GLOB_TS,
1572
- GLOB_TSX,
1573
- GLOB_VUE,
1574
- GLOB_YAML,
1575
- coderwyd,
1576
- combine,
1577
- comments,
1578
- src_default as default,
1579
- ensurePackages,
1580
- getVueVersion,
1581
- ignores,
1582
- imports,
1583
- interopDefault,
1584
- javascript,
1585
- jsdoc,
1586
- jsonc,
1587
- markdown,
1588
- node,
1589
- perfectionist,
1590
- react,
1591
- renameRules,
1592
- sortPackageJson,
1593
- sortTsconfig,
1594
- stylistic,
1595
- test,
1596
- toArray,
1597
- typescript,
1598
- unicorn,
1599
- unocss,
1600
- vue,
1601
- yaml
1552
+ defineConfig
1602
1553
  };