@coderwyd/eslint-config 1.1.0-beta.3 → 1.1.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
@@ -31,7 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
33
  GLOB_ALL_SRC: () => GLOB_ALL_SRC,
34
- GLOB_ASTRO: () => GLOB_ASTRO,
35
34
  GLOB_CSS: () => GLOB_CSS,
36
35
  GLOB_EXCLUDE: () => GLOB_EXCLUDE,
37
36
  GLOB_HTML: () => GLOB_HTML,
@@ -52,50 +51,31 @@ __export(src_exports, {
52
51
  GLOB_TSX: () => GLOB_TSX,
53
52
  GLOB_VUE: () => GLOB_VUE,
54
53
  GLOB_YAML: () => GLOB_YAML,
55
- astro: () => astro,
56
54
  coderwyd: () => coderwyd,
57
55
  combine: () => combine,
58
56
  comments: () => comments,
59
57
  default: () => src_default,
58
+ ensurePackages: () => ensurePackages,
60
59
  getVueVersion: () => getVueVersion,
61
60
  ignores: () => ignores,
62
61
  imports: () => imports,
62
+ interopDefault: () => interopDefault,
63
63
  javascript: () => javascript,
64
64
  jsdoc: () => jsdoc,
65
65
  jsonc: () => jsonc,
66
66
  markdown: () => markdown,
67
67
  node: () => node,
68
- parserAstro: () => import_astro_eslint_parser.default,
69
- parserJsonc: () => import_jsonc_eslint_parser.default,
70
- parserTs: () => parserTs,
71
- parserVue: () => import_vue_eslint_parser.default,
72
- parserYaml: () => import_yaml_eslint_parser.default,
73
- pluginAntfu: () => import_eslint_plugin_antfu.default,
74
- pluginAstro: () => import_eslint_plugin_astro.default,
75
- pluginComments: () => import_eslint_plugin_eslint_comments.default,
76
- pluginImport: () => pluginImport,
77
- pluginJsdoc: () => import_eslint_plugin_jsdoc.default,
78
- pluginJsonc: () => pluginJsonc,
79
- pluginMarkdown: () => import_eslint_plugin_markdown.default,
80
- pluginNoOnlyTests: () => import_eslint_plugin_no_only_tests.default,
81
- pluginNode: () => import_eslint_plugin_n.default,
82
- pluginReact: () => import_eslint_plugin_react.default,
83
- pluginReactHooks: () => import_eslint_plugin_react_hooks.default,
84
- pluginStylistic: () => import_eslint_plugin.default,
85
- pluginTs: () => import_eslint_plugin2.default,
86
- pluginUnicorn: () => import_eslint_plugin_unicorn.default,
87
- pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
88
- pluginVitest: () => import_eslint_plugin_vitest.default,
89
- pluginVue: () => import_eslint_plugin_vue.default,
90
- pluginYaml: () => pluginYaml,
68
+ perfectionist: () => perfectionist,
91
69
  react: () => react,
92
70
  renameRules: () => renameRules,
93
71
  sortPackageJson: () => sortPackageJson,
94
72
  sortTsconfig: () => sortTsconfig,
95
73
  stylistic: () => stylistic,
96
74
  test: () => test,
75
+ toArray: () => toArray,
97
76
  typescript: () => typescript,
98
77
  unicorn: () => unicorn,
78
+ unocss: () => unocss,
99
79
  vue: () => vue,
100
80
  yaml: () => yaml
101
81
  });
@@ -104,36 +84,19 @@ module.exports = __toCommonJS(src_exports);
104
84
  // src/factory.ts
105
85
  var import_node_process3 = __toESM(require("process"), 1);
106
86
  var import_node_fs = __toESM(require("fs"), 1);
107
- var import_local_pkg2 = require("local-pkg");
108
- var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
87
+ var import_local_pkg3 = require("local-pkg");
109
88
 
110
89
  // src/plugins.ts
111
90
  var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
112
91
  var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
113
92
  var pluginImport = __toESM(require("eslint-plugin-i"), 1);
114
- var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
115
- var pluginJsonc = __toESM(require("eslint-plugin-jsonc"), 1);
116
- var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
117
93
  var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
118
- var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
119
- var import_eslint_plugin2 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
120
94
  var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
121
95
  var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
122
- var pluginYaml = __toESM(require("eslint-plugin-yml"), 1);
123
- var import_eslint_plugin_no_only_tests = __toESM(require("eslint-plugin-no-only-tests"), 1);
124
- var import_eslint_plugin_vitest = __toESM(require("eslint-plugin-vitest"), 1);
125
- var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
126
- var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
127
- var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
128
- var import_eslint_plugin_astro = __toESM(require("eslint-plugin-astro"), 1);
129
- var parserTs = __toESM(require("@typescript-eslint/parser"), 1);
130
- var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
131
- var import_yaml_eslint_parser = __toESM(require("yaml-eslint-parser"), 1);
132
- var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
133
- var import_astro_eslint_parser = __toESM(require("astro-eslint-parser"), 1);
96
+ var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
134
97
 
135
98
  // src/configs/comments.ts
