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