@coderwyd/eslint-config 1.1.0-beta.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -9
- package/bin/index.js +3 -0
- package/dist/cli.cjs +268 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +239 -0
- package/dist/index.cjs +553 -492
- package/dist/index.d.cts +130 -78
- package/dist/index.d.ts +130 -78
- package/dist/index.js +553 -473
- package/package.json +76 -37
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
GLOB_ALL_SRC: () => GLOB_ALL_SRC,
|
|
34
|
-
GLOB_ASTRO: () => GLOB_ASTRO,
|
|
35
34
|
GLOB_CSS: () => GLOB_CSS,
|
|
36
35
|
GLOB_EXCLUDE: () => GLOB_EXCLUDE,
|
|
37
36
|
GLOB_HTML: () => GLOB_HTML,
|
|
@@ -52,49 +51,31 @@ __export(src_exports, {
|
|
|
52
51
|
GLOB_TSX: () => GLOB_TSX,
|
|
53
52
|
GLOB_VUE: () => GLOB_VUE,
|
|
54
53
|
GLOB_YAML: () => GLOB_YAML,
|
|
55
|
-
astro: () => astro,
|
|
56
54
|
coderwyd: () => coderwyd,
|
|
57
55
|
combine: () => combine,
|
|
58
56
|
comments: () => comments,
|
|
59
57
|
default: () => src_default,
|
|
58
|
+
ensurePackages: () => ensurePackages,
|
|
60
59
|
getVueVersion: () => getVueVersion,
|
|
61
60
|
ignores: () => ignores,
|
|
62
61
|
imports: () => imports,
|
|
62
|
+
interopDefault: () => interopDefault,
|
|
63
63
|
javascript: () => javascript,
|
|
64
64
|
jsdoc: () => jsdoc,
|
|
65
65
|
jsonc: () => jsonc,
|
|
66
66
|
markdown: () => markdown,
|
|
67
67
|
node: () => node,
|
|
68
|
-
|
|
69
|
-
parserJsonc: () => import_jsonc_eslint_parser.default,
|
|
70
|
-
parserTs: () => import_parser.default,
|
|
71
|
-
parserVue: () => import_vue_eslint_parser.default,
|
|
72
|
-
parserYaml: () => import_yaml_eslint_parser.default,
|
|
73
|
-
pluginAntfu: () => import_eslint_plugin_antfu.default,
|
|
74
|
-
pluginAstro: () => import_eslint_plugin_astro.default,
|
|
75
|
-
pluginComments: () => import_eslint_plugin_eslint_comments.default,
|
|
76
|
-
pluginImport: () => import_eslint_plugin_i.default,
|
|
77
|
-
pluginJsdoc: () => import_eslint_plugin_jsdoc.default,
|
|
78
|
-
pluginJsonc: () => import_eslint_plugin_jsonc.default,
|
|
79
|
-
pluginMarkdown: () => import_eslint_plugin_markdown.default,
|
|
80
|
-
pluginNoOnlyTests: () => import_eslint_plugin_no_only_tests.default,
|
|
81
|
-
pluginNode: () => import_eslint_plugin_n.default,
|
|
82
|
-
pluginReact: () => import_eslint_plugin_react.default,
|
|
83
|
-
pluginReactHooks: () => import_eslint_plugin_react_hooks.default,
|
|
84
|
-
pluginStylistic: () => import_eslint_plugin.default,
|
|
85
|
-
pluginTs: () => import_eslint_plugin2.default,
|
|
86
|
-
pluginUnicorn: () => import_eslint_plugin_unicorn.default,
|
|
87
|
-
pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
|
|
88
|
-
pluginVue: () => import_eslint_plugin_vue.default,
|
|
89
|
-
pluginYaml: () => import_eslint_plugin_yml.default,
|
|
68
|
+
perfectionist: () => perfectionist,
|
|
90
69
|
react: () => react,
|
|
91
70
|
renameRules: () => renameRules,
|
|
92
71
|
sortPackageJson: () => sortPackageJson,
|
|
93
72
|
sortTsconfig: () => sortTsconfig,
|
|
94
73
|
stylistic: () => stylistic,
|
|
95
74
|
test: () => test,
|
|
75
|
+
toArray: () => toArray,
|
|
96
76
|
typescript: () => typescript,
|
|
97
77
|
unicorn: () => unicorn,
|
|
78
|
+
unocss: () => unocss,
|
|
98
79
|
vue: () => vue,
|
|
99
80
|
yaml: () => yaml
|
|
100
81
|
});
|
|
@@ -103,37 +84,22 @@ module.exports = __toCommonJS(src_exports);
|
|
|
103
84
|
// src/factory.ts
|
|
104
85
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
105
86
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
106
|
-
var
|
|
107
|
-
var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
|
|
87
|
+
var import_local_pkg3 = require("local-pkg");
|
|
108
88
|
|
|
109
89
|
// src/plugins.ts
|
|
110
90
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
111
91
|
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
112
|
-
var
|
|
113
|
-
var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
|
|
114
|
-
var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
|
|
115
|
-
var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
|
|
92
|
+
var pluginImport = __toESM(require("eslint-plugin-i"), 1);
|
|
116
93
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
117
|
-
var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
118
|
-
var import_eslint_plugin2 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
119
94
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
120
95
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
121
|
-
var
|
|
122
|
-
var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
|
|
123
|
-
var import_eslint_plugin_no_only_tests = __toESM(require("eslint-plugin-no-only-tests"), 1);
|
|
124
|
-
var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
|
|
125
|
-
var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
|
|
126
|
-
var import_eslint_plugin_astro = __toESM(require("eslint-plugin-astro"), 1);
|
|
127
|
-
var import_parser = __toESM(require("@typescript-eslint/parser"), 1);
|
|
128
|
-
var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
|
|
129
|
-
var import_yaml_eslint_parser = __toESM(require("yaml-eslint-parser"), 1);
|
|
130
|
-
var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
|
|
131
|
-
var import_astro_eslint_parser = __toESM(require("astro-eslint-parser"), 1);
|
|
96
|
+
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
132
97
|
|
|
133
98
|
// src/configs/comments.ts
|
|
134
|
-
function comments() {
|
|
99
|
+
async function comments() {
|
|
135
100
|
return [
|
|
136
101
|
{
|
|
102
|
+
name: "coderwyd:eslint-comments",
|
|
137
103
|
plugins: {
|
|
138
104
|
"eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
139
105
|
},
|
|
@@ -165,12 +131,13 @@ var GLOB_MARKDOWN = "**/*.md";
|
|
|
165
131
|
var GLOB_VUE = "**/*.vue";
|
|
166
132
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
167
133
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
168
|
-
var GLOB_ASTRO = "**/*.astro";
|
|
169
134
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
170
135
|
var GLOB_TESTS = [
|
|
171
136
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
172
137
|
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
173
|
-
`**/*.test.${GLOB_SRC_EXT}
|
|
138
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
139
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
140
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
174
141
|
];
|
|
175
142
|
var GLOB_ALL_SRC = [
|
|
176
143
|
GLOB_SRC,
|
|
@@ -188,14 +155,21 @@ var GLOB_EXCLUDE = [
|
|
|
188
155
|
"**/package-lock.json",
|
|
189
156
|
"**/yarn.lock",
|
|
190
157
|
"**/pnpm-lock.yaml",
|
|
158
|
+
"**/bun.lockb",
|
|
191
159
|
"**/output",
|
|
192
160
|
"**/coverage",
|
|
193
161
|
"**/temp",
|
|
162
|
+
"**/.temp",
|
|
163
|
+
"**/tmp",
|
|
164
|
+
"**/.tmp",
|
|
165
|
+
"**/.history",
|
|
194
166
|
"**/.vitepress/cache",
|
|
195
167
|
"**/.nuxt",
|
|
168
|
+
"**/.next",
|
|
196
169
|
"**/.vercel",
|
|
197
170
|
"**/.changeset",
|
|
198
171
|
"**/.idea",
|
|
172
|
+
"**/.cache",
|
|
199
173
|
"**/.output",
|
|
200
174
|
"**/.vite-inspect",
|
|
201
175
|
"**/CHANGELOG*.md",
|
|
@@ -207,27 +181,29 @@ var GLOB_EXCLUDE = [
|
|
|
207
181
|
];
|
|
208
182
|
|
|
209
183
|
// src/configs/ignores.ts
|
|
210
|
-
function ignores() {
|
|
184
|
+
async function ignores() {
|
|
211
185
|
return [
|
|
212
|
-
{
|
|
186
|
+
{
|
|
187
|
+
ignores: GLOB_EXCLUDE
|
|
188
|
+
}
|
|
213
189
|
];
|
|
214
190
|
}
|
|
215
191
|
|
|
216
192
|
// src/configs/imports.ts
|
|
217
|
-
function imports(options = {}) {
|
|
193
|
+
async function imports(options = {}) {
|
|
218
194
|
const {
|
|
219
195
|
stylistic: stylistic2 = true
|
|
220
196
|
} = options;
|
|
221
197
|
return [
|
|
222
198
|
{
|
|
199
|
+
name: "coderwyd:imports",
|
|
223
200
|
plugins: {
|
|
224
201
|
antfu: import_eslint_plugin_antfu.default,
|
|
225
|
-
import:
|
|
202
|
+
import: pluginImport
|
|
226
203
|
},
|
|
227
204
|
rules: {
|
|
228
205
|
"antfu/import-dedupe": "error",
|
|
229
206
|
"antfu/no-import-node-modules-by-path": "error",
|
|
230
|
-
"import/export": "error",
|
|
231
207
|
"import/first": "error",
|
|
232
208
|
"import/no-duplicates": "error",
|
|
233
209
|
"import/no-mutable-exports": "error",
|
|
@@ -245,23 +221,12 @@ function imports(options = {}) {
|
|
|
245
221
|
|
|
246
222
|
// src/configs/javascript.ts
|
|
247
223
|
var import_globals = __toESM(require("globals"), 1);
|
|
248
|
-
|
|
249
|
-
// src/flags.ts
|
|
250
|
-
var OFF = 0;
|
|
251
|
-
|
|
252
|
-
// src/configs/javascript.ts
|
|
253
|
-
function javascript(options = {}) {
|
|
224
|
+
async function javascript(options = {}) {
|
|
254
225
|
const {
|
|
255
226
|
isInEditor = false,
|
|
256
227
|
overrides = {}
|
|
257
228
|
} = options;
|
|
258
229
|
return [
|
|
259
|
-
{
|
|
260
|
-
plugins: {
|
|
261
|
-
"antfu": import_eslint_plugin_antfu.default,
|
|
262
|
-
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
230
|
{
|
|
266
231
|
languageOptions: {
|
|
267
232
|
ecmaVersion: 2022,
|
|
@@ -282,20 +247,23 @@ function javascript(options = {}) {
|
|
|
282
247
|
},
|
|
283
248
|
sourceType: "module"
|
|
284
249
|
},
|
|
250
|
+
linterOptions: {
|
|
251
|
+
reportUnusedDisableDirectives: true
|
|
252
|
+
},
|
|
253
|
+
name: "coderwyd:javascript",
|
|
254
|
+
plugins: {
|
|
255
|
+
"antfu": import_eslint_plugin_antfu.default,
|
|
256
|
+
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
257
|
+
},
|
|
285
258
|
rules: {
|
|
286
259
|
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
287
|
-
"antfu/top-level-function": "error",
|
|
288
260
|
"array-callback-return": "error",
|
|
289
|
-
"arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
|
|
290
261
|
"block-scoped-var": "error",
|
|
291
262
|
"constructor-super": "error",
|
|
292
263
|
"default-case-last": "error",
|
|
293
264
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
294
|
-
"eol-last": "error",
|
|
295
265
|
"eqeqeq": ["error", "smart"],
|
|
296
|
-
"max-statements-per-line": ["error", { max: 1 }],
|
|
297
266
|
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
|
|
298
|
-
"new-parens": "error",
|
|
299
267
|
"no-alert": "error",
|
|
300
268
|
"no-array-constructor": "error",
|
|
301
269
|
"no-async-promise-executor": "error",
|
|
@@ -306,7 +274,6 @@ function javascript(options = {}) {
|
|
|
306
274
|
"no-cond-assign": ["error", "always"],
|
|
307
275
|
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
308
276
|
"no-const-assign": "error",
|
|
309
|
-
"no-constant-condition": "warn",
|
|
310
277
|
"no-control-regex": "error",
|
|
311
278
|
"no-debugger": "error",
|
|
312
279
|
"no-delete-var": "error",
|
|
@@ -322,29 +289,18 @@ function javascript(options = {}) {
|
|
|
322
289
|
"no-extend-native": "error",
|
|
323
290
|
"no-extra-bind": "error",
|
|
324
291
|
"no-extra-boolean-cast": "error",
|
|
325
|
-
"no-extra-parens": ["error", "functions"],
|
|
326
292
|
"no-fallthrough": "error",
|
|
327
|
-
"no-floating-decimal": "error",
|
|
328
293
|
"no-func-assign": "error",
|
|
329
294
|
"no-global-assign": "error",
|
|
330
295
|
"no-implied-eval": "error",
|
|
331
296
|
"no-import-assign": "error",
|
|
332
297
|
"no-invalid-regexp": "error",
|
|
333
|
-
"no-invalid-this": "error",
|
|
334
298
|
"no-irregular-whitespace": "error",
|
|
335
299
|
"no-iterator": "error",
|
|
336
300
|
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
337
301
|
"no-lone-blocks": "error",
|
|
338
302
|
"no-loss-of-precision": "error",
|
|
339
303
|
"no-misleading-character-class": "error",
|
|
340
|
-
"no-mixed-operators": ["error", {
|
|
341
|
-
allowSamePrecedence: true,
|
|
342
|
-
groups: [
|
|
343
|
-
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
|
344
|
-
["&&", "||"],
|
|
345
|
-
["in", "instanceof"]
|
|
346
|
-
]
|
|
347
|
-
}],
|
|
348
304
|
"no-multi-str": "error",
|
|
349
305
|
"no-new": "error",
|
|
350
306
|
"no-new-func": "error",
|
|
@@ -375,7 +331,9 @@ function javascript(options = {}) {
|
|
|
375
331
|
"error",
|
|
376
332
|
"DebuggerStatement",
|
|
377
333
|
"LabeledStatement",
|
|
378
|
-
"WithStatement"
|
|
334
|
+
"WithStatement",
|
|
335
|
+
"TSEnumDeclaration[const=true]",
|
|
336
|
+
"TSExportAssignment"
|
|
379
337
|
],
|
|
380
338
|
"no-self-assign": ["error", { props: true }],
|
|
381
339
|
"no-self-compare": "error",
|
|
@@ -414,7 +372,6 @@ function javascript(options = {}) {
|
|
|
414
372
|
"no-useless-rename": "error",
|
|
415
373
|
"no-useless-return": "error",
|
|
416
374
|
"no-var": "error",
|
|
417
|
-
"no-void": "error",
|
|
418
375
|
"no-with": "error",
|
|
419
376
|
"object-shorthand": [
|
|
420
377
|
"error",
|
|
@@ -445,7 +402,6 @@ function javascript(options = {}) {
|
|
|
445
402
|
"prefer-rest-params": "error",
|
|
446
403
|
"prefer-spread": "error",
|
|
447
404
|
"prefer-template": "error",
|
|
448
|
-
"quote-props": ["error", "consistent-as-needed"],
|
|
449
405
|
"sort-imports": [
|
|
450
406
|
"error",
|
|
451
407
|
{
|
|
@@ -458,7 +414,7 @@ function javascript(options = {}) {
|
|
|
458
414
|
],
|
|
459
415
|
"symbol-description": "error",
|
|
460
416
|
"unicode-bom": ["error", "never"],
|
|
461
|
-
"unused-imports/no-unused-imports": isInEditor ?
|
|
417
|
+
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
462
418
|
"unused-imports/no-unused-vars": [
|
|
463
419
|
"error",
|
|
464
420
|
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
|
|
@@ -466,32 +422,79 @@ function javascript(options = {}) {
|
|
|
466
422
|
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
|
|
467
423
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
468
424
|
"vars-on-top": "error",
|
|
469
|
-
"wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
|
|
470
425
|
"yoda": ["error", "never"],
|
|
471
426
|
...overrides
|
|
472
427
|
}
|
|
473
428
|
},
|
|
474
429
|
{
|
|
475
430
|
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
431
|
+
name: "coderwyd:scripts-overrides",
|
|
476
432
|
rules: {
|
|
477
|
-
"no-console":
|
|
433
|
+
"no-console": "off"
|
|
478
434
|
}
|
|
479
435
|
}
|
|
480
436
|
];
|
|
481
437
|
}
|
|
482
438
|
|
|
439
|
+
// src/utils.ts
|
|
440
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
441
|
+
var import_local_pkg = require("local-pkg");
|
|
442
|
+
async function combine(...configs) {
|
|
443
|
+
const resolved = await Promise.all(configs);
|
|
444
|
+
return resolved.flat();
|
|
445
|
+
}
|
|
446
|
+
function renameRules(rules, from, to) {
|
|
447
|
+
return Object.fromEntries(
|
|
448
|
+
Object.entries(rules).map(([key, value]) => {
|
|
449
|
+
if (key.startsWith(from))
|
|
450
|
+
return [to + key.slice(from.length), value];
|
|
451
|
+
return [key, value];
|
|
452
|
+
})
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
function getVueVersion() {
|
|
456
|
+
const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
|
|
457
|
+
if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
|
|
458
|
+
return +pkg.version[0];
|
|
459
|
+
return 3;
|
|
460
|
+
}
|
|
461
|
+
function toArray(value) {
|
|
462
|
+
return Array.isArray(value) ? value : [value];
|
|
463
|
+
}
|
|
464
|
+
async function interopDefault(m) {
|
|
465
|
+
const resolved = await m;
|
|
466
|
+
return resolved.default || resolved;
|
|
467
|
+
}
|
|
468
|
+
async function ensurePackages(packages) {
|
|
469
|
+
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false)
|
|
470
|
+
return;
|
|
471
|
+
const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i));
|
|
472
|
+
if (nonExistingPackages.length === 0)
|
|
473
|
+
return;
|
|
474
|
+
const { default: prompts } = await import("prompts");
|
|
475
|
+
const { result } = await prompts([
|
|
476
|
+
{
|
|
477
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
478
|
+
name: "result",
|
|
479
|
+
type: "confirm"
|
|
480
|
+
}
|
|
481
|
+
]);
|
|
482
|
+
if (result)
|
|
483
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
484
|
+
}
|
|
485
|
+
|
|
483
486
|
// src/configs/jsdoc.ts
|
|
484
|
-
function jsdoc(options = {}) {
|
|
487
|
+
async function jsdoc(options = {}) {
|
|
485
488
|
const {
|
|
486
489
|
stylistic: stylistic2 = true
|
|
487
490
|
} = options;
|
|
488
491
|
return [
|
|
489
492
|
{
|
|
493
|
+
name: "coderwyd:jsdoc",
|
|
490
494
|
plugins: {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
{
|
|
495
|
+
// @ts-expect-error missing types
|
|
496
|
+
jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
|
|
497
|
+
},
|
|
495
498
|
rules: {
|
|
496
499
|
"jsdoc/check-access": "warn",
|
|
497
500
|
"jsdoc/check-param-names": "warn",
|
|
@@ -508,7 +511,6 @@ function jsdoc(options = {}) {
|
|
|
508
511
|
"jsdoc/require-returns-check": "warn",
|
|
509
512
|
"jsdoc/require-returns-description": "warn",
|
|
510
513
|
"jsdoc/require-yields-check": "warn",
|
|
511
|
-
"jsdoc/valid-types": "warn",
|
|
512
514
|
...stylistic2 ? {
|
|
513
515
|
"jsdoc/check-alignment": "warn",
|
|
514
516
|
"jsdoc/multiline-blocks": "warn"
|
|
@@ -519,22 +521,35 @@ function jsdoc(options = {}) {
|
|
|
519
521
|
}
|
|
520
522
|
|
|
521
523
|
// src/configs/jsonc.ts
|
|
522
|
-
function jsonc(options = {}) {
|
|
524
|
+
async function jsonc(options = {}) {
|
|
523
525
|
const {
|
|
524
|
-
|
|
525
|
-
overrides = {}
|
|
526
|
+
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
527
|
+
overrides = {},
|
|
528
|
+
stylistic: stylistic2 = true
|
|
526
529
|
} = options;
|
|
530
|
+
const {
|
|
531
|
+
indent = 2
|
|
532
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
533
|
+
const [
|
|
534
|
+
pluginJsonc,
|
|
535
|
+
parserJsonc
|
|
536
|
+
] = await Promise.all([
|
|
537
|
+
interopDefault(import("eslint-plugin-jsonc")),
|
|
538
|
+
interopDefault(import("jsonc-eslint-parser"))
|
|
539
|
+
]);
|
|
527
540
|
return [
|
|
528
541
|
{
|
|
542
|
+
name: "coderwyd:jsonc:setup",
|
|
529
543
|
plugins: {
|
|
530
|
-
jsonc:
|
|
544
|
+
jsonc: pluginJsonc
|
|
531
545
|
}
|
|
532
546
|
},
|
|
533
547
|
{
|
|
534
|
-
files
|
|
548
|
+
files,
|
|
535
549
|
languageOptions: {
|
|
536
|
-
parser:
|
|
550
|
+
parser: parserJsonc
|
|
537
551
|
},
|
|
552
|
+
name: "coderwyd:jsonc:rules",
|
|
538
553
|
rules: {
|
|
539
554
|
"jsonc/no-bigint-literals": "error",
|
|
540
555
|
"jsonc/no-binary-expression": "error",
|
|
@@ -566,7 +581,7 @@ function jsonc(options = {}) {
|
|
|
566
581
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
567
582
|
"jsonc/comma-dangle": ["error", "never"],
|
|
568
583
|
"jsonc/comma-style": ["error", "last"],
|
|
569
|
-
"jsonc/indent": ["error",
|
|
584
|
+
"jsonc/indent": ["error", indent],
|
|
570
585
|
"jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
571
586
|
"jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
|
|
572
587
|
"jsonc/object-curly-spacing": ["error", "always"],
|
|
@@ -581,19 +596,23 @@ function jsonc(options = {}) {
|
|
|
581
596
|
}
|
|
582
597
|
|
|
583
598
|
// src/configs/markdown.ts
|
|
584
|
-
function markdown(options = {}) {
|
|
599
|
+
async function markdown(options = {}) {
|
|
585
600
|
const {
|
|
586
601
|
componentExts = [],
|
|
602
|
+
files = [GLOB_MARKDOWN],
|
|
587
603
|
overrides = {}
|
|
588
604
|
} = options;
|
|
589
605
|
return [
|
|
590
606
|
{
|
|
607
|
+
name: "coderwyd:markdown:setup",
|
|
591
608
|
plugins: {
|
|
592
|
-
|
|
609
|
+
// @ts-expect-error missing types
|
|
610
|
+
markdown: await interopDefault(import("eslint-plugin-markdown"))
|
|
593
611
|
}
|
|
594
612
|
},
|
|
595
613
|
{
|
|
596
|
-
files
|
|
614
|
+
files,
|
|
615
|
+
name: "coderwyd:markdown:processor",
|
|
597
616
|
processor: "markdown/markdown"
|
|
598
617
|
},
|
|
599
618
|
{
|
|
@@ -608,45 +627,50 @@ function markdown(options = {}) {
|
|
|
608
627
|
}
|
|
609
628
|
}
|
|
610
629
|
},
|
|
630
|
+
name: "coderwyd:markdown:rules",
|
|
611
631
|
rules: {
|
|
612
|
-
"antfu/no-
|
|
613
|
-
"
|
|
614
|
-
"
|
|
615
|
-
"no-
|
|
616
|
-
"no-
|
|
617
|
-
"no-
|
|
618
|
-
"no-
|
|
619
|
-
"no-
|
|
620
|
-
"
|
|
621
|
-
"
|
|
622
|
-
"
|
|
623
|
-
"
|
|
624
|
-
"
|
|
625
|
-
"
|
|
626
|
-
"ts/
|
|
627
|
-
"ts/no-
|
|
628
|
-
"ts/no-
|
|
632
|
+
"antfu/no-ts-export-equal": "off",
|
|
633
|
+
"import/newline-after-import": "off",
|
|
634
|
+
"no-alert": "off",
|
|
635
|
+
"no-console": "off",
|
|
636
|
+
"no-labels": "off",
|
|
637
|
+
"no-lone-blocks": "off",
|
|
638
|
+
"no-restricted-syntax": "off",
|
|
639
|
+
"no-undef": "off",
|
|
640
|
+
"no-unused-expressions": "off",
|
|
641
|
+
"no-unused-labels": "off",
|
|
642
|
+
"no-unused-vars": "off",
|
|
643
|
+
"node/prefer-global/process": "off",
|
|
644
|
+
"style/comma-dangle": "off",
|
|
645
|
+
"style/eol-last": "off",
|
|
646
|
+
"ts/consistent-type-imports": "off",
|
|
647
|
+
"ts/no-namespace": "off",
|
|
648
|
+
"ts/no-redeclare": "off",
|
|
649
|
+
"ts/no-require-imports": "off",
|
|
650
|
+
"ts/no-unused-vars": "off",
|
|
651
|
+
"ts/no-use-before-define": "off",
|
|
652
|
+
"ts/no-var-requires": "off",
|
|
629
653
|
"unicode-bom": "off",
|
|
630
|
-
"unused-imports/no-unused-imports":
|
|
631
|
-
"unused-imports/no-unused-vars":
|
|
654
|
+
"unused-imports/no-unused-imports": "off",
|
|
655
|
+
"unused-imports/no-unused-vars": "off",
|
|
632
656
|
// Type aware rules
|
|
633
657
|
...{
|
|
634
|
-
"ts/await-thenable":
|
|
635
|
-
"ts/dot-notation":
|
|
636
|
-
"ts/no-floating-promises":
|
|
637
|
-
"ts/no-for-in-array":
|
|
638
|
-
"ts/no-implied-eval":
|
|
639
|
-
"ts/no-misused-promises":
|
|
640
|
-
"ts/no-throw-literal":
|
|
641
|
-
"ts/no-unnecessary-type-assertion":
|
|
642
|
-
"ts/no-unsafe-argument":
|
|
643
|
-
"ts/no-unsafe-assignment":
|
|
644
|
-
"ts/no-unsafe-call":
|
|
645
|
-
"ts/no-unsafe-member-access":
|
|
646
|
-
"ts/no-unsafe-return":
|
|
647
|
-
"ts/restrict-plus-operands":
|
|
648
|
-
"ts/restrict-template-expressions":
|
|
649
|
-
"ts/unbound-method":
|
|
658
|
+
"ts/await-thenable": "off",
|
|
659
|
+
"ts/dot-notation": "off",
|
|
660
|
+
"ts/no-floating-promises": "off",
|
|
661
|
+
"ts/no-for-in-array": "off",
|
|
662
|
+
"ts/no-implied-eval": "off",
|
|
663
|
+
"ts/no-misused-promises": "off",
|
|
664
|
+
"ts/no-throw-literal": "off",
|
|
665
|
+
"ts/no-unnecessary-type-assertion": "off",
|
|
666
|
+
"ts/no-unsafe-argument": "off",
|
|
667
|
+
"ts/no-unsafe-assignment": "off",
|
|
668
|
+
"ts/no-unsafe-call": "off",
|
|
669
|
+
"ts/no-unsafe-member-access": "off",
|
|
670
|
+
"ts/no-unsafe-return": "off",
|
|
671
|
+
"ts/restrict-plus-operands": "off",
|
|
672
|
+
"ts/restrict-template-expressions": "off",
|
|
673
|
+
"ts/unbound-method": "off"
|
|
650
674
|
},
|
|
651
675
|
...overrides
|
|
652
676
|
}
|
|
@@ -655,9 +679,10 @@ function markdown(options = {}) {
|
|
|
655
679
|
}
|
|
656
680
|
|
|
657
681
|
// src/configs/node.ts
|
|
658
|
-
function node() {
|
|
682
|
+
async function node() {
|
|
659
683
|
return [
|
|
660
684
|
{
|
|
685
|
+
name: "coderwyd:node",
|
|
661
686
|
plugins: {
|
|
662
687
|
node: import_eslint_plugin_n.default
|
|
663
688
|
},
|
|
@@ -676,10 +701,11 @@ function node() {
|
|
|
676
701
|
}
|
|
677
702
|
|
|
678
703
|
// src/configs/sort.ts
|
|
679
|
-
function sortPackageJson() {
|
|
704
|
+
async function sortPackageJson() {
|
|
680
705
|
return [
|
|
681
706
|
{
|
|
682
707
|
files: ["**/package.json"],
|
|
708
|
+
name: "coderwyd:sort-package-json",
|
|
683
709
|
rules: {
|
|
684
710
|
"jsonc/sort-array-values": [
|
|
685
711
|
"error",
|
|
@@ -734,7 +760,6 @@ function sortPackageJson() {
|
|
|
734
760
|
"husky",
|
|
735
761
|
"simple-git-hooks",
|
|
736
762
|
"lint-staged",
|
|
737
|
-
"nano-staged",
|
|
738
763
|
"eslintConfig"
|
|
739
764
|
],
|
|
740
765
|
pathPattern: "^$"
|
|
@@ -769,6 +794,7 @@ function sortTsconfig() {
|
|
|
769
794
|
return [
|
|
770
795
|
{
|
|
771
796
|
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
797
|
+
name: "coderwyd:sort-tsconfig",
|
|
772
798
|
rules: {
|
|
773
799
|
"jsonc/sort-keys": [
|
|
774
800
|
"error",
|
|
@@ -794,70 +820,39 @@ function sortTsconfig() {
|
|
|
794
820
|
"disableReferencedProjectLoad",
|
|
795
821
|
/* Language and Environment */
|
|
796
822
|
"target",
|
|
797
|
-
"lib",
|
|
798
823
|
"jsx",
|
|
799
|
-
"experimentalDecorators",
|
|
800
|
-
"emitDecoratorMetadata",
|
|
801
824
|
"jsxFactory",
|
|
802
825
|
"jsxFragmentFactory",
|
|
803
826
|
"jsxImportSource",
|
|
804
|
-
"
|
|
827
|
+
"lib",
|
|
828
|
+
"moduleDetection",
|
|
805
829
|
"noLib",
|
|
830
|
+
"reactNamespace",
|
|
806
831
|
"useDefineForClassFields",
|
|
807
|
-
"
|
|
832
|
+
"emitDecoratorMetadata",
|
|
833
|
+
"experimentalDecorators",
|
|
808
834
|
/* Modules */
|
|
809
|
-
"module",
|
|
810
|
-
"rootDir",
|
|
811
|
-
"moduleResolution",
|
|
812
835
|
"baseUrl",
|
|
813
|
-
"
|
|
836
|
+
"rootDir",
|
|
814
837
|
"rootDirs",
|
|
815
|
-
"
|
|
816
|
-
"
|
|
817
|
-
"
|
|
838
|
+
"customConditions",
|
|
839
|
+
"module",
|
|
840
|
+
"moduleResolution",
|
|
818
841
|
"moduleSuffixes",
|
|
819
|
-
"
|
|
842
|
+
"noResolve",
|
|
843
|
+
"paths",
|
|
844
|
+
"resolveJsonModule",
|
|
820
845
|
"resolvePackageJsonExports",
|
|
821
846
|
"resolvePackageJsonImports",
|
|
822
|
-
"
|
|
823
|
-
"
|
|
847
|
+
"typeRoots",
|
|
848
|
+
"types",
|
|
824
849
|
"allowArbitraryExtensions",
|
|
825
|
-
"
|
|
850
|
+
"allowImportingTsExtensions",
|
|
851
|
+
"allowUmdGlobalAccess",
|
|
826
852
|
/* JavaScript Support */
|
|
827
853
|
"allowJs",
|
|
828
854
|
"checkJs",
|
|
829
855
|
"maxNodeModuleJsDepth",
|
|
830
|
-
/* Emit */
|
|
831
|
-
"declaration",
|
|
832
|
-
"declarationMap",
|
|
833
|
-
"emitDeclarationOnly",
|
|
834
|
-
"sourceMap",
|
|
835
|
-
"inlineSourceMap",
|
|
836
|
-
"outFile",
|
|
837
|
-
"outDir",
|
|
838
|
-
"removeComments",
|
|
839
|
-
"noEmit",
|
|
840
|
-
"importHelpers",
|
|
841
|
-
"importsNotUsedAsValues",
|
|
842
|
-
"downlevelIteration",
|
|
843
|
-
"sourceRoot",
|
|
844
|
-
"mapRoot",
|
|
845
|
-
"inlineSources",
|
|
846
|
-
"emitBOM",
|
|
847
|
-
"newLine",
|
|
848
|
-
"stripInternal",
|
|
849
|
-
"noEmitHelpers",
|
|
850
|
-
"noEmitOnError",
|
|
851
|
-
"preserveConstEnums",
|
|
852
|
-
"declarationDir",
|
|
853
|
-
"preserveValueImports",
|
|
854
|
-
/* Interop Constraints */
|
|
855
|
-
"isolatedModules",
|
|
856
|
-
"verbatimModuleSyntax",
|
|
857
|
-
"allowSyntheticDefaultImports",
|
|
858
|
-
"esModuleInterop",
|
|
859
|
-
"preserveSymlinks",
|
|
860
|
-
"forceConsistentCasingInFileNames",
|
|
861
856
|
/* Type Checking */
|
|
862
857
|
"strict",
|
|
863
858
|
"strictBindCallApply",
|
|
@@ -878,6 +873,37 @@ function sortTsconfig() {
|
|
|
878
873
|
"noUnusedLocals",
|
|
879
874
|
"noUnusedParameters",
|
|
880
875
|
"useUnknownInCatchVariables",
|
|
876
|
+
/* Emit */
|
|
877
|
+
"declaration",
|
|
878
|
+
"declarationDir",
|
|
879
|
+
"declarationMap",
|
|
880
|
+
"downlevelIteration",
|
|
881
|
+
"emitBOM",
|
|
882
|
+
"emitDeclarationOnly",
|
|
883
|
+
"importHelpers",
|
|
884
|
+
"importsNotUsedAsValues",
|
|
885
|
+
"inlineSourceMap",
|
|
886
|
+
"inlineSources",
|
|
887
|
+
"mapRoot",
|
|
888
|
+
"newLine",
|
|
889
|
+
"noEmit",
|
|
890
|
+
"noEmitHelpers",
|
|
891
|
+
"noEmitOnError",
|
|
892
|
+
"outDir",
|
|
893
|
+
"outFile",
|
|
894
|
+
"preserveConstEnums",
|
|
895
|
+
"preserveValueImports",
|
|
896
|
+
"removeComments",
|
|
897
|
+
"sourceMap",
|
|
898
|
+
"sourceRoot",
|
|
899
|
+
"stripInternal",
|
|
900
|
+
/* Interop Constraints */
|
|
901
|
+
"allowSyntheticDefaultImports",
|
|
902
|
+
"esModuleInterop",
|
|
903
|
+
"forceConsistentCasingInFileNames",
|
|
904
|
+
"isolatedModules",
|
|
905
|
+
"preserveSymlinks",
|
|
906
|
+
"verbatimModuleSyntax",
|
|
881
907
|
/* Completeness */
|
|
882
908
|
"skipDefaultLibCheck",
|
|
883
909
|
"skipLibCheck"
|
|
@@ -891,137 +917,57 @@ function sortTsconfig() {
|
|
|
891
917
|
}
|
|
892
918
|
|
|
893
919
|
// src/configs/stylistic.ts
|
|
894
|
-
function stylistic() {
|
|
920
|
+
async function stylistic(options = {}) {
|
|
921
|
+
const {
|
|
922
|
+
indent = 2,
|
|
923
|
+
jsx = true,
|
|
924
|
+
quotes = "single",
|
|
925
|
+
semi = false
|
|
926
|
+
} = options;
|
|
927
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
928
|
+
const config = pluginStylistic.configs.customize({
|
|
929
|
+
flat: true,
|
|
930
|
+
indent,
|
|
931
|
+
jsx,
|
|
932
|
+
pluginName: "style",
|
|
933
|
+
quotes,
|
|
934
|
+
semi
|
|
935
|
+
});
|
|
895
936
|
return [
|
|
896
937
|
{
|
|
938
|
+
name: "coderwyd:stylistic",
|
|
897
939
|
plugins: {
|
|
898
940
|
antfu: import_eslint_plugin_antfu.default,
|
|
899
|
-
style:
|
|
941
|
+
style: pluginStylistic
|
|
900
942
|
},
|
|
901
943
|
rules: {
|
|
944
|
+
...config.rules,
|
|
902
945
|
"antfu/consistent-list-newline": "error",
|
|
903
946
|
"antfu/if-newline": "error",
|
|
904
|
-
"
|
|
905
|
-
"
|
|
906
|
-
"
|
|
907
|
-
"style/block-spacing": ["error", "always"],
|
|
908
|
-
"style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
|
|
909
|
-
"style/comma-dangle": ["error", "always-multiline"],
|
|
910
|
-
"style/comma-spacing": ["error", { after: true, before: false }],
|
|
911
|
-
"style/comma-style": ["error", "last"],
|
|
912
|
-
"style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
|
|
913
|
-
"style/dot-location": ["error", "property"],
|
|
914
|
-
"style/indent": ["error", 2, {
|
|
915
|
-
ArrayExpression: 1,
|
|
916
|
-
CallExpression: { arguments: 1 },
|
|
917
|
-
FunctionDeclaration: { body: 1, parameters: 1 },
|
|
918
|
-
FunctionExpression: { body: 1, parameters: 1 },
|
|
919
|
-
ImportDeclaration: 1,
|
|
920
|
-
MemberExpression: 1,
|
|
921
|
-
ObjectExpression: 1,
|
|
922
|
-
SwitchCase: 1,
|
|
923
|
-
VariableDeclarator: 1,
|
|
924
|
-
flatTernaryExpressions: false,
|
|
925
|
-
ignoreComments: false,
|
|
926
|
-
ignoredNodes: [
|
|
927
|
-
"TemplateLiteral *",
|
|
928
|
-
"JSXElement",
|
|
929
|
-
"JSXElement > *",
|
|
930
|
-
"JSXAttribute",
|
|
931
|
-
"JSXIdentifier",
|
|
932
|
-
"JSXNamespacedName",
|
|
933
|
-
"JSXMemberExpression",
|
|
934
|
-
"JSXSpreadAttribute",
|
|
935
|
-
"JSXExpressionContainer",
|
|
936
|
-
"JSXOpeningElement",
|
|
937
|
-
"JSXClosingElement",
|
|
938
|
-
"JSXFragment",
|
|
939
|
-
"JSXOpeningFragment",
|
|
940
|
-
"JSXClosingFragment",
|
|
941
|
-
"JSXText",
|
|
942
|
-
"JSXEmptyExpression",
|
|
943
|
-
"JSXSpreadChild",
|
|
944
|
-
"TSTypeParameterInstantiation",
|
|
945
|
-
"FunctionExpression > .params[decorators.length > 0]",
|
|
946
|
-
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
947
|
-
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
|
|
948
|
-
],
|
|
949
|
-
offsetTernaryExpressions: true,
|
|
950
|
-
outerIIFEBody: 1
|
|
951
|
-
}],
|
|
952
|
-
"style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
953
|
-
"style/keyword-spacing": ["error", { after: true, before: true }],
|
|
954
|
-
"style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
|
|
955
|
-
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
956
|
-
"style/multiline-ternary": ["error", "always-multiline"],
|
|
957
|
-
"style/no-mixed-spaces-and-tabs": "error",
|
|
958
|
-
"style/no-multi-spaces": "error",
|
|
959
|
-
"style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
960
|
-
"style/no-tabs": "error",
|
|
961
|
-
"style/no-trailing-spaces": "error",
|
|
962
|
-
"style/no-whitespace-before-property": "error",
|
|
963
|
-
"style/object-curly-spacing": ["error", "always"],
|
|
964
|
-
"style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
965
|
-
"style/operator-linebreak": ["error", "before"],
|
|
966
|
-
"style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
|
|
967
|
-
"style/quotes": ["error", "single"],
|
|
968
|
-
"style/rest-spread-spacing": ["error", "never"],
|
|
969
|
-
"style/semi": ["error", "never"],
|
|
970
|
-
"style/semi-spacing": ["error", { after: true, before: false }],
|
|
971
|
-
"style/space-before-blocks": ["error", "always"],
|
|
972
|
-
"style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
|
|
973
|
-
"style/space-in-parens": ["error", "never"],
|
|
974
|
-
"style/space-infix-ops": "error",
|
|
975
|
-
"style/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
976
|
-
"style/spaced-comment": ["error", "always", {
|
|
977
|
-
block: {
|
|
978
|
-
balanced: true,
|
|
979
|
-
exceptions: ["*"],
|
|
980
|
-
markers: ["!"]
|
|
981
|
-
},
|
|
982
|
-
line: {
|
|
983
|
-
exceptions: ["/", "#"],
|
|
984
|
-
markers: ["/"]
|
|
985
|
-
}
|
|
986
|
-
}],
|
|
987
|
-
"style/template-curly-spacing": "error",
|
|
988
|
-
"style/template-tag-spacing": ["error", "never"],
|
|
989
|
-
"style/type-annotation-spacing": ["error", {}],
|
|
990
|
-
"style/yield-star-spacing": ["error", "both"]
|
|
947
|
+
"antfu/indent-binary-ops": ["error", { indent }],
|
|
948
|
+
"antfu/top-level-function": "error",
|
|
949
|
+
"curly": ["error", "multi-or-nest", "consistent"]
|
|
991
950
|
}
|
|
992
951
|
}
|
|
993
952
|
];
|
|
994
953
|
}
|
|
995
954
|
|
|
996
955
|
// src/configs/typescript.ts
|
|
997
|
-
var
|
|
998
|
-
|
|
999
|
-
// src/utils.ts
|
|
1000
|
-
function combine(...configs) {
|
|
1001
|
-
return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
|
|
1002
|
-
}
|
|
1003
|
-
function renameRules(rules, from, to) {
|
|
1004
|
-
return Object.fromEntries(
|
|
1005
|
-
Object.entries(rules).map(([key, value]) => {
|
|
1006
|
-
if (key.startsWith(from))
|
|
1007
|
-
return [to + key.slice(from.length), value];
|
|
1008
|
-
return [key, value];
|
|
1009
|
-
})
|
|
1010
|
-
);
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
// src/configs/typescript.ts
|
|
1014
|
-
function typescript(options) {
|
|
956
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
957
|
+
async function typescript(options = {}) {
|
|
1015
958
|
const {
|
|
1016
959
|
componentExts = [],
|
|
1017
960
|
overrides = {},
|
|
1018
|
-
parserOptions = {}
|
|
1019
|
-
|
|
1020
|
-
|
|
961
|
+
parserOptions = {}
|
|
962
|
+
} = options;
|
|
963
|
+
const files = options.files ?? [
|
|
964
|
+
GLOB_SRC,
|
|
965
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
966
|
+
];
|
|
1021
967
|
const typeAwareRules = {
|
|
1022
|
-
"dot-notation":
|
|
1023
|
-
"no-implied-eval":
|
|
1024
|
-
"no-throw-literal":
|
|
968
|
+
"dot-notation": "off",
|
|
969
|
+
"no-implied-eval": "off",
|
|
970
|
+
"no-throw-literal": "off",
|
|
1025
971
|
"ts/await-thenable": "error",
|
|
1026
972
|
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
1027
973
|
"ts/no-floating-promises": "error",
|
|
@@ -1039,109 +985,116 @@ function typescript(options) {
|
|
|
1039
985
|
"ts/restrict-template-expressions": "error",
|
|
1040
986
|
"ts/unbound-method": "error"
|
|
1041
987
|
};
|
|
988
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
989
|
+
const [
|
|
990
|
+
pluginTs,
|
|
991
|
+
parserTs
|
|
992
|
+
] = await Promise.all([
|
|
993
|
+
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
994
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
995
|
+
]);
|
|
1042
996
|
return [
|
|
1043
997
|
{
|
|
998
|
+
// Install the plugins without globs, so they can be configured separately.
|
|
999
|
+
name: "coderwyd:typescript:setup",
|
|
1044
1000
|
plugins: {
|
|
1045
1001
|
antfu: import_eslint_plugin_antfu.default,
|
|
1046
|
-
|
|
1047
|
-
ts: import_eslint_plugin2.default
|
|
1002
|
+
ts: pluginTs
|
|
1048
1003
|
}
|
|
1049
1004
|
},
|
|
1050
1005
|
{
|
|
1051
|
-
files
|
|
1052
|
-
GLOB_TS,
|
|
1053
|
-
GLOB_TSX,
|
|
1054
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1055
|
-
],
|
|
1006
|
+
files,
|
|
1056
1007
|
languageOptions: {
|
|
1057
|
-
parser:
|
|
1008
|
+
parser: parserTs,
|
|
1058
1009
|
parserOptions: {
|
|
1010
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1059
1011
|
sourceType: "module",
|
|
1060
1012
|
...tsconfigPath ? {
|
|
1061
|
-
project:
|
|
1062
|
-
tsconfigRootDir:
|
|
1013
|
+
project: tsconfigPath,
|
|
1014
|
+
tsconfigRootDir: import_node_process2.default.cwd()
|
|
1063
1015
|
} : {},
|
|
1064
1016
|
...parserOptions
|
|
1065
1017
|
}
|
|
1066
1018
|
},
|
|
1019
|
+
name: "coderwyd:typescript:rules",
|
|
1067
1020
|
rules: {
|
|
1068
1021
|
...renameRules(
|
|
1069
|
-
|
|
1022
|
+
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1070
1023
|
"@typescript-eslint/",
|
|
1071
1024
|
"ts/"
|
|
1072
1025
|
),
|
|
1073
1026
|
...renameRules(
|
|
1074
|
-
|
|
1027
|
+
pluginTs.configs.strict.rules,
|
|
1075
1028
|
"@typescript-eslint/",
|
|
1076
1029
|
"ts/"
|
|
1077
1030
|
),
|
|
1078
1031
|
"antfu/generic-spacing": "error",
|
|
1079
1032
|
"antfu/named-tuple-spacing": "error",
|
|
1080
|
-
"
|
|
1081
|
-
"
|
|
1082
|
-
"
|
|
1083
|
-
"no-
|
|
1084
|
-
"no-
|
|
1085
|
-
"no-invalid-this": OFF,
|
|
1086
|
-
"no-loss-of-precision": OFF,
|
|
1087
|
-
"no-redeclare": OFF,
|
|
1088
|
-
"no-use-before-define": OFF,
|
|
1089
|
-
"no-useless-constructor": OFF,
|
|
1090
|
-
// TS
|
|
1033
|
+
"no-dupe-class-members": "off",
|
|
1034
|
+
"no-loss-of-precision": "off",
|
|
1035
|
+
"no-redeclare": "off",
|
|
1036
|
+
"no-use-before-define": "off",
|
|
1037
|
+
"no-useless-constructor": "off",
|
|
1091
1038
|
"ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
1039
|
+
"ts/ban-types": ["error", { types: { Function: false } }],
|
|
1092
1040
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1093
1041
|
"ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
|
|
1094
1042
|
"ts/no-dupe-class-members": "error",
|
|
1095
|
-
"ts/no-dynamic-delete":
|
|
1096
|
-
"ts/no-explicit-any":
|
|
1097
|
-
"ts/no-
|
|
1098
|
-
"ts/no-
|
|
1099
|
-
"ts/no-invalid-void-type":
|
|
1043
|
+
"ts/no-dynamic-delete": "off",
|
|
1044
|
+
"ts/no-explicit-any": "off",
|
|
1045
|
+
"ts/no-extraneous-class": "off",
|
|
1046
|
+
"ts/no-import-type-side-effects": "error",
|
|
1047
|
+
"ts/no-invalid-void-type": "off",
|
|
1100
1048
|
"ts/no-loss-of-precision": "error",
|
|
1101
|
-
"ts/no-non-null-assertion":
|
|
1049
|
+
"ts/no-non-null-assertion": "off",
|
|
1102
1050
|
"ts/no-redeclare": "error",
|
|
1103
1051
|
"ts/no-require-imports": "error",
|
|
1104
|
-
"ts/no-unused-vars":
|
|
1052
|
+
"ts/no-unused-vars": "off",
|
|
1105
1053
|
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
1054
|
+
"ts/no-useless-constructor": "off",
|
|
1106
1055
|
"ts/prefer-ts-expect-error": "error",
|
|
1107
|
-
"ts/triple-slash-reference":
|
|
1056
|
+
"ts/triple-slash-reference": "off",
|
|
1057
|
+
"ts/unified-signatures": "off",
|
|
1108
1058
|
...tsconfigPath ? typeAwareRules : {},
|
|
1109
1059
|
...overrides
|
|
1110
1060
|
}
|
|
1111
1061
|
},
|
|
1112
1062
|
{
|
|
1113
1063
|
files: ["**/*.d.ts"],
|
|
1064
|
+
name: "coderwyd:typescript:dts-overrides",
|
|
1114
1065
|
rules: {
|
|
1115
|
-
"eslint-comments/no-unlimited-disable":
|
|
1116
|
-
"import/no-duplicates":
|
|
1117
|
-
"
|
|
1066
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
1067
|
+
"import/no-duplicates": "off",
|
|
1068
|
+
"no-restricted-syntax": "off",
|
|
1069
|
+
"unused-imports/no-unused-vars": "off"
|
|
1118
1070
|
}
|
|
1119
1071
|
},
|
|
1120
1072
|
{
|
|
1121
|
-
files:
|
|
1073
|
+
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1074
|
+
name: "coderwyd:typescript:tests-overrides",
|
|
1122
1075
|
rules: {
|
|
1123
|
-
"no-unused-expressions":
|
|
1076
|
+
"no-unused-expressions": "off"
|
|
1124
1077
|
}
|
|
1125
1078
|
},
|
|
1126
1079
|
{
|
|
1127
|
-
files: [
|
|
1080
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
1081
|
+
name: "coderwyd:typescript:javascript-overrides",
|
|
1128
1082
|
rules: {
|
|
1129
|
-
"ts/no-require-imports":
|
|
1130
|
-
"ts/no-var-requires":
|
|
1083
|
+
"ts/no-require-imports": "off",
|
|
1084
|
+
"ts/no-var-requires": "off"
|
|
1131
1085
|
}
|
|
1132
1086
|
}
|
|
1133
1087
|
];
|
|
1134
1088
|
}
|
|
1135
1089
|
|
|
1136
1090
|
// src/configs/unicorn.ts
|
|
1137
|
-
function unicorn() {
|
|
1091
|
+
async function unicorn() {
|
|
1138
1092
|
return [
|
|
1139
1093
|
{
|
|
1094
|
+
name: "coderwyd:unicorn",
|
|
1140
1095
|
plugins: {
|
|
1141
1096
|
unicorn: import_eslint_plugin_unicorn.default
|
|
1142
|
-
}
|
|
1143
|
-
},
|
|
1144
|
-
{
|
|
1097
|
+
},
|
|
1145
1098
|
rules: {
|
|
1146
1099
|
// Pass error message when throwing errors
|
|
1147
1100
|
"unicorn/error-message": "error",
|
|
@@ -1153,10 +1106,10 @@ function unicorn() {
|
|
|
1153
1106
|
"unicorn/no-new-array": "error",
|
|
1154
1107
|
// Prevent deprecated `new Buffer()`
|
|
1155
1108
|
"unicorn/no-new-buffer": "error",
|
|
1156
|
-
// Keep regex literals safe!
|
|
1157
|
-
"unicorn/no-unsafe-regex": "error",
|
|
1158
1109
|
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
|
|
1159
1110
|
"unicorn/number-literal-case": "error",
|
|
1111
|
+
// textContent instead of innerText
|
|
1112
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
1160
1113
|
// includes over indexOf when checking for existence
|
|
1161
1114
|
"unicorn/prefer-includes": "error",
|
|
1162
1115
|
// Prefer using the node: protocol
|
|
@@ -1165,8 +1118,6 @@ function unicorn() {
|
|
|
1165
1118
|
"unicorn/prefer-number-properties": "error",
|
|
1166
1119
|
// String methods startsWith/endsWith instead of more complicated stuff
|
|
1167
1120
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1168
|
-
// textContent instead of innerText
|
|
1169
|
-
"unicorn/prefer-text-content": "error",
|
|
1170
1121
|
// Enforce throwing type error when throwing error while checking typeof
|
|
1171
1122
|
"unicorn/prefer-type-error": "error",
|
|
1172
1123
|
// Use new when throwing error
|
|
@@ -1177,55 +1128,61 @@ function unicorn() {
|
|
|
1177
1128
|
}
|
|
1178
1129
|
|
|
1179
1130
|
// src/configs/vue.ts
|
|
1180
|
-
|
|
1181
|
-
var import_local_pkg = require("local-pkg");
|
|
1182
|
-
function getVueVersion() {
|
|
1183
|
-
const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process2.default.cwd()] });
|
|
1184
|
-
if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
|
|
1185
|
-
return +pkg.version[0];
|
|
1186
|
-
return 3;
|
|
1187
|
-
}
|
|
1188
|
-
var isVue3 = getVueVersion() === 3;
|
|
1189
|
-
var vue3Rules = {
|
|
1190
|
-
...import_eslint_plugin_vue.default.configs.base.rules,
|
|
1191
|
-
...import_eslint_plugin_vue.default.configs["vue3-essential"].rules,
|
|
1192
|
-
...import_eslint_plugin_vue.default.configs["vue3-strongly-recommended"].rules,
|
|
1193
|
-
...import_eslint_plugin_vue.default.configs["vue3-recommended"].rules
|
|
1194
|
-
};
|
|
1195
|
-
var vue2Rules = {
|
|
1196
|
-
...import_eslint_plugin_vue.default.configs.base.rules,
|
|
1197
|
-
...import_eslint_plugin_vue.default.configs.essential.rules,
|
|
1198
|
-
...import_eslint_plugin_vue.default.configs["strongly-recommended"].rules,
|
|
1199
|
-
...import_eslint_plugin_vue.default.configs.recommended.rules
|
|
1200
|
-
};
|
|
1201
|
-
function vue(options = {}) {
|
|
1131
|
+
async function vue(options = {}) {
|
|
1202
1132
|
const {
|
|
1133
|
+
files = [GLOB_VUE],
|
|
1203
1134
|
overrides = {},
|
|
1204
1135
|
stylistic: stylistic2 = true
|
|
1205
1136
|
} = options;
|
|
1137
|
+
const {
|
|
1138
|
+
indent = 2
|
|
1139
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1140
|
+
const isVue3 = getVueVersion() === 3;
|
|
1141
|
+
const [
|
|
1142
|
+
pluginVue,
|
|
1143
|
+
parserVue
|
|
1144
|
+
] = await Promise.all([
|
|
1145
|
+
// @ts-expect-error missing types
|
|
1146
|
+
interopDefault(import("eslint-plugin-vue")),
|
|
1147
|
+
interopDefault(import("vue-eslint-parser"))
|
|
1148
|
+
]);
|
|
1149
|
+
const vue3Rules = {
|
|
1150
|
+
...pluginVue.configs.base.rules,
|
|
1151
|
+
...pluginVue.configs["vue3-essential"].rules,
|
|
1152
|
+
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1153
|
+
...pluginVue.configs["vue3-recommended"].rules
|
|
1154
|
+
};
|
|
1155
|
+
const vue2Rules = {
|
|
1156
|
+
...pluginVue.configs.base.rules,
|
|
1157
|
+
...pluginVue.configs.essential.rules,
|
|
1158
|
+
...pluginVue.configs["strongly-recommended"].rules,
|
|
1159
|
+
...pluginVue.configs.recommended.rules
|
|
1160
|
+
};
|
|
1206
1161
|
return [
|
|
1207
1162
|
{
|
|
1163
|
+
name: "coderwyd:vue:setup",
|
|
1208
1164
|
plugins: {
|
|
1209
|
-
vue:
|
|
1165
|
+
vue: pluginVue
|
|
1210
1166
|
}
|
|
1211
1167
|
},
|
|
1212
1168
|
{
|
|
1213
|
-
files
|
|
1169
|
+
files,
|
|
1214
1170
|
languageOptions: {
|
|
1215
|
-
parser:
|
|
1171
|
+
parser: parserVue,
|
|
1216
1172
|
parserOptions: {
|
|
1217
1173
|
ecmaFeatures: {
|
|
1218
1174
|
jsx: true
|
|
1219
1175
|
},
|
|
1220
1176
|
extraFileExtensions: [".vue"],
|
|
1221
|
-
parser: options.typescript ?
|
|
1177
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1222
1178
|
sourceType: "module"
|
|
1223
1179
|
}
|
|
1224
1180
|
},
|
|
1225
|
-
|
|
1181
|
+
name: "coderwyd:vue:rules",
|
|
1182
|
+
processor: pluginVue.processors[".vue"],
|
|
1226
1183
|
rules: {
|
|
1227
1184
|
...isVue3 ? vue3Rules : vue2Rules,
|
|
1228
|
-
"node/prefer-global/process":
|
|
1185
|
+
"node/prefer-global/process": "off",
|
|
1229
1186
|
"vue/block-order": ["error", {
|
|
1230
1187
|
order: ["script", "template", "style"]
|
|
1231
1188
|
}],
|
|
@@ -1238,9 +1195,11 @@ function vue(options = {}) {
|
|
|
1238
1195
|
"vue/dot-location": ["error", "property"],
|
|
1239
1196
|
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
1240
1197
|
"vue/eqeqeq": ["error", "smart"],
|
|
1241
|
-
"vue/
|
|
1242
|
-
"vue/
|
|
1243
|
-
"vue/
|
|
1198
|
+
"vue/html-indent": ["error", indent],
|
|
1199
|
+
"vue/html-quotes": ["error", "double"],
|
|
1200
|
+
"vue/max-attributes-per-line": "off",
|
|
1201
|
+
"vue/multi-word-component-names": "off",
|
|
1202
|
+
"vue/no-dupe-keys": "off",
|
|
1244
1203
|
"vue/no-empty-pattern": "error",
|
|
1245
1204
|
"vue/no-extra-parens": ["error", "functions"],
|
|
1246
1205
|
"vue/no-irregular-whitespace": "error",
|
|
@@ -1252,11 +1211,11 @@ function vue(options = {}) {
|
|
|
1252
1211
|
"WithStatement"
|
|
1253
1212
|
],
|
|
1254
1213
|
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1255
|
-
"vue/no-setup-props-reactivity-loss":
|
|
1214
|
+
"vue/no-setup-props-reactivity-loss": "off",
|
|
1256
1215
|
"vue/no-sparse-arrays": "error",
|
|
1257
1216
|
"vue/no-unused-refs": "error",
|
|
1258
1217
|
"vue/no-useless-v-bind": "error",
|
|
1259
|
-
"vue/no-v-html":
|
|
1218
|
+
"vue/no-v-html": "off",
|
|
1260
1219
|
"vue/object-shorthand": [
|
|
1261
1220
|
"error",
|
|
1262
1221
|
"always",
|
|
@@ -1267,8 +1226,9 @@ function vue(options = {}) {
|
|
|
1267
1226
|
],
|
|
1268
1227
|
"vue/prefer-separate-static-class": "error",
|
|
1269
1228
|
"vue/prefer-template": "error",
|
|
1270
|
-
"vue/
|
|
1271
|
-
"vue/require-prop
|
|
1229
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
1230
|
+
"vue/require-default-prop": "off",
|
|
1231
|
+
"vue/require-prop-types": "off",
|
|
1272
1232
|
"vue/space-infix-ops": "error",
|
|
1273
1233
|
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
1274
1234
|
...stylistic2 ? {
|
|
@@ -1288,7 +1248,7 @@ function vue(options = {}) {
|
|
|
1288
1248
|
}],
|
|
1289
1249
|
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
1290
1250
|
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1291
|
-
"vue/object-curly-newline":
|
|
1251
|
+
"vue/object-curly-newline": "off",
|
|
1292
1252
|
"vue/object-curly-spacing": ["error", "always"],
|
|
1293
1253
|
"vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
1294
1254
|
"vue/operator-linebreak": ["error", "before"],
|
|
@@ -1304,24 +1264,38 @@ function vue(options = {}) {
|
|
|
1304
1264
|
}
|
|
1305
1265
|
|
|
1306
1266
|
// src/configs/yaml.ts
|
|
1307
|
-
function yaml(options = {}) {
|
|
1267
|
+
async function yaml(options = {}) {
|
|
1308
1268
|
const {
|
|
1269
|
+
files = [GLOB_YAML],
|
|
1309
1270
|
overrides = {},
|
|
1310
1271
|
stylistic: stylistic2 = true
|
|
1311
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
|
+
]);
|
|
1312
1284
|
return [
|
|
1313
1285
|
{
|
|
1286
|
+
name: "coderwyd:yaml:setup",
|
|
1314
1287
|
plugins: {
|
|
1315
|
-
yaml:
|
|
1288
|
+
yaml: pluginYaml
|
|
1316
1289
|
}
|
|
1317
1290
|
},
|
|
1318
1291
|
{
|
|
1319
|
-
files
|
|
1292
|
+
files,
|
|
1320
1293
|
languageOptions: {
|
|
1321
|
-
parser:
|
|
1294
|
+
parser: parserYaml
|
|
1322
1295
|
},
|
|
1296
|
+
name: "coderwyd:yaml:rules",
|
|
1323
1297
|
rules: {
|
|
1324
|
-
"style/spaced-comment":
|
|
1298
|
+
"style/spaced-comment": "off",
|
|
1325
1299
|
"yaml/block-mapping": "error",
|
|
1326
1300
|
"yaml/block-sequence": "error",
|
|
1327
1301
|
"yaml/no-empty-key": "error",
|
|
@@ -1336,10 +1310,10 @@ function yaml(options = {}) {
|
|
|
1336
1310
|
"yaml/flow-mapping-curly-spacing": "error",
|
|
1337
1311
|
"yaml/flow-sequence-bracket-newline": "error",
|
|
1338
1312
|
"yaml/flow-sequence-bracket-spacing": "error",
|
|
1339
|
-
"yaml/indent": ["error", 2],
|
|
1313
|
+
"yaml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
1340
1314
|
"yaml/key-spacing": "error",
|
|
1341
1315
|
"yaml/no-tab-indent": "error",
|
|
1342
|
-
"yaml/quotes": ["error", { avoidEscape: false, prefer:
|
|
1316
|
+
"yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
|
|
1343
1317
|
"yaml/spaced-comment": "error"
|
|
1344
1318
|
} : {},
|
|
1345
1319
|
...overrides
|
|
@@ -1349,84 +1323,180 @@ function yaml(options = {}) {
|
|
|
1349
1323
|
}
|
|
1350
1324
|
|
|
1351
1325
|
// src/configs/test.ts
|
|
1352
|
-
function test(options = {}) {
|
|
1326
|
+
async function test(options = {}) {
|
|
1353
1327
|
const {
|
|
1328
|
+
files = GLOB_TESTS,
|
|
1354
1329
|
isInEditor = false,
|
|
1355
1330
|
overrides = {}
|
|
1356
1331
|
} = options;
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1332
|
+
const [
|
|
1333
|
+
pluginVitest,
|
|
1334
|
+
pluginNoOnlyTests
|
|
1335
|
+
] = await Promise.all([
|
|
1336
|
+
interopDefault(import("eslint-plugin-vitest")),
|
|
1337
|
+
// @ts-expect-error missing types
|
|
1338
|
+
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1339
|
+
]);
|
|
1340
|
+
return [
|
|
1341
|
+
{
|
|
1342
|
+
name: "coderwyd:test:setup",
|
|
1343
|
+
plugins: {
|
|
1344
|
+
test: {
|
|
1345
|
+
...pluginVitest,
|
|
1346
|
+
rules: {
|
|
1347
|
+
...pluginVitest.rules,
|
|
1348
|
+
// extend `test/no-only-tests` rule
|
|
1349
|
+
...pluginNoOnlyTests.rules
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
},
|
|
1354
|
+
{
|
|
1355
|
+
files,
|
|
1356
|
+
name: "coderwyd:test:rules",
|
|
1357
|
+
rules: {
|
|
1358
|
+
"node/prefer-global/process": "off",
|
|
1359
|
+
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1360
|
+
"test/no-identical-title": "error",
|
|
1361
|
+
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
1362
|
+
"test/prefer-hooks-in-order": "error",
|
|
1363
|
+
"test/prefer-lowercase-title": "error",
|
|
1364
|
+
...overrides
|
|
1365
|
+
}
|
|
1360
1366
|
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1367
|
+
];
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// src/configs/perfectionist.ts
|
|
1371
|
+
async function perfectionist() {
|
|
1372
|
+
return [
|
|
1373
|
+
{
|
|
1374
|
+
name: "coderwyd:perfectionist",
|
|
1375
|
+
plugins: {
|
|
1376
|
+
perfectionist: import_eslint_plugin_perfectionist.default
|
|
1377
|
+
}
|
|
1366
1378
|
}
|
|
1367
|
-
|
|
1379
|
+
];
|
|
1368
1380
|
}
|
|
1369
1381
|
|
|
1370
1382
|
// src/configs/react.ts
|
|
1371
|
-
|
|
1383
|
+
var import_local_pkg2 = require("local-pkg");
|
|
1384
|
+
var ReactRefreshAllowConstantExportPackages = [
|
|
1385
|
+
"vite"
|
|
1386
|
+
];
|
|
1387
|
+
async function react(options = {}) {
|
|
1372
1388
|
const {
|
|
1373
|
-
|
|
1389
|
+
files = [GLOB_JSX, GLOB_TSX],
|
|
1390
|
+
overrides = {},
|
|
1391
|
+
typescript: typescript2 = true
|
|
1374
1392
|
} = options;
|
|
1393
|
+
await ensurePackages([
|
|
1394
|
+
"eslint-plugin-react",
|
|
1395
|
+
"eslint-plugin-react-hooks",
|
|
1396
|
+
"eslint-plugin-react-refresh"
|
|
1397
|
+
]);
|
|
1398
|
+
const [
|
|
1399
|
+
pluginReact,
|
|
1400
|
+
pluginReactHooks,
|
|
1401
|
+
pluginReactRefresh
|
|
1402
|
+
] = await Promise.all([
|
|
1403
|
+
interopDefault(import("eslint-plugin-react")),
|
|
1404
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1405
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1406
|
+
]);
|
|
1407
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1408
|
+
(i) => (0, import_local_pkg2.isPackageExists)(i)
|
|
1409
|
+
);
|
|
1375
1410
|
return [
|
|
1376
1411
|
{
|
|
1412
|
+
name: "coderwyd:react:setup",
|
|
1377
1413
|
plugins: {
|
|
1378
|
-
"react":
|
|
1379
|
-
"react-hooks":
|
|
1414
|
+
"react": pluginReact,
|
|
1415
|
+
"react-hooks": pluginReactHooks,
|
|
1416
|
+
"react-refresh": pluginReactRefresh
|
|
1380
1417
|
}
|
|
1381
1418
|
},
|
|
1382
1419
|
{
|
|
1383
|
-
files
|
|
1420
|
+
files,
|
|
1384
1421
|
languageOptions: {
|
|
1385
1422
|
parserOptions: {
|
|
1386
1423
|
ecmaFeatures: {
|
|
1387
1424
|
jsx: true
|
|
1388
|
-
}
|
|
1389
|
-
parser: options.typescript ? import_parser.default : null,
|
|
1390
|
-
sourceType: "module"
|
|
1425
|
+
}
|
|
1391
1426
|
}
|
|
1392
1427
|
},
|
|
1428
|
+
name: "coderwyd:react:rules",
|
|
1393
1429
|
rules: {
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
"react/
|
|
1397
|
-
|
|
1430
|
+
// recommended rules react-hooks
|
|
1431
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
1432
|
+
"react-hooks/rules-of-hooks": "error",
|
|
1433
|
+
// react refresh
|
|
1434
|
+
"react-refresh/only-export-components": [
|
|
1435
|
+
"warn",
|
|
1436
|
+
{ allowConstantExport: isAllowConstantExport }
|
|
1437
|
+
],
|
|
1438
|
+
// recommended rules react
|
|
1439
|
+
"react/display-name": "error",
|
|
1440
|
+
"react/jsx-key": "error",
|
|
1441
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
1442
|
+
"react/jsx-no-duplicate-props": "error",
|
|
1443
|
+
"react/jsx-no-target-blank": "error",
|
|
1444
|
+
"react/jsx-no-undef": "error",
|
|
1445
|
+
"react/jsx-uses-react": "error",
|
|
1446
|
+
"react/jsx-uses-vars": "error",
|
|
1447
|
+
"react/no-children-prop": "error",
|
|
1448
|
+
"react/no-danger-with-children": "error",
|
|
1449
|
+
"react/no-deprecated": "error",
|
|
1450
|
+
"react/no-direct-mutation-state": "error",
|
|
1451
|
+
"react/no-find-dom-node": "error",
|
|
1452
|
+
"react/no-is-mounted": "error",
|
|
1453
|
+
"react/no-render-return-value": "error",
|
|
1454
|
+
"react/no-string-refs": "error",
|
|
1455
|
+
"react/no-unescaped-entities": "error",
|
|
1456
|
+
"react/no-unknown-property": "error",
|
|
1457
|
+
"react/no-unsafe": "off",
|
|
1458
|
+
"react/prop-types": "error",
|
|
1459
|
+
"react/react-in-jsx-scope": "off",
|
|
1460
|
+
"react/require-render-return": "error",
|
|
1461
|
+
...typescript2 ? {
|
|
1462
|
+
"react/jsx-no-undef": "off",
|
|
1463
|
+
"react/prop-type": "off"
|
|
1464
|
+
} : {},
|
|
1465
|
+
// overrides
|
|
1398
1466
|
...overrides
|
|
1399
|
-
},
|
|
1400
|
-
settings: {
|
|
1401
|
-
react: {
|
|
1402
|
-
version: "detect"
|
|
1403
|
-
}
|
|
1404
1467
|
}
|
|
1405
1468
|
}
|
|
1406
1469
|
];
|
|
1407
1470
|
}
|
|
1408
1471
|
|
|
1409
|
-
// src/configs/
|
|
1410
|
-
function
|
|
1411
|
-
const {
|
|
1472
|
+
// src/configs/unocss.ts
|
|
1473
|
+
async function unocss(options = {}) {
|
|
1474
|
+
const {
|
|
1475
|
+
attributify = true,
|
|
1476
|
+
strict = false
|
|
1477
|
+
} = options;
|
|
1478
|
+
await ensurePackages([
|
|
1479
|
+
"@unocss/eslint-plugin"
|
|
1480
|
+
]);
|
|
1481
|
+
const [
|
|
1482
|
+
pluginUnoCSS
|
|
1483
|
+
] = await Promise.all([
|
|
1484
|
+
interopDefault(import("@unocss/eslint-plugin"))
|
|
1485
|
+
]);
|
|
1412
1486
|
return [
|
|
1413
1487
|
{
|
|
1488
|
+
name: "antfu:unocss",
|
|
1414
1489
|
plugins: {
|
|
1415
|
-
|
|
1416
|
-
}
|
|
1417
|
-
},
|
|
1418
|
-
{
|
|
1419
|
-
files: [GLOB_ASTRO],
|
|
1420
|
-
languageOptions: {
|
|
1421
|
-
parser: import_astro_eslint_parser.default,
|
|
1422
|
-
parserOptions: {
|
|
1423
|
-
extraFileExtensions: [".astro"],
|
|
1424
|
-
parser: options.typescript ? import_parser.default : null
|
|
1425
|
-
}
|
|
1490
|
+
unocss: pluginUnoCSS
|
|
1426
1491
|
},
|
|
1427
1492
|
rules: {
|
|
1428
|
-
|
|
1429
|
-
...
|
|
1493
|
+
"unocss/order": "warn",
|
|
1494
|
+
...attributify ? {
|
|
1495
|
+
"unocss/order-attributify": "warn"
|
|
1496
|
+
} : {},
|
|
1497
|
+
...strict ? {
|
|
1498
|
+
"unocss/blocklist": "error"
|
|
1499
|
+
} : {}
|
|
1430
1500
|
}
|
|
1431
1501
|
}
|
|
1432
1502
|
];
|
|
@@ -1449,46 +1519,46 @@ var VuePackages = [
|
|
|
1449
1519
|
"vitepress",
|
|
1450
1520
|
"@slidev/cli"
|
|
1451
1521
|
];
|
|
1452
|
-
|
|
1453
|
-
"react",
|
|
1454
|
-
"next"
|
|
1455
|
-
];
|
|
1456
|
-
var AstroPackages = [
|
|
1457
|
-
"astro"
|
|
1458
|
-
];
|
|
1459
|
-
function coderwyd(options = {}, ...userConfigs) {
|
|
1522
|
+
async function coderwyd(options = {}, ...userConfigs) {
|
|
1460
1523
|
const {
|
|
1461
|
-
|
|
1462
|
-
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
|
|
1463
|
-
react: enableReact = ReactPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
|
|
1464
|
-
astro: enableAstro = AstroPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
|
|
1465
|
-
typescript: enableTypeScript = (0, import_local_pkg2.isPackageExists)("typescript"),
|
|
1466
|
-
stylistic: enableStylistic = true,
|
|
1524
|
+
componentExts = [],
|
|
1467
1525
|
gitignore: enableGitignore = true,
|
|
1526
|
+
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
|
|
1468
1527
|
overrides = {},
|
|
1469
|
-
|
|
1528
|
+
react: enableReact = false,
|
|
1529
|
+
typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
|
|
1530
|
+
unocss: enableUnoCSS = false,
|
|
1531
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
|
|
1470
1532
|
} = options;
|
|
1533
|
+
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1534
|
+
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
1535
|
+
stylisticOptions.jsx = options.jsx ?? true;
|
|
1471
1536
|
const configs = [];
|
|
1472
1537
|
if (enableGitignore) {
|
|
1473
1538
|
if (typeof enableGitignore !== "boolean") {
|
|
1474
|
-
configs.push(
|
|
1539
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1475
1540
|
} else {
|
|
1476
1541
|
if (import_node_fs.default.existsSync(".gitignore"))
|
|
1477
|
-
configs.push(
|
|
1542
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
1478
1543
|
}
|
|
1479
1544
|
}
|
|
1480
1545
|
configs.push(
|
|
1481
1546
|
ignores(),
|
|
1482
|
-
javascript({
|
|
1547
|
+
javascript({
|
|
1548
|
+
isInEditor,
|
|
1549
|
+
overrides: overrides.javascript
|
|
1550
|
+
}),
|
|
1483
1551
|
comments(),
|
|
1484
1552
|
node(),
|
|
1485
1553
|
jsdoc({
|
|
1486
|
-
stylistic:
|
|
1554
|
+
stylistic: stylisticOptions
|
|
1487
1555
|
}),
|
|
1488
1556
|
imports({
|
|
1489
|
-
stylistic:
|
|
1557
|
+
stylistic: stylisticOptions
|
|
1490
1558
|
}),
|
|
1491
|
-
unicorn()
|
|
1559
|
+
unicorn(),
|
|
1560
|
+
// Optional plugins (installed but not enabled by default)
|
|
1561
|
+
perfectionist()
|
|
1492
1562
|
);
|
|
1493
1563
|
if (enableVue)
|
|
1494
1564
|
componentExts.push("vue");
|
|
@@ -1499,14 +1569,18 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1499
1569
|
overrides: overrides.typescript
|
|
1500
1570
|
}));
|
|
1501
1571
|
}
|
|
1502
|
-
if (
|
|
1503
|
-
configs.push(stylistic());
|
|
1504
|
-
if (options.test ?? true)
|
|
1505
|
-
configs.push(test({
|
|
1572
|
+
if (stylisticOptions)
|
|
1573
|
+
configs.push(stylistic(stylisticOptions));
|
|
1574
|
+
if (options.test ?? true) {
|
|
1575
|
+
configs.push(test({
|
|
1576
|
+
isInEditor,
|
|
1577
|
+
overrides: overrides.test
|
|
1578
|
+
}));
|
|
1579
|
+
}
|
|
1506
1580
|
if (enableVue) {
|
|
1507
1581
|
configs.push(vue({
|
|
1508
1582
|
overrides: overrides.vue,
|
|
1509
|
-
stylistic:
|
|
1583
|
+
stylistic: stylisticOptions,
|
|
1510
1584
|
typescript: !!enableTypeScript
|
|
1511
1585
|
}));
|
|
1512
1586
|
}
|
|
@@ -1516,15 +1590,17 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1516
1590
|
typescript: !!enableTypeScript
|
|
1517
1591
|
}));
|
|
1518
1592
|
}
|
|
1519
|
-
if (
|
|
1520
|
-
configs.push(
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
}));
|
|
1593
|
+
if (enableUnoCSS) {
|
|
1594
|
+
configs.push(unocss(
|
|
1595
|
+
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1596
|
+
));
|
|
1524
1597
|
}
|
|
1525
1598
|
if (options.jsonc ?? true) {
|
|
1526
1599
|
configs.push(
|
|
1527
|
-
jsonc(
|
|
1600
|
+
jsonc({
|
|
1601
|
+
overrides: overrides.jsonc,
|
|
1602
|
+
stylistic: stylisticOptions
|
|
1603
|
+
}),
|
|
1528
1604
|
sortPackageJson(),
|
|
1529
1605
|
sortTsconfig()
|
|
1530
1606
|
);
|
|
@@ -1532,11 +1608,15 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1532
1608
|
if (options.yaml ?? true) {
|
|
1533
1609
|
configs.push(yaml({
|
|
1534
1610
|
overrides: overrides.yaml,
|
|
1535
|
-
stylistic:
|
|
1611
|
+
stylistic: stylisticOptions
|
|
1612
|
+
}));
|
|
1613
|
+
}
|
|
1614
|
+
if (options.markdown ?? true) {
|
|
1615
|
+
configs.push(markdown({
|
|
1616
|
+
componentExts,
|
|
1617
|
+
overrides: overrides.markdown
|
|
1536
1618
|
}));
|
|
1537
1619
|
}
|
|
1538
|
-
if (options.markdown ?? true)
|
|
1539
|
-
configs.push(markdown({ componentExts, overrides: overrides.markdown }));
|
|
1540
1620
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1541
1621
|
if (key in options)
|
|
1542
1622
|
acc[key] = options[key];
|
|
@@ -1556,7 +1636,6 @@ var src_default = coderwyd;
|
|
|
1556
1636
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1557
1637
|
0 && (module.exports = {
|
|
1558
1638
|
GLOB_ALL_SRC,
|
|
1559
|
-
GLOB_ASTRO,
|
|
1560
1639
|
GLOB_CSS,
|
|
1561
1640
|
GLOB_EXCLUDE,
|
|
1562
1641
|
GLOB_HTML,
|
|
@@ -1577,48 +1656,30 @@ var src_default = coderwyd;
|
|
|
1577
1656
|
GLOB_TSX,
|
|
1578
1657
|
GLOB_VUE,
|
|
1579
1658
|
GLOB_YAML,
|
|
1580
|
-
astro,
|
|
1581
1659
|
coderwyd,
|
|
1582
1660
|
combine,
|
|
1583
1661
|
comments,
|
|
1662
|
+
ensurePackages,
|
|
1584
1663
|
getVueVersion,
|
|
1585
1664
|
ignores,
|
|
1586
1665
|
imports,
|
|
1666
|
+
interopDefault,
|
|
1587
1667
|
javascript,
|
|
1588
1668
|
jsdoc,
|
|
1589
1669
|
jsonc,
|
|
1590
1670
|
markdown,
|
|
1591
1671
|
node,
|
|
1592
|
-
|
|
1593
|
-
parserJsonc,
|
|
1594
|
-
parserTs,
|
|
1595
|
-
parserVue,
|
|
1596
|
-
parserYaml,
|
|
1597
|
-
pluginAntfu,
|
|
1598
|
-
pluginAstro,
|
|
1599
|
-
pluginComments,
|
|
1600
|
-
pluginImport,
|
|
1601
|
-
pluginJsdoc,
|
|
1602
|
-
pluginJsonc,
|
|
1603
|
-
pluginMarkdown,
|
|
1604
|
-
pluginNoOnlyTests,
|
|
1605
|
-
pluginNode,
|
|
1606
|
-
pluginReact,
|
|
1607
|
-
pluginReactHooks,
|
|
1608
|
-
pluginStylistic,
|
|
1609
|
-
pluginTs,
|
|
1610
|
-
pluginUnicorn,
|
|
1611
|
-
pluginUnusedImports,
|
|
1612
|
-
pluginVue,
|
|
1613
|
-
pluginYaml,
|
|
1672
|
+
perfectionist,
|
|
1614
1673
|
react,
|
|
1615
1674
|
renameRules,
|
|
1616
1675
|
sortPackageJson,
|
|
1617
1676
|
sortTsconfig,
|
|
1618
1677
|
stylistic,
|
|
1619
1678
|
test,
|
|
1679
|
+
toArray,
|
|
1620
1680
|
typescript,
|
|
1621
1681
|
unicorn,
|
|
1682
|
+
unocss,
|
|
1622
1683
|
vue,
|
|
1623
1684
|
yaml
|
|
1624
1685
|
});
|