@coderwyd/eslint-config 1.1.0-beta.3 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/bin/index.js +3 -0
- package/dist/cli.cjs +268 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +239 -0
- package/dist/index.cjs +414 -556
- package/dist/index.d.cts +116 -131
- package/dist/index.d.ts +116 -131
- package/dist/index.js +415 -537
- package/package.json +75 -41
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
|
-
|
|
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
|
|
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
|
|
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 ?
|
|
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":
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
548
|
+
files,
|
|
531
549
|
languageOptions: {
|
|
532
|
-
parser:
|
|
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
|
-
|
|
609
|
+
// @ts-expect-error missing types
|
|
610
|
+
markdown: await interopDefault(import("eslint-plugin-markdown"))
|
|
591
611
|
}
|
|
592
612
|
},
|
|
593
613
|
{
|
|
594
|
-
files
|
|
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-
|
|
613
|
-
"
|
|
614
|
-
"no-alert":
|
|
615
|
-
"no-console":
|
|
616
|
-
"no-
|
|
617
|
-
"no-
|
|
618
|
-
"no-
|
|
619
|
-
"
|
|
620
|
-
"
|
|
621
|
-
"
|
|
622
|
-
"
|
|
623
|
-
"
|
|
624
|
-
"
|
|
625
|
-
"
|
|
626
|
-
"ts/
|
|
627
|
-
"ts/no-
|
|
628
|
-
"ts/no-
|
|
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":
|
|
631
|
-
"unused-imports/no-unused-vars":
|
|
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":
|
|
635
|
-
"ts/dot-notation":
|
|
636
|
-
"ts/no-floating-promises":
|
|
637
|
-
"ts/no-for-in-array":
|
|
638
|
-
"ts/no-implied-eval":
|
|
639
|
-
"ts/no-misused-promises":
|
|
640
|
-
"ts/no-throw-literal":
|
|
641
|
-
"ts/no-unnecessary-type-assertion":
|
|
642
|
-
"ts/no-unsafe-argument":
|
|
643
|
-
"ts/no-unsafe-assignment":
|
|
644
|
-
"ts/no-unsafe-call":
|
|
645
|
-
"ts/no-unsafe-member-access":
|
|
646
|
-
"ts/no-unsafe-return":
|
|
647
|
-
"ts/restrict-plus-operands":
|
|
648
|
-
"ts/restrict-template-expressions":
|
|
649
|
-
"ts/unbound-method":
|
|
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
|
-
|
|
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:
|
|
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
|
|
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
|
-
|
|
1045
|
-
|
|
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":
|
|
1048
|
-
"no-implied-eval":
|
|
1049
|
-
"no-throw-literal":
|
|
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
|
-
|
|
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:
|
|
1088
|
-
tsconfigRootDir:
|
|
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
|
-
|
|
1022
|
+
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1097
1023
|
"@typescript-eslint/",
|
|
1098
1024
|
"ts/"
|
|
1099
1025
|
),
|
|
1100
1026
|
...renameRules(
|
|
1101
|
-
|
|
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
|
-
"
|
|
1108
|
-
"no-
|
|
1109
|
-
"no-
|
|
1110
|
-
"no-
|
|
1111
|
-
"no-
|
|
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":
|
|
1120
|
-
"ts/no-explicit-any":
|
|
1121
|
-
"ts/no-extraneous-class":
|
|
1122
|
-
"ts/no-
|
|
1123
|
-
"ts/no-invalid-void-type":
|
|
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":
|
|
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":
|
|
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":
|
|
1054
|
+
"ts/no-useless-constructor": "off",
|
|
1131
1055
|
"ts/prefer-ts-expect-error": "error",
|
|
1132
|
-
"ts/triple-slash-reference":
|
|
1133
|
-
"ts/unified-signatures":
|
|
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":
|
|
1143
|
-
"import/no-duplicates":
|
|
1144
|
-
"no-restricted-syntax":
|
|
1145
|
-
"unused-imports/no-unused-vars":
|
|
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:
|
|
1073
|
+
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1150
1074
|
name: "coderwyd:typescript:tests-overrides",
|
|
1151
1075
|
rules: {
|
|
1152
|
-
"no-unused-expressions":
|
|
1076
|
+
"no-unused-expressions": "off"
|
|
1153
1077
|
}
|
|
1154
1078
|
},
|
|
1155
1079
|
{
|
|
1156
|
-
files: [
|
|
1080
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
1157
1081
|
name: "coderwyd:typescript:javascript-overrides",
|
|
1158
1082
|
rules: {
|
|
1159
|
-
"ts/no-require-imports":
|
|
1160
|
-
"ts/no-var-requires":
|
|
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",
|
|
@@ -1172,6 +1096,7 @@ function unicorn() {
|
|
|
1172
1096
|
unicorn: import_eslint_plugin_unicorn.default
|
|
1173
1097
|
},
|
|
1174
1098
|
rules: {
|
|
1099
|
+
"unicorn/better-regex": "error",
|
|
1175
1100
|
// Pass error message when throwing errors
|
|
1176
1101
|
"unicorn/error-message": "error",
|
|
1177
1102
|
// Uppercase regex escapes
|
|
@@ -1204,60 +1129,61 @@ function unicorn() {
|
|
|
1204
1129
|
}
|
|
1205
1130
|
|
|
1206
1131
|
// src/configs/vue.ts
|
|
1207
|
-
|
|
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 = {}) {
|
|
1132
|
+
async function vue(options = {}) {
|
|
1229
1133
|
const {
|
|
1134
|
+
files = [GLOB_VUE],
|
|
1230
1135
|
overrides = {},
|
|
1231
1136
|
stylistic: stylistic2 = true
|
|
1232
1137
|
} = options;
|
|
1233
1138
|
const {
|
|
1234
1139
|
indent = 2
|
|
1235
1140
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1141
|
+
const isVue3 = getVueVersion() === 3;
|
|
1142
|
+
const [
|
|
1143
|
+
pluginVue,
|
|
1144
|
+
parserVue
|
|
1145
|
+
] = await Promise.all([
|
|
1146
|
+
// @ts-expect-error missing types
|
|
1147
|
+
interopDefault(import("eslint-plugin-vue")),
|
|
1148
|
+
interopDefault(import("vue-eslint-parser"))
|
|
1149
|
+
]);
|
|
1150
|
+
const vue3Rules = {
|
|
1151
|
+
...pluginVue.configs.base.rules,
|
|
1152
|
+
...pluginVue.configs["vue3-essential"].rules,
|
|
1153
|
+
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1154
|
+
...pluginVue.configs["vue3-recommended"].rules
|
|
1155
|
+
};
|
|
1156
|
+
const vue2Rules = {
|
|
1157
|
+
...pluginVue.configs.base.rules,
|
|
1158
|
+
...pluginVue.configs.essential.rules,
|
|
1159
|
+
...pluginVue.configs["strongly-recommended"].rules,
|
|
1160
|
+
...pluginVue.configs.recommended.rules
|
|
1161
|
+
};
|
|
1236
1162
|
return [
|
|
1237
1163
|
{
|
|
1238
1164
|
name: "coderwyd:vue:setup",
|
|
1239
1165
|
plugins: {
|
|
1240
|
-
vue:
|
|
1166
|
+
vue: pluginVue
|
|
1241
1167
|
}
|
|
1242
1168
|
},
|
|
1243
1169
|
{
|
|
1244
|
-
files
|
|
1170
|
+
files,
|
|
1245
1171
|
languageOptions: {
|
|
1246
|
-
parser:
|
|
1172
|
+
parser: parserVue,
|
|
1247
1173
|
parserOptions: {
|
|
1248
1174
|
ecmaFeatures: {
|
|
1249
1175
|
jsx: true
|
|
1250
1176
|
},
|
|
1251
1177
|
extraFileExtensions: [".vue"],
|
|
1252
|
-
parser: options.typescript ?
|
|
1178
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1253
1179
|
sourceType: "module"
|
|
1254
1180
|
}
|
|
1255
1181
|
},
|
|
1256
1182
|
name: "coderwyd:vue:rules",
|
|
1257
|
-
processor:
|
|
1183
|
+
processor: pluginVue.processors[".vue"],
|
|
1258
1184
|
rules: {
|
|
1259
1185
|
...isVue3 ? vue3Rules : vue2Rules,
|
|
1260
|
-
"node/prefer-global/process":
|
|
1186
|
+
"node/prefer-global/process": "off",
|
|
1261
1187
|
"vue/block-order": ["error", {
|
|
1262
1188
|
order: ["script", "template", "style"]
|
|
1263
1189
|
}],
|
|
@@ -1272,9 +1198,9 @@ function vue(options = {}) {
|
|
|
1272
1198
|
"vue/eqeqeq": ["error", "smart"],
|
|
1273
1199
|
"vue/html-indent": ["error", indent],
|
|
1274
1200
|
"vue/html-quotes": ["error", "double"],
|
|
1275
|
-
"vue/max-attributes-per-line":
|
|
1276
|
-
"vue/multi-word-component-names":
|
|
1277
|
-
"vue/no-dupe-keys":
|
|
1201
|
+
"vue/max-attributes-per-line": "off",
|
|
1202
|
+
"vue/multi-word-component-names": "off",
|
|
1203
|
+
"vue/no-dupe-keys": "off",
|
|
1278
1204
|
"vue/no-empty-pattern": "error",
|
|
1279
1205
|
"vue/no-extra-parens": ["error", "functions"],
|
|
1280
1206
|
"vue/no-irregular-whitespace": "error",
|
|
@@ -1286,11 +1212,11 @@ function vue(options = {}) {
|
|
|
1286
1212
|
"WithStatement"
|
|
1287
1213
|
],
|
|
1288
1214
|
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1289
|
-
"vue/no-setup-props-reactivity-loss":
|
|
1215
|
+
"vue/no-setup-props-reactivity-loss": "off",
|
|
1290
1216
|
"vue/no-sparse-arrays": "error",
|
|
1291
1217
|
"vue/no-unused-refs": "error",
|
|
1292
1218
|
"vue/no-useless-v-bind": "error",
|
|
1293
|
-
"vue/no-v-html":
|
|
1219
|
+
"vue/no-v-html": "off",
|
|
1294
1220
|
"vue/object-shorthand": [
|
|
1295
1221
|
"error",
|
|
1296
1222
|
"always",
|
|
@@ -1301,8 +1227,9 @@ function vue(options = {}) {
|
|
|
1301
1227
|
],
|
|
1302
1228
|
"vue/prefer-separate-static-class": "error",
|
|
1303
1229
|
"vue/prefer-template": "error",
|
|
1304
|
-
"vue/
|
|
1305
|
-
"vue/require-prop
|
|
1230
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
1231
|
+
"vue/require-default-prop": "off",
|
|
1232
|
+
"vue/require-prop-types": "off",
|
|
1306
1233
|
"vue/space-infix-ops": "error",
|
|
1307
1234
|
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
1308
1235
|
...stylistic2 ? {
|
|
@@ -1322,7 +1249,7 @@ function vue(options = {}) {
|
|
|
1322
1249
|
}],
|
|
1323
1250
|
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
1324
1251
|
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1325
|
-
"vue/object-curly-newline":
|
|
1252
|
+
"vue/object-curly-newline": "off",
|
|
1326
1253
|
"vue/object-curly-spacing": ["error", "always"],
|
|
1327
1254
|
"vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
1328
1255
|
"vue/operator-linebreak": ["error", "before"],
|
|
@@ -1338,8 +1265,9 @@ function vue(options = {}) {
|
|
|
1338
1265
|
}
|
|
1339
1266
|
|
|
1340
1267
|
// src/configs/yaml.ts
|
|
1341
|
-
function yaml(options = {}) {
|
|
1268
|
+
async function yaml(options = {}) {
|
|
1342
1269
|
const {
|
|
1270
|
+
files = [GLOB_YAML],
|
|
1343
1271
|
overrides = {},
|
|
1344
1272
|
stylistic: stylistic2 = true
|
|
1345
1273
|
} = options;
|
|
@@ -1347,6 +1275,13 @@ function yaml(options = {}) {
|
|
|
1347
1275
|
indent = 2,
|
|
1348
1276
|
quotes = "single"
|
|
1349
1277
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1278
|
+
const [
|
|
1279
|
+
pluginYaml,
|
|
1280
|
+
parserYaml
|
|
1281
|
+
] = await Promise.all([
|
|
1282
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
1283
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1284
|
+
]);
|
|
1350
1285
|
return [
|
|
1351
1286
|
{
|
|
1352
1287
|
name: "coderwyd:yaml:setup",
|
|
@@ -1355,13 +1290,13 @@ function yaml(options = {}) {
|
|
|
1355
1290
|
}
|
|
1356
1291
|
},
|
|
1357
1292
|
{
|
|
1358
|
-
files
|
|
1293
|
+
files,
|
|
1359
1294
|
languageOptions: {
|
|
1360
|
-
parser:
|
|
1295
|
+
parser: parserYaml
|
|
1361
1296
|
},
|
|
1362
1297
|
name: "coderwyd:yaml:rules",
|
|
1363
1298
|
rules: {
|
|
1364
|
-
"style/spaced-comment":
|
|
1299
|
+
"style/spaced-comment": "off",
|
|
1365
1300
|
"yaml/block-mapping": "error",
|
|
1366
1301
|
"yaml/block-sequence": "error",
|
|
1367
1302
|
"yaml/no-empty-key": "error",
|
|
@@ -1389,32 +1324,42 @@ function yaml(options = {}) {
|
|
|
1389
1324
|
}
|
|
1390
1325
|
|
|
1391
1326
|
// src/configs/test.ts
|
|
1392
|
-
function test(options = {}) {
|
|
1327
|
+
async function test(options = {}) {
|
|
1393
1328
|
const {
|
|
1329
|
+
files = GLOB_TESTS,
|
|
1394
1330
|
isInEditor = false,
|
|
1395
1331
|
overrides = {}
|
|
1396
1332
|
} = options;
|
|
1333
|
+
const [
|
|
1334
|
+
pluginVitest,
|
|
1335
|
+
pluginNoOnlyTests
|
|
1336
|
+
] = await Promise.all([
|
|
1337
|
+
interopDefault(import("eslint-plugin-vitest")),
|
|
1338
|
+
// @ts-expect-error missing types
|
|
1339
|
+
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1340
|
+
]);
|
|
1397
1341
|
return [
|
|
1398
1342
|
{
|
|
1399
1343
|
name: "coderwyd:test:setup",
|
|
1400
1344
|
plugins: {
|
|
1401
1345
|
test: {
|
|
1402
|
-
...
|
|
1346
|
+
...pluginVitest,
|
|
1403
1347
|
rules: {
|
|
1404
|
-
...
|
|
1348
|
+
...pluginVitest.rules,
|
|
1405
1349
|
// extend `test/no-only-tests` rule
|
|
1406
|
-
...
|
|
1350
|
+
...pluginNoOnlyTests.rules
|
|
1407
1351
|
}
|
|
1408
1352
|
}
|
|
1409
1353
|
}
|
|
1410
1354
|
},
|
|
1411
1355
|
{
|
|
1412
|
-
files
|
|
1356
|
+
files,
|
|
1413
1357
|
name: "coderwyd:test:rules",
|
|
1414
1358
|
rules: {
|
|
1359
|
+
"node/prefer-global/process": "off",
|
|
1415
1360
|
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1416
1361
|
"test/no-identical-title": "error",
|
|
1417
|
-
"test/no-only-tests": isInEditor ?
|
|
1362
|
+
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
1418
1363
|
"test/prefer-hooks-in-order": "error",
|
|
1419
1364
|
"test/prefer-lowercase-title": "error",
|
|
1420
1365
|
...overrides
|
|
@@ -1423,210 +1368,136 @@ function test(options = {}) {
|
|
|
1423
1368
|
];
|
|
1424
1369
|
}
|
|
1425
1370
|
|
|
1371
|
+
// src/configs/perfectionist.ts
|
|
1372
|
+
async function perfectionist() {
|
|
1373
|
+
return [
|
|
1374
|
+
{
|
|
1375
|
+
name: "coderwyd:perfectionist",
|
|
1376
|
+
plugins: {
|
|
1377
|
+
perfectionist: import_eslint_plugin_perfectionist.default
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
];
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1426
1383
|
// src/configs/react.ts
|
|
1427
|
-
var
|
|
1428
|
-
|
|
1384
|
+
var import_local_pkg2 = require("local-pkg");
|
|
1385
|
+
var ReactRefreshAllowConstantExportPackages = [
|
|
1386
|
+
"vite"
|
|
1387
|
+
];
|
|
1388
|
+
async function react(options = {}) {
|
|
1429
1389
|
const {
|
|
1390
|
+
files = [GLOB_JSX, GLOB_TSX],
|
|
1430
1391
|
overrides = {},
|
|
1431
|
-
|
|
1392
|
+
typescript: typescript2 = true
|
|
1432
1393
|
} = options;
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1394
|
+
await ensurePackages([
|
|
1395
|
+
"eslint-plugin-react",
|
|
1396
|
+
"eslint-plugin-react-hooks",
|
|
1397
|
+
"eslint-plugin-react-refresh"
|
|
1398
|
+
]);
|
|
1399
|
+
const [
|
|
1400
|
+
pluginReact,
|
|
1401
|
+
pluginReactHooks,
|
|
1402
|
+
pluginReactRefresh
|
|
1403
|
+
] = await Promise.all([
|
|
1404
|
+
interopDefault(import("eslint-plugin-react")),
|
|
1405
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1406
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1407
|
+
]);
|
|
1408
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1409
|
+
(i) => (0, import_local_pkg2.isPackageExists)(i)
|
|
1410
|
+
);
|
|
1437
1411
|
return [
|
|
1438
1412
|
{
|
|
1439
1413
|
name: "coderwyd:react:setup",
|
|
1440
1414
|
plugins: {
|
|
1441
|
-
"react":
|
|
1442
|
-
"react-hooks":
|
|
1443
|
-
|
|
1444
|
-
settings: {
|
|
1445
|
-
"import/extensions": extensions,
|
|
1446
|
-
"import/resolver": {
|
|
1447
|
-
node: { extensions }
|
|
1448
|
-
},
|
|
1449
|
-
"react": {
|
|
1450
|
-
version: "detect"
|
|
1451
|
-
}
|
|
1415
|
+
"react": pluginReact,
|
|
1416
|
+
"react-hooks": pluginReactHooks,
|
|
1417
|
+
"react-refresh": pluginReactRefresh
|
|
1452
1418
|
}
|
|
1453
1419
|
},
|
|
1454
1420
|
{
|
|
1455
|
-
files
|
|
1421
|
+
files,
|
|
1456
1422
|
languageOptions: {
|
|
1457
|
-
globals: import_globals2.default.browser,
|
|
1458
1423
|
parserOptions: {
|
|
1459
1424
|
ecmaFeatures: {
|
|
1460
1425
|
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
|
|
1426
|
+
}
|
|
1468
1427
|
}
|
|
1469
1428
|
},
|
|
1470
1429
|
name: "coderwyd:react:rules",
|
|
1471
1430
|
rules: {
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
"
|
|
1475
|
-
|
|
1476
|
-
"react/
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
"react/no-
|
|
1495
|
-
"react/no-
|
|
1496
|
-
"react/
|
|
1431
|
+
// recommended rules react-hooks
|
|
1432
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
1433
|
+
"react-hooks/rules-of-hooks": "error",
|
|
1434
|
+
// react refresh
|
|
1435
|
+
"react-refresh/only-export-components": [
|
|
1436
|
+
"warn",
|
|
1437
|
+
{ allowConstantExport: isAllowConstantExport }
|
|
1438
|
+
],
|
|
1439
|
+
// recommended rules react
|
|
1440
|
+
"react/display-name": "error",
|
|
1441
|
+
"react/jsx-key": "error",
|
|
1442
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
1443
|
+
"react/jsx-no-duplicate-props": "error",
|
|
1444
|
+
"react/jsx-no-target-blank": "error",
|
|
1445
|
+
"react/jsx-no-undef": "error",
|
|
1446
|
+
"react/jsx-uses-react": "error",
|
|
1447
|
+
"react/jsx-uses-vars": "error",
|
|
1448
|
+
"react/no-children-prop": "error",
|
|
1449
|
+
"react/no-danger-with-children": "error",
|
|
1450
|
+
"react/no-deprecated": "error",
|
|
1451
|
+
"react/no-direct-mutation-state": "error",
|
|
1452
|
+
"react/no-find-dom-node": "error",
|
|
1453
|
+
"react/no-is-mounted": "error",
|
|
1454
|
+
"react/no-render-return-value": "error",
|
|
1455
|
+
"react/no-string-refs": "error",
|
|
1456
|
+
"react/no-unescaped-entities": "error",
|
|
1457
|
+
"react/no-unknown-property": "error",
|
|
1458
|
+
"react/no-unsafe": "off",
|
|
1459
|
+
"react/prop-types": "error",
|
|
1497
1460
|
"react/react-in-jsx-scope": "off",
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
"react/jsx-
|
|
1501
|
-
"react/
|
|
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"]
|
|
1461
|
+
"react/require-render-return": "error",
|
|
1462
|
+
...typescript2 ? {
|
|
1463
|
+
"react/jsx-no-undef": "off",
|
|
1464
|
+
"react/prop-type": "off"
|
|
1603
1465
|
} : {},
|
|
1466
|
+
// overrides
|
|
1604
1467
|
...overrides
|
|
1605
1468
|
}
|
|
1606
1469
|
}
|
|
1607
1470
|
];
|
|
1608
1471
|
}
|
|
1609
1472
|
|
|
1610
|
-
// src/configs/
|
|
1611
|
-
function
|
|
1612
|
-
const {
|
|
1473
|
+
// src/configs/unocss.ts
|
|
1474
|
+
async function unocss(options = {}) {
|
|
1475
|
+
const {
|
|
1476
|
+
attributify = true,
|
|
1477
|
+
strict = false
|
|
1478
|
+
} = options;
|
|
1479
|
+
await ensurePackages([
|
|
1480
|
+
"@unocss/eslint-plugin"
|
|
1481
|
+
]);
|
|
1482
|
+
const [
|
|
1483
|
+
pluginUnoCSS
|
|
1484
|
+
] = await Promise.all([
|
|
1485
|
+
interopDefault(import("@unocss/eslint-plugin"))
|
|
1486
|
+
]);
|
|
1613
1487
|
return [
|
|
1614
1488
|
{
|
|
1615
|
-
|
|
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",
|
|
1489
|
+
name: "coderwyd:unocss",
|
|
1624
1490
|
plugins: {
|
|
1625
|
-
|
|
1491
|
+
unocss: pluginUnoCSS
|
|
1626
1492
|
},
|
|
1627
1493
|
rules: {
|
|
1628
|
-
|
|
1629
|
-
...
|
|
1494
|
+
"unocss/order": "warn",
|
|
1495
|
+
...attributify ? {
|
|
1496
|
+
"unocss/order-attributify": "warn"
|
|
1497
|
+
} : {},
|
|
1498
|
+
...strict ? {
|
|
1499
|
+
"unocss/blocklist": "error"
|
|
1500
|
+
} : {}
|
|
1630
1501
|
}
|
|
1631
1502
|
}
|
|
1632
1503
|
];
|
|
@@ -1649,46 +1520,46 @@ var VuePackages = [
|
|
|
1649
1520
|
"vitepress",
|
|
1650
1521
|
"@slidev/cli"
|
|
1651
1522
|
];
|
|
1652
|
-
|
|
1653
|
-
"react",
|
|
1654
|
-
"next"
|
|
1655
|
-
];
|
|
1656
|
-
var AstroPackages = [
|
|
1657
|
-
"astro"
|
|
1658
|
-
];
|
|
1659
|
-
function coderwyd(options = {}, ...userConfigs) {
|
|
1523
|
+
async function coderwyd(options = {}, ...userConfigs) {
|
|
1660
1524
|
const {
|
|
1661
|
-
|
|
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,
|
|
1525
|
+
componentExts = [],
|
|
1667
1526
|
gitignore: enableGitignore = true,
|
|
1527
|
+
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
|
|
1668
1528
|
overrides = {},
|
|
1669
|
-
|
|
1529
|
+
react: enableReact = false,
|
|
1530
|
+
typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
|
|
1531
|
+
unocss: enableUnoCSS = false,
|
|
1532
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
|
|
1670
1533
|
} = options;
|
|
1534
|
+
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1535
|
+
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
1536
|
+
stylisticOptions.jsx = options.jsx ?? true;
|
|
1671
1537
|
const configs = [];
|
|
1672
1538
|
if (enableGitignore) {
|
|
1673
1539
|
if (typeof enableGitignore !== "boolean") {
|
|
1674
|
-
configs.push(
|
|
1540
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1675
1541
|
} else {
|
|
1676
1542
|
if (import_node_fs.default.existsSync(".gitignore"))
|
|
1677
|
-
configs.push(
|
|
1543
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
1678
1544
|
}
|
|
1679
1545
|
}
|
|
1680
1546
|
configs.push(
|
|
1681
1547
|
ignores(),
|
|
1682
|
-
javascript({
|
|
1548
|
+
javascript({
|
|
1549
|
+
isInEditor,
|
|
1550
|
+
overrides: overrides.javascript
|
|
1551
|
+
}),
|
|
1683
1552
|
comments(),
|
|
1684
1553
|
node(),
|
|
1685
1554
|
jsdoc({
|
|
1686
|
-
stylistic:
|
|
1555
|
+
stylistic: stylisticOptions
|
|
1687
1556
|
}),
|
|
1688
1557
|
imports({
|
|
1689
|
-
stylistic:
|
|
1558
|
+
stylistic: stylisticOptions
|
|
1690
1559
|
}),
|
|
1691
|
-
unicorn()
|
|
1560
|
+
unicorn(),
|
|
1561
|
+
// Optional plugins (installed but not enabled by default)
|
|
1562
|
+
perfectionist()
|
|
1692
1563
|
);
|
|
1693
1564
|
if (enableVue)
|
|
1694
1565
|
componentExts.push("vue");
|
|
@@ -1699,17 +1570,18 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1699
1570
|
overrides: overrides.typescript
|
|
1700
1571
|
}));
|
|
1701
1572
|
}
|
|
1702
|
-
if (
|
|
1703
|
-
configs.push(stylistic(
|
|
1704
|
-
|
|
1705
|
-
|
|
1573
|
+
if (stylisticOptions)
|
|
1574
|
+
configs.push(stylistic(stylisticOptions));
|
|
1575
|
+
if (options.test ?? true) {
|
|
1576
|
+
configs.push(test({
|
|
1577
|
+
isInEditor,
|
|
1578
|
+
overrides: overrides.test
|
|
1579
|
+
}));
|
|
1706
1580
|
}
|
|
1707
|
-
if (options.test ?? true)
|
|
1708
|
-
configs.push(test({ isInEditor, overrides: overrides.test }));
|
|
1709
1581
|
if (enableVue) {
|
|
1710
1582
|
configs.push(vue({
|
|
1711
1583
|
overrides: overrides.vue,
|
|
1712
|
-
stylistic:
|
|
1584
|
+
stylistic: stylisticOptions,
|
|
1713
1585
|
typescript: !!enableTypeScript
|
|
1714
1586
|
}));
|
|
1715
1587
|
}
|
|
@@ -1719,15 +1591,17 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1719
1591
|
typescript: !!enableTypeScript
|
|
1720
1592
|
}));
|
|
1721
1593
|
}
|
|
1722
|
-
if (
|
|
1723
|
-
configs.push(
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
}));
|
|
1594
|
+
if (enableUnoCSS) {
|
|
1595
|
+
configs.push(unocss(
|
|
1596
|
+
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1597
|
+
));
|
|
1727
1598
|
}
|
|
1728
1599
|
if (options.jsonc ?? true) {
|
|
1729
1600
|
configs.push(
|
|
1730
|
-
jsonc(
|
|
1601
|
+
jsonc({
|
|
1602
|
+
overrides: overrides.jsonc,
|
|
1603
|
+
stylistic: stylisticOptions
|
|
1604
|
+
}),
|
|
1731
1605
|
sortPackageJson(),
|
|
1732
1606
|
sortTsconfig()
|
|
1733
1607
|
);
|
|
@@ -1735,11 +1609,15 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1735
1609
|
if (options.yaml ?? true) {
|
|
1736
1610
|
configs.push(yaml({
|
|
1737
1611
|
overrides: overrides.yaml,
|
|
1738
|
-
stylistic:
|
|
1612
|
+
stylistic: stylisticOptions
|
|
1613
|
+
}));
|
|
1614
|
+
}
|
|
1615
|
+
if (options.markdown ?? true) {
|
|
1616
|
+
configs.push(markdown({
|
|
1617
|
+
componentExts,
|
|
1618
|
+
overrides: overrides.markdown
|
|
1739
1619
|
}));
|
|
1740
1620
|
}
|
|
1741
|
-
if (options.markdown ?? true)
|
|
1742
|
-
configs.push(markdown({ componentExts, overrides: overrides.markdown }));
|
|
1743
1621
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1744
1622
|
if (key in options)
|
|
1745
1623
|
acc[key] = options[key];
|
|
@@ -1759,7 +1637,6 @@ var src_default = coderwyd;
|
|
|
1759
1637
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1760
1638
|
0 && (module.exports = {
|
|
1761
1639
|
GLOB_ALL_SRC,
|
|
1762
|
-
GLOB_ASTRO,
|
|
1763
1640
|
GLOB_CSS,
|
|
1764
1641
|
GLOB_EXCLUDE,
|
|
1765
1642
|
GLOB_HTML,
|
|
@@ -1780,49 +1657,30 @@ var src_default = coderwyd;
|
|
|
1780
1657
|
GLOB_TSX,
|
|
1781
1658
|
GLOB_VUE,
|
|
1782
1659
|
GLOB_YAML,
|
|
1783
|
-
astro,
|
|
1784
1660
|
coderwyd,
|
|
1785
1661
|
combine,
|
|
1786
1662
|
comments,
|
|
1663
|
+
ensurePackages,
|
|
1787
1664
|
getVueVersion,
|
|
1788
1665
|
ignores,
|
|
1789
1666
|
imports,
|
|
1667
|
+
interopDefault,
|
|
1790
1668
|
javascript,
|
|
1791
1669
|
jsdoc,
|
|
1792
1670
|
jsonc,
|
|
1793
1671
|
markdown,
|
|
1794
1672
|
node,
|
|
1795
|
-
|
|
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,
|
|
1673
|
+
perfectionist,
|
|
1818
1674
|
react,
|
|
1819
1675
|
renameRules,
|
|
1820
1676
|
sortPackageJson,
|
|
1821
1677
|
sortTsconfig,
|
|
1822
1678
|
stylistic,
|
|
1823
1679
|
test,
|
|
1680
|
+
toArray,
|
|
1824
1681
|
typescript,
|
|
1825
1682
|
unicorn,
|
|
1683
|
+
unocss,
|
|
1826
1684
|
vue,
|
|
1827
1685
|
yaml
|
|
1828
1686
|
});
|