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