136
- function comments() {
99
+ async function comments() {
137
100
  return [
138
101
  {
139
102
  name: "coderwyd:eslint-comments",
@@ -168,7 +131,6 @@ var GLOB_MARKDOWN = "**/*.md";
168
131
  var GLOB_VUE = "**/*.vue";
169
132
  var GLOB_YAML = "**/*.y?(a)ml";
170
133
  var GLOB_HTML = "**/*.htm?(l)";
171
- var GLOB_ASTRO = "**/*.astro";
172
134
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
173
135
  var GLOB_TESTS = [
174
136
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -197,8 +159,13 @@ var GLOB_EXCLUDE = [
197
159
  "**/output",
198
160
  "**/coverage",
199
161
  "**/temp",
162
+ "**/.temp",
163
+ "**/tmp",
164
+ "**/.tmp",
165
+ "**/.history",
200
166
  "**/.vitepress/cache",
201
167
  "**/.nuxt",
168
+ "**/.next",
202
169
  "**/.vercel",
203
170
  "**/.changeset",
204
171
  "**/.idea",
@@ -214,7 +181,7 @@ var GLOB_EXCLUDE = [
214
181
  ];
215
182
 
216
183
  // src/configs/ignores.ts
217
- function ignores() {
184
+ async function ignores() {
218
185
  return [
219
186
  {
220
187
  ignores: GLOB_EXCLUDE
@@ -223,7 +190,7 @@ function ignores() {
223
190
  }
224
191
 
225
192
  // src/configs/imports.ts
226
- function imports(options = {}) {
193
+ async function imports(options = {}) {
227
194
  const {
228
195
  stylistic: stylistic2 = true
229
196
  } = options;
@@ -254,12 +221,7 @@ function imports(options = {}) {
254
221
 
255
222
  // src/configs/javascript.ts
256
223
  var import_globals = __toESM(require("globals"), 1);
257
-
258
- // src/flags.ts
259
- var OFF = 0;
260
-
261
- // src/configs/javascript.ts
262
- function javascript(options = {}) {
224
+ async function javascript(options = {}) {
263
225
  const {
264
226
  isInEditor = false,
265
227
  overrides = {}
@@ -285,6 +247,9 @@ function javascript(options = {}) {
285
247
  },
286
248
  sourceType: "module"
287
249
  },
250
+ linterOptions: {
251
+ reportUnusedDisableDirectives: true
252
+ },
288
253
  name: "coderwyd:javascript",
289
254
  plugins: {
290
255
  "antfu": import_eslint_plugin_antfu.default,
@@ -293,7 +258,6 @@ function javascript(options = {}) {
293
258
  rules: {
294
259
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
295
260
  "array-callback-return": "error",
296
- "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
297
261
  "block-scoped-var": "error",
298
262
  "constructor-super": "error",
299
263
  "default-case-last": "error",
@@ -331,7 +295,6 @@ function javascript(options = {}) {
331
295
  "no-implied-eval": "error",
332
296
  "no-import-assign": "error",
333
297
  "no-invalid-regexp": "error",
334
- "no-invalid-this": "error",
335
298
  "no-irregular-whitespace": "error",
336
299
  "no-iterator": "error",
337
300
  "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
@@ -409,7 +372,6 @@ function javascript(options = {}) {
409
372
  "no-useless-rename": "error",
410
373
  "no-useless-return": "error",
411
374
  "no-var": "error",
412
- "no-void": "error",
413
375
  "no-with": "error",
414
376
  "object-shorthand": [
415
377
  "error",
@@ -452,7 +414,7 @@ function javascript(options = {}) {
452
414
  ],
453
415
  "symbol-description": "error",
454
416
  "unicode-bom": ["error", "never"],
455
- "unused-imports/no-unused-imports": isInEditor ? OFF : "error",
417
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
456
418
  "unused-imports/no-unused-vars": [
457
419
  "error",
458
420
  { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
@@ -468,14 +430,61 @@ function javascript(options = {}) {
468
430
  files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
469
431
  name: "coderwyd:scripts-overrides",
470
432
  rules: {
471
- "no-console": OFF
433
+ "no-console": "off"
472
434
  }
473
435
  }
474
436
  ];
475
437
  }
476
438
 
439
+ // src/utils.ts
440
+ var import_node_process = __toESM(require("process"), 1);
441
+ var import_local_pkg = require("local-pkg");
442
+ async function combine(...configs) {
443
+ const resolved = await Promise.all(configs);
444
+ return resolved.flat();
445
+ }
446
+ function renameRules(rules, from, to) {
447
+ return Object.fromEntries(
448
+ Object.entries(rules).map(([key, value]) => {
449
+ if (key.startsWith(from))
450
+ return [to + key.slice(from.length), value];
451
+ return [key, value];
452
+ })
453
+ );
454
+ }
455
+ function getVueVersion() {
456
+ const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
457
+ if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
458
+ return +pkg.version[0];
459
+ return 3;
460
+ }
461
+ function toArray(value) {
462
+ return Array.isArray(value) ? value : [value];
463
+ }
464
+ async function interopDefault(m) {
465
+ const resolved = await m;
466
+ return resolved.default || resolved;
467
+ }
468
+ async function ensurePackages(packages) {
469
+ if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false)
470
+ return;
471
+ const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i));
472
+ if (nonExistingPackages.length === 0)
473
+ return;
474
+ const { default: prompts } = await import("prompts");
475
+ const { result } = await prompts([
476
+ {
477
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
478
+ name: "result",
479
+ type: "confirm"
480
+ }
481
+ ]);
482
+ if (result)
483
+ await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
484
+ }
485
+
477
486
  // src/configs/jsdoc.ts
478
- function jsdoc(options = {}) {
487
+ async function jsdoc(options = {}) {
479
488
  const {
480
489
  stylistic: stylistic2 = true
481
490
  } = options;
@@ -483,7 +492,8 @@ function jsdoc(options = {}) {
483
492
  {
484
493
  name: "coderwyd:jsdoc",
485
494
  plugins: {
486
- jsdoc: import_eslint_plugin_jsdoc.default
495
+ // @ts-expect-error missing types
496
+ jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
487
497
  },
488
498
  rules: {
489
499
  "jsdoc/check-access": "warn",
@@ -511,14 +521,22 @@ function jsdoc(options = {}) {
511
521
  }
512
522
 
513
523
  // src/configs/jsonc.ts
514
- function jsonc(options = {}) {
524
+ async function jsonc(options = {}) {
515
525
  const {
516
- stylistic: stylistic2 = true,
517
- overrides = {}
526
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
527
+ overrides = {},
528
+ stylistic: stylistic2 = true
518
529
  } = options;
519
530
  const {
520
531
  indent = 2
521
532
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
533
+ const [
534
+ pluginJsonc,
535
+ parserJsonc
536
+ ] = await Promise.all([
537
+ interopDefault(import("eslint-plugin-jsonc")),
538
+ interopDefault(import("jsonc-eslint-parser"))
539
+ ]);
522
540
  return [
523
541
  {
524
542
  name: "coderwyd:jsonc:setup",
@@ -527,9 +545,9 @@ function jsonc(options = {}) {
527
545
  }
528
546
  },
529
547
  {
530
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
548
+ files,
531
549
  languageOptions: {
532
- parser: import_jsonc_eslint_parser.default
550
+ parser: parserJsonc
533
551
  },
534
552
  name: "coderwyd:jsonc:rules",
535
553
  rules: {
@@ -578,20 +596,22 @@ function jsonc(options = {}) {
578
596
  }
579
597
 
580
598
  // src/configs/markdown.ts
581
- function markdown(options = {}) {
599
+ async function markdown(options = {}) {
582
600
  const {
583
601
  componentExts = [],
602
+ files = [GLOB_MARKDOWN],
584
603
  overrides = {}
585
604
  } = options;
586
605
  return [
587
606
  {
588
607
  name: "coderwyd:markdown:setup",
589
608
  plugins: {
590
- markdown: import_eslint_plugin_markdown.default
609
+ // @ts-expect-error missing types
610
+ markdown: await interopDefault(import("eslint-plugin-markdown"))
591
611
  }
592
612
  },
593
613
  {
594
- files: [GLOB_MARKDOWN],
614
+ files,
595
615
  name: "coderwyd:markdown:processor",
596
616
  processor: "markdown/markdown"
597
617
  },
@@ -609,44 +629,48 @@ function markdown(options = {}) {
609
629
  },
610
630
  name: "coderwyd:markdown:rules",
611
631
  rules: {
612
- "antfu/no-cjs-exports": OFF,
613
- "antfu/no-ts-export-equal": OFF,
614
- "no-alert": OFF,
615
- "no-console": OFF,
616
- "no-undef": OFF,
617
- "no-unused-expressions": OFF,
618
- "no-unused-vars": OFF,
619
- "node/prefer-global/process": OFF,
620
- "style/comma-dangle": OFF,
621
- "style/eol-last": OFF,
622
- "ts/consistent-type-imports": OFF,
623
- "ts/no-namespace": OFF,
624
- "ts/no-redeclare": OFF,
625
- "ts/no-require-imports": OFF,
626
- "ts/no-unused-vars": OFF,
627
- "ts/no-use-before-define": OFF,
628
- "ts/no-var-requires": OFF,
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",
629
653
  "unicode-bom": "off",
630
- "unused-imports/no-unused-imports": OFF,
631
- "unused-imports/no-unused-vars": OFF,
654
+ "unused-imports/no-unused-imports": "off",
655
+ "unused-imports/no-unused-vars": "off",
632
656
  // Type aware rules
633
657
  ...{
634
- "ts/await-thenable": OFF,
635
- "ts/dot-notation": OFF,
636
- "ts/no-floating-promises": OFF,
637
- "ts/no-for-in-array": OFF,
638
- "ts/no-implied-eval": OFF,
639
- "ts/no-misused-promises": OFF,
640
- "ts/no-throw-literal": OFF,
641
- "ts/no-unnecessary-type-assertion": OFF,
642
- "ts/no-unsafe-argument": OFF,
643
- "ts/no-unsafe-assignment": OFF,
644
- "ts/no-unsafe-call": OFF,
645
- "ts/no-unsafe-member-access": OFF,
646
- "ts/no-unsafe-return": OFF,
647
- "ts/restrict-plus-operands": OFF,
648
- "ts/restrict-template-expressions": OFF,
649
- "ts/unbound-method": OFF
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"
650
674
  },
651
675
  ...overrides
652
676
  }
@@ -655,7 +679,7 @@ function markdown(options = {}) {
655
679
  }
656
680
 
657
681
  // src/configs/node.ts
658
- function node() {
682
+ async function node() {
659
683
  return [
660
684
  {
661
685
  name: "coderwyd:node",
@@ -677,7 +701,7 @@ function node() {
677
701
  }
678
702
 
679
703
  // src/configs/sort.ts
680
- function sortPackageJson() {
704
+ async function sortPackageJson() {
681
705
  return [
682
706
  {
683
707
  files: ["**/package.json"],
@@ -736,7 +760,6 @@ function sortPackageJson() {
736
760
  "husky",
737
761
  "simple-git-hooks",
738
762
  "lint-staged",
739
- "nano-staged",
740
763
  "eslintConfig"
741
764
  ],
742
765
  pathPattern: "^$"
@@ -894,161 +917,58 @@ function sortTsconfig() {
894
917
  }
895
918
 
896
919
  // src/configs/stylistic.ts
897
- function stylistic(options = {}) {
920
+ async function stylistic(options = {}) {
898
921
  const {
899
922
  indent = 2,
900
- quotes = "single"
923
+ jsx = true,
924
+ quotes = "single",
925
+ semi = false
901
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
+ });
902
936
  return [
903
937
  {
904
938
  name: "coderwyd:stylistic",
905
939
  plugins: {
906
940
  antfu: import_eslint_plugin_antfu.default,
907
- style: import_eslint_plugin.default
941
+ style: pluginStylistic
908
942
  },
909
943
  rules: {
944
+ ...config.rules,
910
945
  "antfu/consistent-list-newline": "error",
911
946
  "antfu/if-newline": "error",
947
+ "antfu/indent-binary-ops": ["error", { indent }],
912
948
  "antfu/top-level-function": "error",
913
- "curly": ["error", "multi-or-nest", "consistent"],
914
- "style/array-bracket-spacing": ["error", "never"],
915
- "style/arrow-spacing": ["error", { after: true, before: true }],
916
- "style/block-spacing": ["error", "always"],
917
- "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
918
- "style/comma-dangle": ["error", "always-multiline"],
919
- "style/comma-spacing": ["error", { after: true, before: false }],
920
- "style/comma-style": ["error", "last"],
921
- "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
922
- "style/dot-location": ["error", "property"],
923
- "style/eol-last": "error",
924
- "style/indent": ["error", indent, {
925
- ArrayExpression: 1,
926
- CallExpression: { arguments: 1 },
927
- FunctionDeclaration: { body: 1, parameters: 1 },
928
- FunctionExpression: { body: 1, parameters: 1 },
929
- ImportDeclaration: 1,
930
- MemberExpression: 1,
931
- ObjectExpression: 1,
932
- SwitchCase: 1,
933
- VariableDeclarator: 1,
934
- flatTernaryExpressions: false,
935
- ignoreComments: false,
936
- ignoredNodes: [
937
- "TemplateLiteral *",
938
- "JSXElement",
939
- "JSXElement > *",
940
- "JSXAttribute",
941
- "JSXIdentifier",
942
- "JSXNamespacedName",
943
- "JSXMemberExpression",
944
- "JSXSpreadAttribute",
945
- "JSXExpressionContainer",
946
- "JSXOpeningElement",
947
- "JSXClosingElement",
948
- "JSXFragment",
949
- "JSXOpeningFragment",
950
- "JSXClosingFragment",
951
- "JSXText",
952
- "JSXEmptyExpression",
953
- "JSXSpreadChild",
954
- "TSTypeParameterInstantiation",
955
- "FunctionExpression > .params[decorators.length > 0]",
956
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
957
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
958
- ],
959
- offsetTernaryExpressions: true,
960
- outerIIFEBody: 1
961
- }],
962
- "style/jsx-quotes": "error",
963
- "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
964
- "style/keyword-spacing": ["error", { after: true, before: true }],
965
- "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
966
- "style/max-statements-per-line": ["error", { max: 1 }],
967
- "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
968
- "style/multiline-ternary": ["error", "always-multiline"],
969
- "style/new-parens": "error",
970
- "style/no-extra-parens": ["error", "functions"],
971
- "style/no-floating-decimal": "error",
972
- "style/no-mixed-operators": ["error", {
973
- allowSamePrecedence: true,
974
- groups: [
975
- ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
976
- ["&&", "||"],
977
- ["in", "instanceof"]
978
- ]
979
- }],
980
- "style/no-mixed-spaces-and-tabs": "error",
981
- "style/no-multi-spaces": "error",
982
- "style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
983
- "style/no-tabs": indent === "tab" ? "off" : "error",
984
- "style/no-trailing-spaces": "error",
985
- "style/no-whitespace-before-property": "error",
986
- "style/object-curly-spacing": ["error", "always"],
987
- "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
988
- "style/operator-linebreak": ["error", "before"],
989
- "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
990
- "style/quote-props": ["error", "consistent-as-needed"],
991
- "style/quotes": ["error", quotes, { allowTemplateLiterals: true, avoidEscape: false }],
992
- "style/rest-spread-spacing": ["error", "never"],
993
- "style/semi": ["error", "never"],
994
- "style/semi-spacing": ["error", { after: true, before: false }],
995
- "style/space-before-blocks": ["error", "always"],
996
- "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
997
- "style/space-in-parens": ["error", "never"],
998
- "style/space-infix-ops": "error",
999
- "style/space-unary-ops": ["error", { nonwords: false, words: true }],
1000
- "style/spaced-comment": ["error", "always", {
1001
- block: {
1002
- balanced: true,
1003
- exceptions: ["*"],
1004
- markers: ["!"]
1005
- },
1006
- line: {
1007
- exceptions: ["/", "#"],
1008
- markers: ["/"]
1009
- }
1010
- }],
1011
- "style/template-curly-spacing": "error",
1012
- "style/template-tag-spacing": ["error", "never"],
1013
- "style/type-annotation-spacing": ["error", {}],
1014
- "style/wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
1015
- "style/yield-star-spacing": ["error", "both"]
949
+ "curly": ["error", "multi-or-nest", "consistent"]
1016
950
  }
1017
951
  }
1018
952
  ];
1019
953
  }
1020
954
 
1021
955
  // src/configs/typescript.ts
1022
- var import_node_process = __toESM(require("process"), 1);
1023
-
1024
- // src/utils.ts
1025
- function combine(...configs) {
1026
- return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
1027
- }
1028
- function renameRules(rules, from, to) {
1029
- return Object.fromEntries(
1030
- Object.entries(rules).map(([key, value]) => {
1031
- if (key.startsWith(from))
1032
- return [to + key.slice(from.length), value];
1033
- return [key, value];
1034
- })
1035
- );
1036
- }
1037
-
1038
- // src/configs/typescript.ts
1039
- function typescript(options) {
956
+ var import_node_process2 = __toESM(require("process"), 1);
957
+ async function typescript(options = {}) {
1040
958
  const {
1041
959
  componentExts = [],
1042
960
  overrides = {},
1043
- parserOptions = {},
1044
- tsconfigPath
1045
- } = options ?? {};
961
+ parserOptions = {}
962
+ } = options;
963
+ const files = options.files ?? [
964
+ GLOB_SRC,
965
+ ...componentExts.map((ext) => `**/*.${ext}`)
966
+ ];
1046
967
  const typeAwareRules = {
1047
- "dot-notation": OFF,
1048
- "no-implied-eval": OFF,
1049
- "no-throw-literal": OFF,
968
+ "dot-notation": "off",
969
+ "no-implied-eval": "off",
970
+ "no-throw-literal": "off",
1050
971
  "ts/await-thenable": "error",
1051
- "ts/ban-types": ["error", { types: { Function: false } }],
1052
972
  "ts/dot-notation": ["error", { allowKeywords: true }],
1053
973
  "ts/no-floating-promises": "error",
1054
974
  "ts/no-for-in-array": "error",
@@ -1065,27 +985,33 @@ function typescript(options) {
1065
985
  "ts/restrict-template-expressions": "error",
1066
986
  "ts/unbound-method": "error"
1067
987
  };
988
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
989
+ const [
990
+ pluginTs,
991
+ parserTs
992
+ ] = await Promise.all([
993
+ interopDefault(import("@typescript-eslint/eslint-plugin")),
994
+ interopDefault(import("@typescript-eslint/parser"))
995
+ ]);
1068
996
  return [
1069
997
  {
998
+ // Install the plugins without globs, so they can be configured separately.
1070
999
  name: "coderwyd:typescript:setup",
1071
1000
  plugins: {
1072
1001
  antfu: import_eslint_plugin_antfu.default,
1073
- import: pluginImport,
1074
- ts: import_eslint_plugin2.default
1002
+ ts: pluginTs
1075
1003
  }
1076
1004
  },
1077
1005
  {
1078
- files: [
1079
- GLOB_SRC,
1080
- ...componentExts.map((ext) => `**/*.${ext}`)
1081
- ],
1006
+ files,
1082
1007
  languageOptions: {
1083
1008
  parser: parserTs,
1084
1009
  parserOptions: {
1010
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1085
1011
  sourceType: "module",
1086
1012
  ...tsconfigPath ? {
1087
- project: [tsconfigPath],
1088
- tsconfigRootDir: import_node_process.default.cwd()
1013
+ project: tsconfigPath,
1014
+ tsconfigRootDir: import_node_process2.default.cwd()
1089
1015
  } : {},
1090
1016
  ...parserOptions
1091
1017
  }
@@ -1093,44 +1019,42 @@ function typescript(options) {
1093
1019
  name: "coderwyd:typescript:rules",
1094
1020
  rules: {
1095
1021
  ...renameRules(
1096
- import_eslint_plugin2.default.configs["eslint-recommended"].overrides[0].rules,
1022
+ pluginTs.configs["eslint-recommended"].overrides[0].rules,
1097
1023
  "@typescript-eslint/",
1098
1024
  "ts/"
1099
1025
  ),
1100
1026
  ...renameRules(
1101
- import_eslint_plugin2.default.configs.strict.rules,
1027
+ pluginTs.configs.strict.rules,
1102
1028
  "@typescript-eslint/",
1103
1029
  "ts/"
1104
1030
  ),
1105
1031
  "antfu/generic-spacing": "error",
1106
1032
  "antfu/named-tuple-spacing": "error",
1107
- "antfu/no-cjs-exports": "error",
1108
- "no-dupe-class-members": OFF,
1109
- "no-invalid-this": OFF,
1110
- "no-loss-of-precision": OFF,
1111
- "no-redeclare": OFF,
1112
- "no-use-before-define": OFF,
1113
- "no-useless-constructor": OFF,
1114
- // TS
1033
+ "no-dupe-class-members": "off",
1034
+ "no-loss-of-precision": "off",
1035
+ "no-redeclare": "off",
1036
+ "no-use-before-define": "off",
1037
+ "no-useless-constructor": "off",
1115
1038
  "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1039
+ "ts/ban-types": ["error", { types: { Function: false } }],
1116
1040
  "ts/consistent-type-definitions": ["error", "interface"],
1117
1041
  "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1118
1042
  "ts/no-dupe-class-members": "error",
1119
- "ts/no-dynamic-delete": OFF,
1120
- "ts/no-explicit-any": OFF,
1121
- "ts/no-extraneous-class": OFF,
1122
- "ts/no-invalid-this": "error",
1123
- "ts/no-invalid-void-type": OFF,
1043
+ "ts/no-dynamic-delete": "off",
1044
+ "ts/no-explicit-any": "off",
1045
+ "ts/no-extraneous-class": "off",
1046
+ "ts/no-import-type-side-effects": "error",
1047
+ "ts/no-invalid-void-type": "off",
1124
1048
  "ts/no-loss-of-precision": "error",
1125
- "ts/no-non-null-assertion": OFF,
1049
+ "ts/no-non-null-assertion": "off",
1126
1050
  "ts/no-redeclare": "error",
1127
1051
  "ts/no-require-imports": "error",
1128
- "ts/no-unused-vars": OFF,
1052
+ "ts/no-unused-vars": "off",
1129
1053
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1130
- "ts/no-useless-constructor": OFF,
1054
+ "ts/no-useless-constructor": "off",
1131
1055
  "ts/prefer-ts-expect-error": "error",
1132
- "ts/triple-slash-reference": OFF,
1133
- "ts/unified-signatures": OFF,
1056
+ "ts/triple-slash-reference": "off",
1057
+ "ts/unified-signatures": "off",
1134
1058
  ...tsconfigPath ? typeAwareRules : {},
1135
1059
  ...overrides
1136
1060
  }
@@ -1139,32 +1063,32 @@ function typescript(options) {
1139
1063
  files: ["**/*.d.ts"],
1140
1064
  name: "coderwyd:typescript:dts-overrides",
1141
1065
  rules: {
1142
- "eslint-comments/no-unlimited-disable": OFF,
1143
- "import/no-duplicates": OFF,
1144
- "no-restricted-syntax": OFF,
1145
- "unused-imports/no-unused-vars": OFF
1066
+ "eslint-comments/no-unlimited-disable": "off",
1067
+ "import/no-duplicates": "off",
1068
+ "no-restricted-syntax": "off",
1069
+ "unused-imports/no-unused-vars": "off"
1146
1070
  }
1147
1071
  },
1148
1072
  {
1149
- files: GLOB_TESTS,
1073
+ files: ["**/*.{test,spec}.ts?(x)"],
1150
1074
  name: "coderwyd:typescript:tests-overrides",
1151
1075
  rules: {
1152
- "no-unused-expressions": OFF
1076
+ "no-unused-expressions": "off"
1153
1077
  }
1154
1078
  },
1155
1079
  {
1156
- files: [GLOB_JS],
1080
+ files: ["**/*.js", "**/*.cjs"],
1157
1081
  name: "coderwyd:typescript:javascript-overrides",
1158
1082
  rules: {
1159
- "ts/no-require-imports": OFF,
1160
- "ts/no-var-requires": OFF
1083
+ "ts/no-require-imports": "off",
1084
+ "ts/no-var-requires": "off"
1161
1085
  }
1162
1086
  }
1163
1087
  ];
1164
1088
  }
1165
1089
 
1166
1090
  // src/configs/unicorn.ts
1167
- function unicorn() {
1091
+ async function unicorn() {
1168
1092
  return [
1169
1093
  {
1170
1094
  name: "coderwyd:unicorn",
@@ -1204,60 +1128,61 @@ function unicorn() {
1204
1128
  }
1205
1129
 
1206
1130
  // src/configs/vue.ts
1207
- var import_node_process2 = __toESM(require("process"), 1);
1208
- var import_local_pkg = require("local-pkg");
1209
- function getVueVersion() {
1210
- const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process2.default.cwd()] });
1211
- if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
1212
- return +pkg.version[0];
1213
- return 3;
1214
- }
1215
- var isVue3 = getVueVersion() === 3;
1216
- var vue3Rules = {
1217
- ...import_eslint_plugin_vue.default.configs.base.rules,
1218
- ...import_eslint_plugin_vue.default.configs["vue3-essential"].rules,
1219
- ...import_eslint_plugin_vue.default.configs["vue3-strongly-recommended"].rules,
1220
- ...import_eslint_plugin_vue.default.configs["vue3-recommended"].rules
1221
- };
1222
- var vue2Rules = {
1223
- ...import_eslint_plugin_vue.default.configs.base.rules,
1224
- ...import_eslint_plugin_vue.default.configs.essential.rules,
1225
- ...import_eslint_plugin_vue.default.configs["strongly-recommended"].rules,
1226
- ...import_eslint_plugin_vue.default.configs.recommended.rules
1227
- };
1228
- function vue(options = {}) {
1131
+ async function vue(options = {}) {
1229
1132
  const {
1133
+ files = [GLOB_VUE],
1230
1134
  overrides = {},
1231
1135
  stylistic: stylistic2 = true
1232
1136
  } = options;
1233
1137
  const {
1234
1138
  indent = 2
1235
1139
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1140
+ const isVue3 = getVueVersion() === 3;
1141
+ const [
1142
+ pluginVue,
1143
+ parserVue
1144
+ ] = await Promise.all([
1145
+ // @ts-expect-error missing types
1146
+ interopDefault(import("eslint-plugin-vue")),
1147
+ interopDefault(import("vue-eslint-parser"))
1148
+ ]);
1149
+ const vue3Rules = {
1150
+ ...pluginVue.configs.base.rules,
1151
+ ...pluginVue.configs["vue3-essential"].rules,
1152
+ ...pluginVue.configs["vue3-strongly-recommended"].rules,
1153
+ ...pluginVue.configs["vue3-recommended"].rules
1154
+ };
1155
+ const vue2Rules = {
1156
+ ...pluginVue.configs.base.rules,
1157
+ ...pluginVue.configs.essential.rules,
1158
+ ...pluginVue.configs["strongly-recommended"].rules,
1159
+ ...pluginVue.configs.recommended.rules
1160
+ };
1236
1161
  return [
1237
1162
  {
1238
1163
  name: "coderwyd:vue:setup",
1239
1164
  plugins: {
1240
- vue: import_eslint_plugin_vue.default
1165
+ vue: pluginVue
1241
1166
  }
1242
1167
  },
1243
1168
  {
1244
- files: [GLOB_VUE],
1169
+ files,
1245
1170
  languageOptions: {
1246
- parser: import_vue_eslint_parser.default,
1171
+ parser: parserVue,
1247
1172
  parserOptions: {
1248
1173
  ecmaFeatures: {
1249
1174
  jsx: true
1250
1175
  },
1251
1176
  extraFileExtensions: [".vue"],
1252
- parser: options.typescript ? parserTs : null,
1177
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1253
1178
  sourceType: "module"
1254
1179
  }
1255
1180
  },
1256
1181
  name: "coderwyd:vue:rules",
1257
- processor: import_eslint_plugin_vue.default.processors[".vue"],
1182
+ processor: pluginVue.processors[".vue"],
1258
1183
  rules: {
1259
1184
  ...isVue3 ? vue3Rules : vue2Rules,
1260
- "node/prefer-global/process": OFF,
1185
+ "node/prefer-global/process": "off",
1261
1186
  "vue/block-order": ["error", {
1262
1187
  order: ["script", "template", "style"]
1263
1188
  }],
@@ -1272,9 +1197,9 @@ function vue(options = {}) {
1272
1197
  "vue/eqeqeq": ["error", "smart"],
1273
1198
  "vue/html-indent": ["error", indent],
1274
1199
  "vue/html-quotes": ["error", "double"],
1275
- "vue/max-attributes-per-line": OFF,
1276
- "vue/multi-word-component-names": OFF,
1277
- "vue/no-dupe-keys": OFF,
1200
+ "vue/max-attributes-per-line": "off",
1201
+ "vue/multi-word-component-names": "off",
1202
+ "vue/no-dupe-keys": "off",
1278
1203
  "vue/no-empty-pattern": "error",
1279
1204
  "vue/no-extra-parens": ["error", "functions"],
1280
1205
  "vue/no-irregular-whitespace": "error",
@@ -1286,11 +1211,11 @@ function vue(options = {}) {
1286
1211
  "WithStatement"
1287
1212
  ],
1288
1213
  "vue/no-restricted-v-bind": ["error", "/^v-/"],
1289
- "vue/no-setup-props-reactivity-loss": OFF,
1214
+ "vue/no-setup-props-reactivity-loss": "off",
1290
1215
  "vue/no-sparse-arrays": "error",
1291
1216
  "vue/no-unused-refs": "error",
1292
1217
  "vue/no-useless-v-bind": "error",
1293
- "vue/no-v-html": OFF,
1218
+ "vue/no-v-html": "off",
1294
1219
  "vue/object-shorthand": [
1295
1220
  "error",
1296
1221
  "always",
@@ -1301,8 +1226,9 @@ function vue(options = {}) {
1301
1226
  ],
1302
1227
  "vue/prefer-separate-static-class": "error",
1303
1228
  "vue/prefer-template": "error",
1304
- "vue/require-default-prop": OFF,
1305
- "vue/require-prop-types": OFF,
1229
+ "vue/prop-name-casing": ["error", "camelCase"],
1230
+ "vue/require-default-prop": "off",
1231
+ "vue/require-prop-types": "off",
1306
1232
  "vue/space-infix-ops": "error",
1307
1233
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1308
1234
  ...stylistic2 ? {
@@ -1322,7 +1248,7 @@ function vue(options = {}) {
1322
1248
  }],
1323
1249
  "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1324
1250
  "vue/keyword-spacing": ["error", { after: true, before: true }],
1325
- "vue/object-curly-newline": OFF,
1251
+ "vue/object-curly-newline": "off",
1326
1252
  "vue/object-curly-spacing": ["error", "always"],
1327
1253
  "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1328
1254
  "vue/operator-linebreak": ["error", "before"],
@@ -1338,8 +1264,9 @@ function vue(options = {}) {
1338
1264
  }
1339
1265
 
1340
1266
  // src/configs/yaml.ts
1341
- function yaml(options = {}) {
1267
+ async function yaml(options = {}) {
1342
1268
  const {
1269
+ files = [GLOB_YAML],
1343
1270
  overrides = {},
1344
1271
  stylistic: stylistic2 = true
1345
1272
  } = options;
@@ -1347,6 +1274,13 @@ function yaml(options = {}) {
1347
1274
  indent = 2,
1348
1275
  quotes = "single"
1349
1276
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1277
+ const [
1278
+ pluginYaml,
1279
+ parserYaml
1280
+ ] = await Promise.all([
1281
+ interopDefault(import("eslint-plugin-yml")),
1282
+ interopDefault(import("yaml-eslint-parser"))
1283
+ ]);
1350
1284
  return [
1351
1285
  {
1352
1286
  name: "coderwyd:yaml:setup",
@@ -1355,13 +1289,13 @@ function yaml(options = {}) {
1355
1289
  }
1356
1290
  },
1357
1291
  {
1358
- files: [GLOB_YAML],
1292
+ files,
1359
1293
  languageOptions: {
1360
- parser: import_yaml_eslint_parser.default
1294
+ parser: parserYaml
1361
1295
  },
1362
1296
  name: "coderwyd:yaml:rules",
1363
1297
  rules: {
1364
- "style/spaced-comment": OFF,
1298
+ "style/spaced-comment": "off",
1365
1299
  "yaml/block-mapping": "error",
1366
1300
  "yaml/block-sequence": "error",
1367
1301
  "yaml/no-empty-key": "error",
@@ -1389,32 +1323,42 @@ function yaml(options = {}) {
1389
1323
  }
1390
1324
 
1391
1325
  // src/configs/test.ts
1392
- function test(options = {}) {
1326
+ async function test(options = {}) {
1393
1327
  const {
1328
+ files = GLOB_TESTS,
1394
1329
  isInEditor = false,
1395
1330
  overrides = {}
1396
1331
  } = options;
1332
+ const [
1333
+ pluginVitest,
1334
+ pluginNoOnlyTests
1335
+ ] = await Promise.all([
1336
+ interopDefault(import("eslint-plugin-vitest")),
1337
+ // @ts-expect-error missing types
1338
+ interopDefault(import("eslint-plugin-no-only-tests"))
1339
+ ]);
1397
1340
  return [
1398
1341
  {
1399
1342
  name: "coderwyd:test:setup",
1400
1343
  plugins: {
1401
1344
  test: {
1402
- ...import_eslint_plugin_vitest.default,
1345
+ ...pluginVitest,
1403
1346
  rules: {
1404
- ...import_eslint_plugin_vitest.default.rules,
1347
+ ...pluginVitest.rules,
1405
1348
  // extend `test/no-only-tests` rule
1406
- ...import_eslint_plugin_no_only_tests.default.rules
1349
+ ...pluginNoOnlyTests.rules
1407
1350
  }
1408
1351
  }
1409
1352
  }
1410
1353
  },
1411
1354
  {
1412
- files: GLOB_TESTS,
1355
+ files,
1413
1356
  name: "coderwyd:test:rules",
1414
1357
  rules: {
1358
+ "node/prefer-global/process": "off",
1415
1359
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1416
1360
  "test/no-identical-title": "error",
1417
- "test/no-only-tests": isInEditor ? OFF : "error",
1361
+ "test/no-only-tests": isInEditor ? "off" : "error",
1418
1362
  "test/prefer-hooks-in-order": "error",
1419
1363
  "test/prefer-lowercase-title": "error",
1420
1364
  ...overrides
@@ -1423,210 +1367,136 @@ function test(options = {}) {
1423
1367
  ];
1424
1368
  }
1425
1369
 
1370
+ // src/configs/perfectionist.ts
1371
+ async function perfectionist() {
1372
+ return [
1373
+ {
1374
+ name: "coderwyd:perfectionist",
1375
+ plugins: {
1376
+ perfectionist: import_eslint_plugin_perfectionist.default
1377
+ }
1378
+ }
1379
+ ];
1380
+ }
1381
+
1426
1382
  // src/configs/react.ts
1427
- var import_globals2 = __toESM(require("globals"), 1);
1428
- function react(options = {}) {
1383
+ var import_local_pkg2 = require("local-pkg");
1384
+ var ReactRefreshAllowConstantExportPackages = [
1385
+ "vite"
1386
+ ];
1387
+ async function react(options = {}) {
1429
1388
  const {
1389
+ files = [GLOB_JSX, GLOB_TSX],
1430
1390
  overrides = {},
1431
- stylistic: stylistic2 = true
1391
+ typescript: typescript2 = true
1432
1392
  } = options;
1433
- const {
1434
- indent = 2
1435
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1436
- const extensions = [GLOB_JSX, ...[options.typescript ? GLOB_TSX : ""]];
1393
+ await ensurePackages([
1394
+ "eslint-plugin-react",
1395
+ "eslint-plugin-react-hooks",
1396
+ "eslint-plugin-react-refresh"
1397
+ ]);
1398
+ const [
1399
+ pluginReact,
1400
+ pluginReactHooks,
1401
+ pluginReactRefresh
1402
+ ] = await Promise.all([
1403
+ interopDefault(import("eslint-plugin-react")),
1404
+ interopDefault(import("eslint-plugin-react-hooks")),
1405
+ interopDefault(import("eslint-plugin-react-refresh"))
1406
+ ]);
1407
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1408
+ (i) => (0, import_local_pkg2.isPackageExists)(i)
1409
+ );
1437
1410
  return [
1438
1411
  {
1439
1412
  name: "coderwyd:react:setup",
1440
1413
  plugins: {
1441
- "react": import_eslint_plugin_react.default,
1442
- "react-hooks": import_eslint_plugin_react_hooks.default
1443
- },
1444
- settings: {
1445
- "import/extensions": extensions,
1446
- "import/resolver": {
1447
- node: { extensions }
1448
- },
1449
- "react": {
1450
- version: "detect"
1451
- }
1414
+ "react": pluginReact,
1415
+ "react-hooks": pluginReactHooks,
1416
+ "react-refresh": pluginReactRefresh
1452
1417
  }
1453
1418
  },
1454
1419
  {
1455
- files: [GLOB_JSX, ...[options.typescript ? GLOB_TSX : ""]],
1420
+ files,
1456
1421
  languageOptions: {
1457
- globals: import_globals2.default.browser,
1458
1422
  parserOptions: {
1459
1423
  ecmaFeatures: {
1460
1424
  jsx: true
1461
- },
1462
- // for @typescript/eslint-parser
1463
- jsxPragma: void 0,
1464
- // FIXME: @typescript-eslint v6 throws deprecation warnings
1465
- // See https://github.com/jsx-eslint/eslint-plugin-react/issues/3602
1466
- // Remove this when they support typescript 5.2
1467
- suppressDeprecatedPropertyWarnings: true
1425
+ }
1468
1426
  }
1469
1427
  },
1470
1428
  name: "coderwyd:react:rules",
1471
1429
  rules: {
1472
- ...import_eslint_plugin_react.default.configs.recommended.rules,
1473
- ...import_eslint_plugin_react_hooks.default.configs.recommended.rules,
1474
- "node/prefer-global/process": OFF,
1475
- "react/display-name": ["off", { ignoreTranspilerName: false }],
1476
- "react/iframe-missing-sandbox": "warn",
1477
- "react/jsx-curly-brace-presence": ["error", { children: "never", props: "never" }],
1478
- "react/no-unknown-property": ["error", {
1479
- ignore: [
1480
- // SVG
1481
- "clip-path",
1482
- "clip-rule",
1483
- "fill-opacity",
1484
- "fill-rule",
1485
- "stroke-dasharray",
1486
- "stroke-dashoffset",
1487
- "stroke-linecap",
1488
- "stroke-linejoin",
1489
- "stroke-miterlimit",
1490
- "stroke-opacity",
1491
- "stroke-width"
1492
- ]
1493
- }],
1494
- "react/no-unused-class-component-methods": "error",
1495
- "react/no-unused-state": "error",
1496
- "react/prop-types": "off",
1430
+ // recommended rules react-hooks
1431
+ "react-hooks/exhaustive-deps": "warn",
1432
+ "react-hooks/rules-of-hooks": "error",
1433
+ // react refresh
1434
+ "react-refresh/only-export-components": [
1435
+ "warn",
1436
+ { allowConstantExport: isAllowConstantExport }
1437
+ ],
1438
+ // recommended rules react
1439
+ "react/display-name": "error",
1440
+ "react/jsx-key": "error",
1441
+ "react/jsx-no-comment-textnodes": "error",
1442
+ "react/jsx-no-duplicate-props": "error",
1443
+ "react/jsx-no-target-blank": "error",
1444
+ "react/jsx-no-undef": "error",
1445
+ "react/jsx-uses-react": "error",
1446
+ "react/jsx-uses-vars": "error",
1447
+ "react/no-children-prop": "error",
1448
+ "react/no-danger-with-children": "error",
1449
+ "react/no-deprecated": "error",
1450
+ "react/no-direct-mutation-state": "error",
1451
+ "react/no-find-dom-node": "error",
1452
+ "react/no-is-mounted": "error",
1453
+ "react/no-render-return-value": "error",
1454
+ "react/no-string-refs": "error",
1455
+ "react/no-unescaped-entities": "error",
1456
+ "react/no-unknown-property": "error",
1457
+ "react/no-unsafe": "off",
1458
+ "react/prop-types": "error",
1497
1459
  "react/react-in-jsx-scope": "off",
1498
- ...stylistic2 ? {
1499
- "react/jsx-boolean-value": ["error", "never", { always: [] }],
1500
- "react/jsx-closing-bracket-location": ["error", "tag-aligned"],
1501
- "react/jsx-curly-newline": ["error", {
1502
- multiline: "consistent",
1503
- singleline: "consistent"
1504
- }],
1505
- "react/jsx-curly-spacing": ["error", "never", { allowMultiline: true }],
1506
- "react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
1507
- "react/jsx-fragments": ["error", "syntax"],
1508
- "react/jsx-indent": ["error", indent, { checkAttributes: false, indentLogicalExpressions: true }],
1509
- "react/jsx-indent-props": ["error", indent],
1510
- "react/jsx-max-props-per-line": ["error", { maximum: 1, when: "multiline" }],
1511
- "react/jsx-no-useless-fragment": "error",
1512
- "react/jsx-props-no-multi-spaces": "error",
1513
- "react/jsx-tag-spacing": ["error", {
1514
- afterOpening: "never",
1515
- beforeClosing: "never",
1516
- beforeSelfClosing: "always",
1517
- closingSlash: "never"
1518
- }],
1519
- "react/jsx-wrap-multilines": ["error", {
1520
- arrow: "parens-new-line",
1521
- assignment: "parens-new-line",
1522
- condition: "parens-new-line",
1523
- declaration: "parens-new-line",
1524
- logical: "parens-new-line",
1525
- prop: "parens-new-line",
1526
- return: "parens-new-line"
1527
- }],
1528
- "react/sort-comp": ["error", {
1529
- groups: {
1530
- lifecycle: [
1531
- "displayName",
1532
- "propTypes",
1533
- "contextTypes",
1534
- "childContextTypes",
1535
- "mixins",
1536
- "statics",
1537
- "defaultProps",
1538
- "constructor",
1539
- "getDefaultProps",
1540
- "getInitialState",
1541
- "state",
1542
- "getChildContext",
1543
- "getDerivedStateFromProps",
1544
- "componentWillMount",
1545
- "UNSAFE_componentWillMount",
1546
- "componentDidMount",
1547
- "componentWillReceiveProps",
1548
- "UNSAFE_componentWillReceiveProps",
1549
- "shouldComponentUpdate",
1550
- "componentWillUpdate",
1551
- "UNSAFE_componentWillUpdate",
1552
- "getSnapshotBeforeUpdate",
1553
- "componentDidUpdate",
1554
- "componentDidCatch",
1555
- "componentWillUnmount"
1556
- ],
1557
- rendering: [
1558
- "/^render.+$/",
1559
- "render"
1560
- ]
1561
- },
1562
- order: [
1563
- "static-variables",
1564
- "static-methods",
1565
- "instance-variables",
1566
- "lifecycle",
1567
- "/^handle.+$/",
1568
- "/^on.+$/",
1569
- "getters",
1570
- "setters",
1571
- "/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/",
1572
- "instance-methods",
1573
- "everything-else",
1574
- "rendering"
1575
- ]
1576
- }],
1577
- "react/style-prop-object": "error",
1578
- "style/indent": ["error", indent, {
1579
- SwitchCase: 1,
1580
- VariableDeclarator: 1,
1581
- // from: https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
1582
- ignoredNodes: [
1583
- "JSXElement",
1584
- "JSXElement :not(JSXExpressionContainer, JSXExpressionContainer *)",
1585
- "JSXAttribute",
1586
- "JSXIdentifier",
1587
- "JSXNamespacedName",
1588
- "JSXMemberExpression",
1589
- "JSXSpreadAttribute",
1590
- "JSXOpeningElement",
1591
- "JSXClosingElement",
1592
- "JSXFragment",
1593
- "JSXOpeningFragment",
1594
- "JSXClosingFragment",
1595
- "JSXText",
1596
- "JSXEmptyExpression",
1597
- "JSXSpreadChild"
1598
- ],
1599
- offsetTernaryExpressions: true,
1600
- outerIIFEBody: 1
1601
- }],
1602
- "style/jsx-quotes": ["error", "prefer-double"]
1460
+ "react/require-render-return": "error",
1461
+ ...typescript2 ? {
1462
+ "react/jsx-no-undef": "off",
1463
+ "react/prop-type": "off"
1603
1464
  } : {},
1465
+ // overrides
1604
1466
  ...overrides
1605
1467
  }
1606
1468
  }
1607
1469
  ];
1608
1470
  }
1609
1471
 
1610
- // src/configs/astro.ts
1611
- function astro(options = {}) {
1612
- const { overrides = {} } = options;
1472
+ // src/configs/unocss.ts
1473
+ async function unocss(options = {}) {
1474
+ const {
1475
+ attributify = true,
1476
+ strict = false
1477
+ } = options;
1478
+ await ensurePackages([
1479
+ "@unocss/eslint-plugin"
1480
+ ]);
1481
+ const [
1482
+ pluginUnoCSS
1483
+ ] = await Promise.all([
1484
+ interopDefault(import("@unocss/eslint-plugin"))
1485
+ ]);
1613
1486
  return [
1614
1487
  {
1615
- files: [GLOB_ASTRO],
1616
- languageOptions: {
1617
- parser: import_astro_eslint_parser.default,
1618
- parserOptions: {
1619
- extraFileExtensions: [".astro"],
1620
- parser: options.typescript ? parserTs : null
1621
- }
1622
- },
1623
- name: "coderwyd:astro",
1488
+ name: "antfu:unocss",
1624
1489
  plugins: {
1625
- astro: import_eslint_plugin_astro.default
1490
+ unocss: pluginUnoCSS
1626
1491
  },
1627
1492
  rules: {
1628
- ...import_eslint_plugin_astro.default.configs.recommended.rules,
1629
- ...overrides
1493
+ "unocss/order": "warn",
1494
+ ...attributify ? {
1495
+ "unocss/order-attributify": "warn"
1496
+ } : {},
1497
+ ...strict ? {
1498
+ "unocss/blocklist": "error"
1499
+ } : {}
1630
1500
  }
1631
1501
  }
1632
1502
  ];
@@ -1649,46 +1519,46 @@ var VuePackages = [
1649
1519
  "vitepress",
1650
1520
  "@slidev/cli"
1651
1521
  ];
1652
- var ReactPackages = [
1653
- "react",
1654
- "next"
1655
- ];
1656
- var AstroPackages = [
1657
- "astro"
1658
- ];
1659
- function coderwyd(options = {}, ...userConfigs) {
1522
+ async function coderwyd(options = {}, ...userConfigs) {
1660
1523
  const {
1661
- isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
1662
- vue: enableVue = VuePackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
1663
- react: enableReact = ReactPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
1664
- astro: enableAstro = AstroPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
1665
- typescript: enableTypeScript = (0, import_local_pkg2.isPackageExists)("typescript"),
1666
- stylistic: enableStylistic = true,
1524
+ componentExts = [],
1667
1525
  gitignore: enableGitignore = true,
1526
+ isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
1668
1527
  overrides = {},
1669
- componentExts = []
1528
+ react: enableReact = false,
1529
+ typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
1530
+ unocss: enableUnoCSS = false,
1531
+ vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
1670
1532
  } = options;
1533
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1534
+ if (stylisticOptions && !("jsx" in stylisticOptions))
1535
+ stylisticOptions.jsx = options.jsx ?? true;
1671
1536
  const configs = [];
1672
1537
  if (enableGitignore) {
1673
1538
  if (typeof enableGitignore !== "boolean") {
1674
- configs.push([(0, import_eslint_config_flat_gitignore.default)(enableGitignore)]);
1539
+ configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1675
1540
  } else {
1676
1541
  if (import_node_fs.default.existsSync(".gitignore"))
1677
- configs.push([(0, import_eslint_config_flat_gitignore.default)()]);
1542
+ configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
1678
1543
  }
1679
1544
  }
1680
1545
  configs.push(
1681
1546
  ignores(),
1682
- javascript({ isInEditor }),
1547
+ javascript({
1548
+ isInEditor,
1549
+ overrides: overrides.javascript
1550
+ }),
1683
1551
  comments(),
1684
1552
  node(),
1685
1553
  jsdoc({
1686
- stylistic: enableStylistic
1554
+ stylistic: stylisticOptions
1687
1555
  }),
1688
1556
  imports({
1689
- stylistic: enableStylistic
1557
+ stylistic: stylisticOptions
1690
1558
  }),
1691
- unicorn()
1559
+ unicorn(),
1560
+ // Optional plugins (installed but not enabled by default)
1561
+ perfectionist()
1692
1562
  );
1693
1563
  if (enableVue)
1694
1564
  componentExts.push("vue");
@@ -1699,17 +1569,18 @@ function coderwyd(options = {}, ...userConfigs) {
1699
1569
  overrides: overrides.typescript
1700
1570
  }));
1701
1571
  }
1702
- if (enableStylistic) {
1703
- configs.push(stylistic(
1704
- typeof enableStylistic === "boolean" ? {} : enableStylistic
1705
- ));
1572
+ if (stylisticOptions)
1573
+ configs.push(stylistic(stylisticOptions));
1574
+ if (options.test ?? true) {
1575
+ configs.push(test({
1576
+ isInEditor,
1577
+ overrides: overrides.test
1578
+ }));
1706
1579
  }
1707
- if (options.test ?? true)
1708
- configs.push(test({ isInEditor, overrides: overrides.test }));
1709
1580
  if (enableVue) {
1710
1581
  configs.push(vue({
1711
1582
  overrides: overrides.vue,
1712
- stylistic: enableStylistic,
1583
+ stylistic: stylisticOptions,
1713
1584
  typescript: !!enableTypeScript
1714
1585
  }));
1715
1586
  }
@@ -1719,15 +1590,17 @@ function coderwyd(options = {}, ...userConfigs) {
1719
1590
  typescript: !!enableTypeScript
1720
1591
  }));
1721
1592
  }
1722
- if (enableAstro) {
1723
- configs.push(astro({
1724
- overrides: overrides.astro,
1725
- typescript: !!enableTypeScript
1726
- }));
1593
+ if (enableUnoCSS) {
1594
+ configs.push(unocss(
1595
+ typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1596
+ ));
1727
1597
  }
1728
1598
  if (options.jsonc ?? true) {
1729
1599
  configs.push(
1730
- jsonc(),
1600
+ jsonc({
1601
+ overrides: overrides.jsonc,
1602
+ stylistic: stylisticOptions
1603
+ }),
1731
1604
  sortPackageJson(),
1732
1605
  sortTsconfig()
1733
1606
  );
@@ -1735,11 +1608,15 @@ function coderwyd(options = {}, ...userConfigs) {
1735
1608
  if (options.yaml ?? true) {
1736
1609
  configs.push(yaml({
1737
1610
  overrides: overrides.yaml,
1738
- stylistic: enableStylistic
1611
+ stylistic: stylisticOptions
1612
+ }));
1613
+ }
1614
+ if (options.markdown ?? true) {
1615
+ configs.push(markdown({
1616
+ componentExts,
1617
+ overrides: overrides.markdown
1739
1618
  }));
1740
1619
  }
1741
- if (options.markdown ?? true)
1742
- configs.push(markdown({ componentExts, overrides: overrides.markdown }));
1743
1620
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1744
1621
  if (key in options)
1745
1622
  acc[key] = options[key];
@@ -1759,7 +1636,6 @@ var src_default = coderwyd;
1759
1636
  // Annotate the CommonJS export names for ESM import in node:
1760
1637
  0 && (module.exports = {
1761
1638
  GLOB_ALL_SRC,
1762
- GLOB_ASTRO,
1763
1639
  GLOB_CSS,
1764
1640
  GLOB_EXCLUDE,
1765
1641
  GLOB_HTML,
@@ -1780,49 +1656,30 @@ var src_default = coderwyd;
1780
1656
  GLOB_TSX,
1781
1657
  GLOB_VUE,
1782
1658
  GLOB_YAML,
1783
- astro,
1784
1659
  coderwyd,
1785
1660
  combine,
1786
1661
  comments,
1662
+ ensurePackages,
1787
1663
  getVueVersion,
1788
1664
  ignores,
1789
1665
  imports,
1666
+ interopDefault,
1790
1667
  javascript,
1791
1668
  jsdoc,
1792
1669
  jsonc,
1793
1670
  markdown,
1794
1671
  node,
1795
- parserAstro,
1796
- parserJsonc,
1797
- parserTs,
1798
- parserVue,
1799
- parserYaml,
1800
- pluginAntfu,
1801
- pluginAstro,
1802
- pluginComments,
1803
- pluginImport,
1804
- pluginJsdoc,
1805
- pluginJsonc,
1806
- pluginMarkdown,
1807
- pluginNoOnlyTests,
1808
- pluginNode,
1809
- pluginReact,
1810
- pluginReactHooks,
1811
- pluginStylistic,
1812
- pluginTs,
1813
- pluginUnicorn,
1814
- pluginUnusedImports,
1815
- pluginVitest,
1816
- pluginVue,
1817
- pluginYaml,
1672
+ perfectionist,
1818
1673
  react,
1819
1674
  renameRules,
1820
1675
  sortPackageJson,
1821
1676
  sortTsconfig,
1822
1677
  stylistic,
1823
1678
  test,
1679
+ toArray,
1824
1680
  typescript,
1825
1681
  unicorn,
1682
+ unocss,
1826
1683
  vue,
1827
1684
  yaml
1828
1685
  });