@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.js
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
2
|
import process3 from "process";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import { isPackageExists } from "local-pkg";
|
|
5
|
-
import gitignore from "eslint-config-flat-gitignore";
|
|
4
|
+
import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
6
5
|
|
|
7
6
|
// src/plugins.ts
|
|
8
7
|
import { default as default2 } from "eslint-plugin-antfu";
|
|
9
8
|
import { default as default3 } from "eslint-plugin-eslint-comments";
|
|
10
|
-
import
|
|
11
|
-
import { default as
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as default9 } from "@stylistic/eslint-plugin";
|
|
16
|
-
import { default as default10 } from "@typescript-eslint/eslint-plugin";
|
|
17
|
-
import { default as default11 } from "eslint-plugin-unicorn";
|
|
18
|
-
import { default as default12 } from "eslint-plugin-unused-imports";
|
|
19
|
-
import { default as default13 } from "eslint-plugin-vue";
|
|
20
|
-
import { default as default14 } from "eslint-plugin-yml";
|
|
21
|
-
import { default as default15 } from "eslint-plugin-no-only-tests";
|
|
22
|
-
import { default as default16 } from "eslint-plugin-react";
|
|
23
|
-
import { default as default17 } from "eslint-plugin-react-hooks";
|
|
24
|
-
import { default as default18 } from "eslint-plugin-astro";
|
|
25
|
-
import { default as default19 } from "@typescript-eslint/parser";
|
|
26
|
-
import { default as default20 } from "vue-eslint-parser";
|
|
27
|
-
import { default as default21 } from "yaml-eslint-parser";
|
|
28
|
-
import { default as default22 } from "jsonc-eslint-parser";
|
|
29
|
-
import { default as default23 } from "astro-eslint-parser";
|
|
9
|
+
import * as pluginImport from "eslint-plugin-i";
|
|
10
|
+
import { default as default4 } from "eslint-plugin-n";
|
|
11
|
+
import { default as default5 } from "eslint-plugin-unicorn";
|
|
12
|
+
import { default as default6 } from "eslint-plugin-unused-imports";
|
|
13
|
+
import { default as default7 } from "eslint-plugin-perfectionist";
|
|
30
14
|
|
|
31
15
|
// src/configs/comments.ts
|
|
32
|
-
function comments() {
|
|
16
|
+
async function comments() {
|
|
33
17
|
return [
|
|
34
18
|
{
|
|
19
|
+
name: "coderwyd:eslint-comments",
|
|
35
20
|
plugins: {
|
|
36
21
|
"eslint-comments": default3
|
|
37
22
|
},
|
|
@@ -63,12 +48,13 @@ var GLOB_MARKDOWN = "**/*.md";
|
|
|
63
48
|
var GLOB_VUE = "**/*.vue";
|
|
64
49
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
65
50
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
66
|
-
var GLOB_ASTRO = "**/*.astro";
|
|
67
51
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
68
52
|
var GLOB_TESTS = [
|
|
69
53
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
70
54
|
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
71
|
-
`**/*.test.${GLOB_SRC_EXT}
|
|
55
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
56
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
57
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
72
58
|
];
|
|
73
59
|
var GLOB_ALL_SRC = [
|
|
74
60
|
GLOB_SRC,
|
|
@@ -86,14 +72,21 @@ var GLOB_EXCLUDE = [
|
|
|
86
72
|
"**/package-lock.json",
|
|
87
73
|
"**/yarn.lock",
|
|
88
74
|
"**/pnpm-lock.yaml",
|
|
75
|
+
"**/bun.lockb",
|
|
89
76
|
"**/output",
|
|
90
77
|
"**/coverage",
|
|
91
78
|
"**/temp",
|
|
79
|
+
"**/.temp",
|
|
80
|
+
"**/tmp",
|
|
81
|
+
"**/.tmp",
|
|
82
|
+
"**/.history",
|
|
92
83
|
"**/.vitepress/cache",
|
|
93
84
|
"**/.nuxt",
|
|
85
|
+
"**/.next",
|
|
94
86
|
"**/.vercel",
|
|
95
87
|
"**/.changeset",
|
|
96
88
|
"**/.idea",
|
|
89
|
+
"**/.cache",
|
|
97
90
|
"**/.output",
|
|
98
91
|
"**/.vite-inspect",
|
|
99
92
|
"**/CHANGELOG*.md",
|
|
@@ -105,27 +98,29 @@ var GLOB_EXCLUDE = [
|
|
|
105
98
|
];
|
|
106
99
|
|
|
107
100
|
// src/configs/ignores.ts
|
|
108
|
-
function ignores() {
|
|
101
|
+
async function ignores() {
|
|
109
102
|
return [
|
|
110
|
-
{
|
|
103
|
+
{
|
|
104
|
+
ignores: GLOB_EXCLUDE
|
|
105
|
+
}
|
|
111
106
|
];
|
|
112
107
|
}
|
|
113
108
|
|
|
114
109
|
// src/configs/imports.ts
|
|
115
|
-
function imports(options = {}) {
|
|
110
|
+
async function imports(options = {}) {
|
|
116
111
|
const {
|
|
117
112
|
stylistic: stylistic2 = true
|
|
118
113
|
} = options;
|
|
119
114
|
return [
|
|
120
115
|
{
|
|
116
|
+
name: "coderwyd:imports",
|
|
121
117
|
plugins: {
|
|
122
118
|
antfu: default2,
|
|
123
|
-
import:
|
|
119
|
+
import: pluginImport
|
|
124
120
|
},
|
|
125
121
|
rules: {
|
|
126
122
|
"antfu/import-dedupe": "error",
|
|
127
123
|
"antfu/no-import-node-modules-by-path": "error",
|
|
128
|
-
"import/export": "error",
|
|
129
124
|
"import/first": "error",
|
|
130
125
|
"import/no-duplicates": "error",
|
|
131
126
|
"import/no-mutable-exports": "error",
|
|
@@ -143,23 +138,12 @@ function imports(options = {}) {
|
|
|
143
138
|
|
|
144
139
|
// src/configs/javascript.ts
|
|
145
140
|
import globals from "globals";
|
|
146
|
-
|
|
147
|
-
// src/flags.ts
|
|
148
|
-
var OFF = 0;
|
|
149
|
-
|
|
150
|
-
// src/configs/javascript.ts
|
|
151
|
-
function javascript(options = {}) {
|
|
141
|
+
async function javascript(options = {}) {
|
|
152
142
|
const {
|
|
153
143
|
isInEditor = false,
|
|
154
144
|
overrides = {}
|
|
155
145
|
} = options;
|
|
156
146
|
return [
|
|
157
|
-
{
|
|
158
|
-
plugins: {
|
|
159
|
-
"antfu": default2,
|
|
160
|
-
"unused-imports": default12
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
147
|
{
|
|
164
148
|
languageOptions: {
|
|
165
149
|
ecmaVersion: 2022,
|
|
@@ -180,20 +164,23 @@ function javascript(options = {}) {
|
|
|
180
164
|
},
|
|
181
165
|
sourceType: "module"
|
|
182
166
|
},
|
|
167
|
+
linterOptions: {
|
|
168
|
+
reportUnusedDisableDirectives: true
|
|
169
|
+
},
|
|
170
|
+
name: "coderwyd:javascript",
|
|
171
|
+
plugins: {
|
|
172
|
+
"antfu": default2,
|
|
173
|
+
"unused-imports": default6
|
|
174
|
+
},
|
|
183
175
|
rules: {
|
|
184
176
|
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
185
|
-
"antfu/top-level-function": "error",
|
|
186
177
|
"array-callback-return": "error",
|
|
187
|
-
"arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
|
|
188
178
|
"block-scoped-var": "error",
|
|
189
179
|
"constructor-super": "error",
|
|
190
180
|
"default-case-last": "error",
|
|
191
181
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
192
|
-
"eol-last": "error",
|
|
193
182
|
"eqeqeq": ["error", "smart"],
|
|
194
|
-
"max-statements-per-line": ["error", { max: 1 }],
|
|
195
183
|
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
|
|
196
|
-
"new-parens": "error",
|
|
197
184
|
"no-alert": "error",
|
|
198
185
|
"no-array-constructor": "error",
|
|
199
186
|
"no-async-promise-executor": "error",
|
|
@@ -204,7 +191,6 @@ function javascript(options = {}) {
|
|
|
204
191
|
"no-cond-assign": ["error", "always"],
|
|
205
192
|
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
206
193
|
"no-const-assign": "error",
|
|
207
|
-
"no-constant-condition": "warn",
|
|
208
194
|
"no-control-regex": "error",
|
|
209
195
|
"no-debugger": "error",
|
|
210
196
|
"no-delete-var": "error",
|
|
@@ -220,29 +206,18 @@ function javascript(options = {}) {
|
|
|
220
206
|
"no-extend-native": "error",
|
|
221
207
|
"no-extra-bind": "error",
|
|
222
208
|
"no-extra-boolean-cast": "error",
|
|
223
|
-
"no-extra-parens": ["error", "functions"],
|
|
224
209
|
"no-fallthrough": "error",
|
|
225
|
-
"no-floating-decimal": "error",
|
|
226
210
|
"no-func-assign": "error",
|
|
227
211
|
"no-global-assign": "error",
|
|
228
212
|
"no-implied-eval": "error",
|
|
229
213
|
"no-import-assign": "error",
|
|
230
214
|
"no-invalid-regexp": "error",
|
|
231
|
-
"no-invalid-this": "error",
|
|
232
215
|
"no-irregular-whitespace": "error",
|
|
233
216
|
"no-iterator": "error",
|
|
234
217
|
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
235
218
|
"no-lone-blocks": "error",
|
|
236
219
|
"no-loss-of-precision": "error",
|
|
237
220
|
"no-misleading-character-class": "error",
|
|
238
|
-
"no-mixed-operators": ["error", {
|
|
239
|
-
allowSamePrecedence: true,
|
|
240
|
-
groups: [
|
|
241
|
-
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
|
242
|
-
["&&", "||"],
|
|
243
|
-
["in", "instanceof"]
|
|
244
|
-
]
|
|
245
|
-
}],
|
|
246
221
|
"no-multi-str": "error",
|
|
247
222
|
"no-new": "error",
|
|
248
223
|
"no-new-func": "error",
|
|
@@ -273,7 +248,9 @@ function javascript(options = {}) {
|
|
|
273
248
|
"error",
|
|
274
249
|
"DebuggerStatement",
|
|
275
250
|
"LabeledStatement",
|
|
276
|
-
"WithStatement"
|
|
251
|
+
"WithStatement",
|
|
252
|
+
"TSEnumDeclaration[const=true]",
|
|
253
|
+
"TSExportAssignment"
|
|
277
254
|
],
|
|
278
255
|
"no-self-assign": ["error", { props: true }],
|
|
279
256
|
"no-self-compare": "error",
|
|
@@ -312,7 +289,6 @@ function javascript(options = {}) {
|
|
|
312
289
|
"no-useless-rename": "error",
|
|
313
290
|
"no-useless-return": "error",
|
|
314
291
|
"no-var": "error",
|
|
315
|
-
"no-void": "error",
|
|
316
292
|
"no-with": "error",
|
|
317
293
|
"object-shorthand": [
|
|
318
294
|
"error",
|
|
@@ -343,7 +319,6 @@ function javascript(options = {}) {
|
|
|
343
319
|
"prefer-rest-params": "error",
|
|
344
320
|
"prefer-spread": "error",
|
|
345
321
|
"prefer-template": "error",
|
|
346
|
-
"quote-props": ["error", "consistent-as-needed"],
|
|
347
322
|
"sort-imports": [
|
|
348
323
|
"error",
|
|
349
324
|
{
|
|
@@ -356,7 +331,7 @@ function javascript(options = {}) {
|
|
|
356
331
|
],
|
|
357
332
|
"symbol-description": "error",
|
|
358
333
|
"unicode-bom": ["error", "never"],
|
|
359
|
-
"unused-imports/no-unused-imports": isInEditor ?
|
|
334
|
+
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
360
335
|
"unused-imports/no-unused-vars": [
|
|
361
336
|
"error",
|
|
362
337
|
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
|
|
@@ -364,32 +339,79 @@ function javascript(options = {}) {
|
|
|
364
339
|
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
|
|
365
340
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
366
341
|
"vars-on-top": "error",
|
|
367
|
-
"wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
|
|
368
342
|
"yoda": ["error", "never"],
|
|
369
343
|
...overrides
|
|
370
344
|
}
|
|
371
345
|
},
|
|
372
346
|
{
|
|
373
347
|
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
348
|
+
name: "coderwyd:scripts-overrides",
|
|
374
349
|
rules: {
|
|
375
|
-
"no-console":
|
|
350
|
+
"no-console": "off"
|
|
376
351
|
}
|
|
377
352
|
}
|
|
378
353
|
];
|
|
379
354
|
}
|
|
380
355
|
|
|
356
|
+
// src/utils.ts
|
|
357
|
+
import process from "process";
|
|
358
|
+
import { getPackageInfoSync, isPackageExists } from "local-pkg";
|
|
359
|
+
async function combine(...configs) {
|
|
360
|
+
const resolved = await Promise.all(configs);
|
|
361
|
+
return resolved.flat();
|
|
362
|
+
}
|
|
363
|
+
function renameRules(rules, from, to) {
|
|
364
|
+
return Object.fromEntries(
|
|
365
|
+
Object.entries(rules).map(([key, value]) => {
|
|
366
|
+
if (key.startsWith(from))
|
|
367
|
+
return [to + key.slice(from.length), value];
|
|
368
|
+
return [key, value];
|
|
369
|
+
})
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
function getVueVersion() {
|
|
373
|
+
const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] });
|
|
374
|
+
if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
|
|
375
|
+
return +pkg.version[0];
|
|
376
|
+
return 3;
|
|
377
|
+
}
|
|
378
|
+
function toArray(value) {
|
|
379
|
+
return Array.isArray(value) ? value : [value];
|
|
380
|
+
}
|
|
381
|
+
async function interopDefault(m) {
|
|
382
|
+
const resolved = await m;
|
|
383
|
+
return resolved.default || resolved;
|
|
384
|
+
}
|
|
385
|
+
async function ensurePackages(packages) {
|
|
386
|
+
if (process.env.CI || process.stdout.isTTY === false)
|
|
387
|
+
return;
|
|
388
|
+
const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
|
|
389
|
+
if (nonExistingPackages.length === 0)
|
|
390
|
+
return;
|
|
391
|
+
const { default: prompts } = await import("prompts");
|
|
392
|
+
const { result } = await prompts([
|
|
393
|
+
{
|
|
394
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
395
|
+
name: "result",
|
|
396
|
+
type: "confirm"
|
|
397
|
+
}
|
|
398
|
+
]);
|
|
399
|
+
if (result)
|
|
400
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
401
|
+
}
|
|
402
|
+
|
|
381
403
|
// src/configs/jsdoc.ts
|
|
382
|
-
function jsdoc(options = {}) {
|
|
404
|
+
async function jsdoc(options = {}) {
|
|
383
405
|
const {
|
|
384
406
|
stylistic: stylistic2 = true
|
|
385
407
|
} = options;
|
|
386
408
|
return [
|
|
387
409
|
{
|
|
410
|
+
name: "coderwyd:jsdoc",
|
|
388
411
|
plugins: {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
{
|
|
412
|
+
// @ts-expect-error missing types
|
|
413
|
+
jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
|
|
414
|
+
},
|
|
393
415
|
rules: {
|
|
394
416
|
"jsdoc/check-access": "warn",
|
|
395
417
|
"jsdoc/check-param-names": "warn",
|
|
@@ -406,7 +428,6 @@ function jsdoc(options = {}) {
|
|
|
406
428
|
"jsdoc/require-returns-check": "warn",
|
|
407
429
|
"jsdoc/require-returns-description": "warn",
|
|
408
430
|
"jsdoc/require-yields-check": "warn",
|
|
409
|
-
"jsdoc/valid-types": "warn",
|
|
410
431
|
...stylistic2 ? {
|
|
411
432
|
"jsdoc/check-alignment": "warn",
|
|
412
433
|
"jsdoc/multiline-blocks": "warn"
|
|
@@ -417,22 +438,35 @@ function jsdoc(options = {}) {
|
|
|
417
438
|
}
|
|
418
439
|
|
|
419
440
|
// src/configs/jsonc.ts
|
|
420
|
-
function jsonc(options = {}) {
|
|
441
|
+
async function jsonc(options = {}) {
|
|
421
442
|
const {
|
|
422
|
-
|
|
423
|
-
overrides = {}
|
|
443
|
+
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
444
|
+
overrides = {},
|
|
445
|
+
stylistic: stylistic2 = true
|
|
424
446
|
} = options;
|
|
447
|
+
const {
|
|
448
|
+
indent = 2
|
|
449
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
450
|
+
const [
|
|
451
|
+
pluginJsonc,
|
|
452
|
+
parserJsonc
|
|
453
|
+
] = await Promise.all([
|
|
454
|
+
interopDefault(import("eslint-plugin-jsonc")),
|
|
455
|
+
interopDefault(import("jsonc-eslint-parser"))
|
|
456
|
+
]);
|
|
425
457
|
return [
|
|
426
458
|
{
|
|
459
|
+
name: "coderwyd:jsonc:setup",
|
|
427
460
|
plugins: {
|
|
428
|
-
jsonc:
|
|
461
|
+
jsonc: pluginJsonc
|
|
429
462
|
}
|
|
430
463
|
},
|
|
431
464
|
{
|
|
432
|
-
files
|
|
465
|
+
files,
|
|
433
466
|
languageOptions: {
|
|
434
|
-
parser:
|
|
467
|
+
parser: parserJsonc
|
|
435
468
|
},
|
|
469
|
+
name: "coderwyd:jsonc:rules",
|
|
436
470
|
rules: {
|
|
437
471
|
"jsonc/no-bigint-literals": "error",
|
|
438
472
|
"jsonc/no-binary-expression": "error",
|
|
@@ -464,7 +498,7 @@ function jsonc(options = {}) {
|
|
|
464
498
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
465
499
|
"jsonc/comma-dangle": ["error", "never"],
|
|
466
500
|
"jsonc/comma-style": ["error", "last"],
|
|
467
|
-
"jsonc/indent": ["error",
|
|
501
|
+
"jsonc/indent": ["error", indent],
|
|
468
502
|
"jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
469
503
|
"jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
|
|
470
504
|
"jsonc/object-curly-spacing": ["error", "always"],
|
|
@@ -479,19 +513,23 @@ function jsonc(options = {}) {
|
|
|
479
513
|
}
|
|
480
514
|
|
|
481
515
|
// src/configs/markdown.ts
|
|
482
|
-
function markdown(options = {}) {
|
|
516
|
+
async function markdown(options = {}) {
|
|
483
517
|
const {
|
|
484
518
|
componentExts = [],
|
|
519
|
+
files = [GLOB_MARKDOWN],
|
|
485
520
|
overrides = {}
|
|
486
521
|
} = options;
|
|
487
522
|
return [
|
|
488
523
|
{
|
|
524
|
+
name: "coderwyd:markdown:setup",
|
|
489
525
|
plugins: {
|
|
490
|
-
|
|
526
|
+
// @ts-expect-error missing types
|
|
527
|
+
markdown: await interopDefault(import("eslint-plugin-markdown"))
|
|
491
528
|
}
|
|
492
529
|
},
|
|
493
530
|
{
|
|
494
|
-
files
|
|
531
|
+
files,
|
|
532
|
+
name: "coderwyd:markdown:processor",
|
|
495
533
|
processor: "markdown/markdown"
|
|
496
534
|
},
|
|
497
535
|
{
|
|
@@ -506,45 +544,50 @@ function markdown(options = {}) {
|
|
|
506
544
|
}
|
|
507
545
|
}
|
|
508
546
|
},
|
|
547
|
+
name: "coderwyd:markdown:rules",
|
|
509
548
|
rules: {
|
|
510
|
-
"antfu/no-
|
|
511
|
-
"
|
|
512
|
-
"
|
|
513
|
-
"no-
|
|
514
|
-
"no-
|
|
515
|
-
"no-
|
|
516
|
-
"no-
|
|
517
|
-
"no-
|
|
518
|
-
"
|
|
519
|
-
"
|
|
520
|
-
"
|
|
521
|
-
"
|
|
522
|
-
"
|
|
523
|
-
"
|
|
524
|
-
"ts/
|
|
525
|
-
"ts/no-
|
|
526
|
-
"ts/no-
|
|
549
|
+
"antfu/no-ts-export-equal": "off",
|
|
550
|
+
"import/newline-after-import": "off",
|
|
551
|
+
"no-alert": "off",
|
|
552
|
+
"no-console": "off",
|
|
553
|
+
"no-labels": "off",
|
|
554
|
+
"no-lone-blocks": "off",
|
|
555
|
+
"no-restricted-syntax": "off",
|
|
556
|
+
"no-undef": "off",
|
|
557
|
+
"no-unused-expressions": "off",
|
|
558
|
+
"no-unused-labels": "off",
|
|
559
|
+
"no-unused-vars": "off",
|
|
560
|
+
"node/prefer-global/process": "off",
|
|
561
|
+
"style/comma-dangle": "off",
|
|
562
|
+
"style/eol-last": "off",
|
|
563
|
+
"ts/consistent-type-imports": "off",
|
|
564
|
+
"ts/no-namespace": "off",
|
|
565
|
+
"ts/no-redeclare": "off",
|
|
566
|
+
"ts/no-require-imports": "off",
|
|
567
|
+
"ts/no-unused-vars": "off",
|
|
568
|
+
"ts/no-use-before-define": "off",
|
|
569
|
+
"ts/no-var-requires": "off",
|
|
527
570
|
"unicode-bom": "off",
|
|
528
|
-
"unused-imports/no-unused-imports":
|
|
529
|
-
"unused-imports/no-unused-vars":
|
|
571
|
+
"unused-imports/no-unused-imports": "off",
|
|
572
|
+
"unused-imports/no-unused-vars": "off",
|
|
530
573
|
// Type aware rules
|
|
531
574
|
...{
|
|
532
|
-
"ts/await-thenable":
|
|
533
|
-
"ts/dot-notation":
|
|
534
|
-
"ts/no-floating-promises":
|
|
535
|
-
"ts/no-for-in-array":
|
|
536
|
-
"ts/no-implied-eval":
|
|
537
|
-
"ts/no-misused-promises":
|
|
538
|
-
"ts/no-throw-literal":
|
|
539
|
-
"ts/no-unnecessary-type-assertion":
|
|
540
|
-
"ts/no-unsafe-argument":
|
|
541
|
-
"ts/no-unsafe-assignment":
|
|
542
|
-
"ts/no-unsafe-call":
|
|
543
|
-
"ts/no-unsafe-member-access":
|
|
544
|
-
"ts/no-unsafe-return":
|
|
545
|
-
"ts/restrict-plus-operands":
|
|
546
|
-
"ts/restrict-template-expressions":
|
|
547
|
-
"ts/unbound-method":
|
|
575
|
+
"ts/await-thenable": "off",
|
|
576
|
+
"ts/dot-notation": "off",
|
|
577
|
+
"ts/no-floating-promises": "off",
|
|
578
|
+
"ts/no-for-in-array": "off",
|
|
579
|
+
"ts/no-implied-eval": "off",
|
|
580
|
+
"ts/no-misused-promises": "off",
|
|
581
|
+
"ts/no-throw-literal": "off",
|
|
582
|
+
"ts/no-unnecessary-type-assertion": "off",
|
|
583
|
+
"ts/no-unsafe-argument": "off",
|
|
584
|
+
"ts/no-unsafe-assignment": "off",
|
|
585
|
+
"ts/no-unsafe-call": "off",
|
|
586
|
+
"ts/no-unsafe-member-access": "off",
|
|
587
|
+
"ts/no-unsafe-return": "off",
|
|
588
|
+
"ts/restrict-plus-operands": "off",
|
|
589
|
+
"ts/restrict-template-expressions": "off",
|
|
590
|
+
"ts/unbound-method": "off"
|
|
548
591
|
},
|
|
549
592
|
...overrides
|
|
550
593
|
}
|
|
@@ -553,11 +596,12 @@ function markdown(options = {}) {
|
|
|
553
596
|
}
|
|
554
597
|
|
|
555
598
|
// src/configs/node.ts
|
|
556
|
-
function node() {
|
|
599
|
+
async function node() {
|
|
557
600
|
return [
|
|
558
601
|
{
|
|
602
|
+
name: "coderwyd:node",
|
|
559
603
|
plugins: {
|
|
560
|
-
node:
|
|
604
|
+
node: default4
|
|
561
605
|
},
|
|
562
606
|
rules: {
|
|
563
607
|
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
@@ -574,10 +618,11 @@ function node() {
|
|
|
574
618
|
}
|
|
575
619
|
|
|
576
620
|
// src/configs/sort.ts
|
|
577
|
-
function sortPackageJson() {
|
|
621
|
+
async function sortPackageJson() {
|
|
578
622
|
return [
|
|
579
623
|
{
|
|
580
624
|
files: ["**/package.json"],
|
|
625
|
+
name: "coderwyd:sort-package-json",
|
|
581
626
|
rules: {
|
|
582
627
|
"jsonc/sort-array-values": [
|
|
583
628
|
"error",
|
|
@@ -632,7 +677,6 @@ function sortPackageJson() {
|
|
|
632
677
|
"husky",
|
|
633
678
|
"simple-git-hooks",
|
|
634
679
|
"lint-staged",
|
|
635
|
-
"nano-staged",
|
|
636
680
|
"eslintConfig"
|
|
637
681
|
],
|
|
638
682
|
pathPattern: "^$"
|
|
@@ -667,6 +711,7 @@ function sortTsconfig() {
|
|
|
667
711
|
return [
|
|
668
712
|
{
|
|
669
713
|
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
714
|
+
name: "coderwyd:sort-tsconfig",
|
|
670
715
|
rules: {
|
|
671
716
|
"jsonc/sort-keys": [
|
|
672
717
|
"error",
|
|
@@ -692,70 +737,39 @@ function sortTsconfig() {
|
|
|
692
737
|
"disableReferencedProjectLoad",
|
|
693
738
|
/* Language and Environment */
|
|
694
739
|
"target",
|
|
695
|
-
"lib",
|
|
696
740
|
"jsx",
|
|
697
|
-
"experimentalDecorators",
|
|
698
|
-
"emitDecoratorMetadata",
|
|
699
741
|
"jsxFactory",
|
|
700
742
|
"jsxFragmentFactory",
|
|
701
743
|
"jsxImportSource",
|
|
702
|
-
"
|
|
744
|
+
"lib",
|
|
745
|
+
"moduleDetection",
|
|
703
746
|
"noLib",
|
|
747
|
+
"reactNamespace",
|
|
704
748
|
"useDefineForClassFields",
|
|
705
|
-
"
|
|
749
|
+
"emitDecoratorMetadata",
|
|
750
|
+
"experimentalDecorators",
|
|
706
751
|
/* Modules */
|
|
707
|
-
"module",
|
|
708
|
-
"rootDir",
|
|
709
|
-
"moduleResolution",
|
|
710
752
|
"baseUrl",
|
|
711
|
-
"
|
|
753
|
+
"rootDir",
|
|
712
754
|
"rootDirs",
|
|
713
|
-
"
|
|
714
|
-
"
|
|
715
|
-
"
|
|
755
|
+
"customConditions",
|
|
756
|
+
"module",
|
|
757
|
+
"moduleResolution",
|
|
716
758
|
"moduleSuffixes",
|
|
717
|
-
"
|
|
759
|
+
"noResolve",
|
|
760
|
+
"paths",
|
|
761
|
+
"resolveJsonModule",
|
|
718
762
|
"resolvePackageJsonExports",
|
|
719
763
|
"resolvePackageJsonImports",
|
|
720
|
-
"
|
|
721
|
-
"
|
|
764
|
+
"typeRoots",
|
|
765
|
+
"types",
|
|
722
766
|
"allowArbitraryExtensions",
|
|
723
|
-
"
|
|
767
|
+
"allowImportingTsExtensions",
|
|
768
|
+
"allowUmdGlobalAccess",
|
|
724
769
|
/* JavaScript Support */
|
|
725
770
|
"allowJs",
|
|
726
771
|
"checkJs",
|
|
727
772
|
"maxNodeModuleJsDepth",
|
|
728
|
-
/* Emit */
|
|
729
|
-
"declaration",
|
|
730
|
-
"declarationMap",
|
|
731
|
-
"emitDeclarationOnly",
|
|
732
|
-
"sourceMap",
|
|
733
|
-
"inlineSourceMap",
|
|
734
|
-
"outFile",
|
|
735
|
-
"outDir",
|
|
736
|
-
"removeComments",
|
|
737
|
-
"noEmit",
|
|
738
|
-
"importHelpers",
|
|
739
|
-
"importsNotUsedAsValues",
|
|
740
|
-
"downlevelIteration",
|
|
741
|
-
"sourceRoot",
|
|
742
|
-
"mapRoot",
|
|
743
|
-
"inlineSources",
|
|
744
|
-
"emitBOM",
|
|
745
|
-
"newLine",
|
|
746
|
-
"stripInternal",
|
|
747
|
-
"noEmitHelpers",
|
|
748
|
-
"noEmitOnError",
|
|
749
|
-
"preserveConstEnums",
|
|
750
|
-
"declarationDir",
|
|
751
|
-
"preserveValueImports",
|
|
752
|
-
/* Interop Constraints */
|
|
753
|
-
"isolatedModules",
|
|
754
|
-
"verbatimModuleSyntax",
|
|
755
|
-
"allowSyntheticDefaultImports",
|
|
756
|
-
"esModuleInterop",
|
|
757
|
-
"preserveSymlinks",
|
|
758
|
-
"forceConsistentCasingInFileNames",
|
|
759
773
|
/* Type Checking */
|
|
760
774
|
"strict",
|
|
761
775
|
"strictBindCallApply",
|
|
@@ -776,6 +790,37 @@ function sortTsconfig() {
|
|
|
776
790
|
"noUnusedLocals",
|
|
777
791
|
"noUnusedParameters",
|
|
778
792
|
"useUnknownInCatchVariables",
|
|
793
|
+
/* Emit */
|
|
794
|
+
"declaration",
|
|
795
|
+
"declarationDir",
|
|
796
|
+
"declarationMap",
|
|
797
|
+
"downlevelIteration",
|
|
798
|
+
"emitBOM",
|
|
799
|
+
"emitDeclarationOnly",
|
|
800
|
+
"importHelpers",
|
|
801
|
+
"importsNotUsedAsValues",
|
|
802
|
+
"inlineSourceMap",
|
|
803
|
+
"inlineSources",
|
|
804
|
+
"mapRoot",
|
|
805
|
+
"newLine",
|
|
806
|
+
"noEmit",
|
|
807
|
+
"noEmitHelpers",
|
|
808
|
+
"noEmitOnError",
|
|
809
|
+
"outDir",
|
|
810
|
+
"outFile",
|
|
811
|
+
"preserveConstEnums",
|
|
812
|
+
"preserveValueImports",
|
|
813
|
+
"removeComments",
|
|
814
|
+
"sourceMap",
|
|
815
|
+
"sourceRoot",
|
|
816
|
+
"stripInternal",
|
|
817
|
+
/* Interop Constraints */
|
|
818
|
+
"allowSyntheticDefaultImports",
|
|
819
|
+
"esModuleInterop",
|
|
820
|
+
"forceConsistentCasingInFileNames",
|
|
821
|
+
"isolatedModules",
|
|
822
|
+
"preserveSymlinks",
|
|
823
|
+
"verbatimModuleSyntax",
|
|
779
824
|
/* Completeness */
|
|
780
825
|
"skipDefaultLibCheck",
|
|
781
826
|
"skipLibCheck"
|
|
@@ -789,137 +834,57 @@ function sortTsconfig() {
|
|
|
789
834
|
}
|
|
790
835
|
|
|
791
836
|
// src/configs/stylistic.ts
|
|
792
|
-
function stylistic() {
|
|
837
|
+
async function stylistic(options = {}) {
|
|
838
|
+
const {
|
|
839
|
+
indent = 2,
|
|
840
|
+
jsx = true,
|
|
841
|
+
quotes = "single",
|
|
842
|
+
semi = false
|
|
843
|
+
} = options;
|
|
844
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
845
|
+
const config = pluginStylistic.configs.customize({
|
|
846
|
+
flat: true,
|
|
847
|
+
indent,
|
|
848
|
+
jsx,
|
|
849
|
+
pluginName: "style",
|
|
850
|
+
quotes,
|
|
851
|
+
semi
|
|
852
|
+
});
|
|
793
853
|
return [
|
|
794
854
|
{
|
|
855
|
+
name: "coderwyd:stylistic",
|
|
795
856
|
plugins: {
|
|
796
857
|
antfu: default2,
|
|
797
|
-
style:
|
|
858
|
+
style: pluginStylistic
|
|
798
859
|
},
|
|
799
860
|
rules: {
|
|
861
|
+
...config.rules,
|
|
800
862
|
"antfu/consistent-list-newline": "error",
|
|
801
863
|
"antfu/if-newline": "error",
|
|
802
|
-
"
|
|
803
|
-
"
|
|
804
|
-
"
|
|
805
|
-
"style/block-spacing": ["error", "always"],
|
|
806
|
-
"style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
|
|
807
|
-
"style/comma-dangle": ["error", "always-multiline"],
|
|
808
|
-
"style/comma-spacing": ["error", { after: true, before: false }],
|
|
809
|
-
"style/comma-style": ["error", "last"],
|
|
810
|
-
"style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
|
|
811
|
-
"style/dot-location": ["error", "property"],
|
|
812
|
-
"style/indent": ["error", 2, {
|
|
813
|
-
ArrayExpression: 1,
|
|
814
|
-
CallExpression: { arguments: 1 },
|
|
815
|
-
FunctionDeclaration: { body: 1, parameters: 1 },
|
|
816
|
-
FunctionExpression: { body: 1, parameters: 1 },
|
|
817
|
-
ImportDeclaration: 1,
|
|
818
|
-
MemberExpression: 1,
|
|
819
|
-
ObjectExpression: 1,
|
|
820
|
-
SwitchCase: 1,
|
|
821
|
-
VariableDeclarator: 1,
|
|
822
|
-
flatTernaryExpressions: false,
|
|
823
|
-
ignoreComments: false,
|
|
824
|
-
ignoredNodes: [
|
|
825
|
-
"TemplateLiteral *",
|
|
826
|
-
"JSXElement",
|
|
827
|
-
"JSXElement > *",
|
|
828
|
-
"JSXAttribute",
|
|
829
|
-
"JSXIdentifier",
|
|
830
|
-
"JSXNamespacedName",
|
|
831
|
-
"JSXMemberExpression",
|
|
832
|
-
"JSXSpreadAttribute",
|
|
833
|
-
"JSXExpressionContainer",
|
|
834
|
-
"JSXOpeningElement",
|
|
835
|
-
"JSXClosingElement",
|
|
836
|
-
"JSXFragment",
|
|
837
|
-
"JSXOpeningFragment",
|
|
838
|
-
"JSXClosingFragment",
|
|
839
|
-
"JSXText",
|
|
840
|
-
"JSXEmptyExpression",
|
|
841
|
-
"JSXSpreadChild",
|
|
842
|
-
"TSTypeParameterInstantiation",
|
|
843
|
-
"FunctionExpression > .params[decorators.length > 0]",
|
|
844
|
-
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
845
|
-
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
|
|
846
|
-
],
|
|
847
|
-
offsetTernaryExpressions: true,
|
|
848
|
-
outerIIFEBody: 1
|
|
849
|
-
}],
|
|
850
|
-
"style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
851
|
-
"style/keyword-spacing": ["error", { after: true, before: true }],
|
|
852
|
-
"style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
|
|
853
|
-
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
854
|
-
"style/multiline-ternary": ["error", "always-multiline"],
|
|
855
|
-
"style/no-mixed-spaces-and-tabs": "error",
|
|
856
|
-
"style/no-multi-spaces": "error",
|
|
857
|
-
"style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
858
|
-
"style/no-tabs": "error",
|
|
859
|
-
"style/no-trailing-spaces": "error",
|
|
860
|
-
"style/no-whitespace-before-property": "error",
|
|
861
|
-
"style/object-curly-spacing": ["error", "always"],
|
|
862
|
-
"style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
863
|
-
"style/operator-linebreak": ["error", "before"],
|
|
864
|
-
"style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
|
|
865
|
-
"style/quotes": ["error", "single"],
|
|
866
|
-
"style/rest-spread-spacing": ["error", "never"],
|
|
867
|
-
"style/semi": ["error", "never"],
|
|
868
|
-
"style/semi-spacing": ["error", { after: true, before: false }],
|
|
869
|
-
"style/space-before-blocks": ["error", "always"],
|
|
870
|
-
"style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
|
|
871
|
-
"style/space-in-parens": ["error", "never"],
|
|
872
|
-
"style/space-infix-ops": "error",
|
|
873
|
-
"style/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
874
|
-
"style/spaced-comment": ["error", "always", {
|
|
875
|
-
block: {
|
|
876
|
-
balanced: true,
|
|
877
|
-
exceptions: ["*"],
|
|
878
|
-
markers: ["!"]
|
|
879
|
-
},
|
|
880
|
-
line: {
|
|
881
|
-
exceptions: ["/", "#"],
|
|
882
|
-
markers: ["/"]
|
|
883
|
-
}
|
|
884
|
-
}],
|
|
885
|
-
"style/template-curly-spacing": "error",
|
|
886
|
-
"style/template-tag-spacing": ["error", "never"],
|
|
887
|
-
"style/type-annotation-spacing": ["error", {}],
|
|
888
|
-
"style/yield-star-spacing": ["error", "both"]
|
|
864
|
+
"antfu/indent-binary-ops": ["error", { indent }],
|
|
865
|
+
"antfu/top-level-function": "error",
|
|
866
|
+
"curly": ["error", "multi-or-nest", "consistent"]
|
|
889
867
|
}
|
|
890
868
|
}
|
|
891
869
|
];
|
|
892
870
|
}
|
|
893
871
|
|
|
894
872
|
// src/configs/typescript.ts
|
|
895
|
-
import
|
|
896
|
-
|
|
897
|
-
// src/utils.ts
|
|
898
|
-
function combine(...configs) {
|
|
899
|
-
return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
|
|
900
|
-
}
|
|
901
|
-
function renameRules(rules, from, to) {
|
|
902
|
-
return Object.fromEntries(
|
|
903
|
-
Object.entries(rules).map(([key, value]) => {
|
|
904
|
-
if (key.startsWith(from))
|
|
905
|
-
return [to + key.slice(from.length), value];
|
|
906
|
-
return [key, value];
|
|
907
|
-
})
|
|
908
|
-
);
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
// src/configs/typescript.ts
|
|
912
|
-
function typescript(options) {
|
|
873
|
+
import process2 from "process";
|
|
874
|
+
async function typescript(options = {}) {
|
|
913
875
|
const {
|
|
914
876
|
componentExts = [],
|
|
915
877
|
overrides = {},
|
|
916
|
-
parserOptions = {}
|
|
917
|
-
|
|
918
|
-
|
|
878
|
+
parserOptions = {}
|
|
879
|
+
} = options;
|
|
880
|
+
const files = options.files ?? [
|
|
881
|
+
GLOB_SRC,
|
|
882
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
883
|
+
];
|
|
919
884
|
const typeAwareRules = {
|
|
920
|
-
"dot-notation":
|
|
921
|
-
"no-implied-eval":
|
|
922
|
-
"no-throw-literal":
|
|
885
|
+
"dot-notation": "off",
|
|
886
|
+
"no-implied-eval": "off",
|
|
887
|
+
"no-throw-literal": "off",
|
|
923
888
|
"ts/await-thenable": "error",
|
|
924
889
|
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
925
890
|
"ts/no-floating-promises": "error",
|
|
@@ -937,109 +902,116 @@ function typescript(options) {
|
|
|
937
902
|
"ts/restrict-template-expressions": "error",
|
|
938
903
|
"ts/unbound-method": "error"
|
|
939
904
|
};
|
|
905
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
906
|
+
const [
|
|
907
|
+
pluginTs,
|
|
908
|
+
parserTs
|
|
909
|
+
] = await Promise.all([
|
|
910
|
+
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
911
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
912
|
+
]);
|
|
940
913
|
return [
|
|
941
914
|
{
|
|
915
|
+
// Install the plugins without globs, so they can be configured separately.
|
|
916
|
+
name: "coderwyd:typescript:setup",
|
|
942
917
|
plugins: {
|
|
943
918
|
antfu: default2,
|
|
944
|
-
|
|
945
|
-
ts: default10
|
|
919
|
+
ts: pluginTs
|
|
946
920
|
}
|
|
947
921
|
},
|
|
948
922
|
{
|
|
949
|
-
files
|
|
950
|
-
GLOB_TS,
|
|
951
|
-
GLOB_TSX,
|
|
952
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
953
|
-
],
|
|
923
|
+
files,
|
|
954
924
|
languageOptions: {
|
|
955
|
-
parser:
|
|
925
|
+
parser: parserTs,
|
|
956
926
|
parserOptions: {
|
|
927
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
957
928
|
sourceType: "module",
|
|
958
929
|
...tsconfigPath ? {
|
|
959
|
-
project:
|
|
960
|
-
tsconfigRootDir:
|
|
930
|
+
project: tsconfigPath,
|
|
931
|
+
tsconfigRootDir: process2.cwd()
|
|
961
932
|
} : {},
|
|
962
933
|
...parserOptions
|
|
963
934
|
}
|
|
964
935
|
},
|
|
936
|
+
name: "coderwyd:typescript:rules",
|
|
965
937
|
rules: {
|
|
966
938
|
...renameRules(
|
|
967
|
-
|
|
939
|
+
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
968
940
|
"@typescript-eslint/",
|
|
969
941
|
"ts/"
|
|
970
942
|
),
|
|
971
943
|
...renameRules(
|
|
972
|
-
|
|
944
|
+
pluginTs.configs.strict.rules,
|
|
973
945
|
"@typescript-eslint/",
|
|
974
946
|
"ts/"
|
|
975
947
|
),
|
|
976
948
|
"antfu/generic-spacing": "error",
|
|
977
949
|
"antfu/named-tuple-spacing": "error",
|
|
978
|
-
"
|
|
979
|
-
"
|
|
980
|
-
"
|
|
981
|
-
"no-
|
|
982
|
-
"no-
|
|
983
|
-
"no-invalid-this": OFF,
|
|
984
|
-
"no-loss-of-precision": OFF,
|
|
985
|
-
"no-redeclare": OFF,
|
|
986
|
-
"no-use-before-define": OFF,
|
|
987
|
-
"no-useless-constructor": OFF,
|
|
988
|
-
// TS
|
|
950
|
+
"no-dupe-class-members": "off",
|
|
951
|
+
"no-loss-of-precision": "off",
|
|
952
|
+
"no-redeclare": "off",
|
|
953
|
+
"no-use-before-define": "off",
|
|
954
|
+
"no-useless-constructor": "off",
|
|
989
955
|
"ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
956
|
+
"ts/ban-types": ["error", { types: { Function: false } }],
|
|
990
957
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
991
958
|
"ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
|
|
992
959
|
"ts/no-dupe-class-members": "error",
|
|
993
|
-
"ts/no-dynamic-delete":
|
|
994
|
-
"ts/no-explicit-any":
|
|
995
|
-
"ts/no-
|
|
996
|
-
"ts/no-
|
|
997
|
-
"ts/no-invalid-void-type":
|
|
960
|
+
"ts/no-dynamic-delete": "off",
|
|
961
|
+
"ts/no-explicit-any": "off",
|
|
962
|
+
"ts/no-extraneous-class": "off",
|
|
963
|
+
"ts/no-import-type-side-effects": "error",
|
|
964
|
+
"ts/no-invalid-void-type": "off",
|
|
998
965
|
"ts/no-loss-of-precision": "error",
|
|
999
|
-
"ts/no-non-null-assertion":
|
|
966
|
+
"ts/no-non-null-assertion": "off",
|
|
1000
967
|
"ts/no-redeclare": "error",
|
|
1001
968
|
"ts/no-require-imports": "error",
|
|
1002
|
-
"ts/no-unused-vars":
|
|
969
|
+
"ts/no-unused-vars": "off",
|
|
1003
970
|
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
971
|
+
"ts/no-useless-constructor": "off",
|
|
1004
972
|
"ts/prefer-ts-expect-error": "error",
|
|
1005
|
-
"ts/triple-slash-reference":
|
|
973
|
+
"ts/triple-slash-reference": "off",
|
|
974
|
+
"ts/unified-signatures": "off",
|
|
1006
975
|
...tsconfigPath ? typeAwareRules : {},
|
|
1007
976
|
...overrides
|
|
1008
977
|
}
|
|
1009
978
|
},
|
|
1010
979
|
{
|
|
1011
980
|
files: ["**/*.d.ts"],
|
|
981
|
+
name: "coderwyd:typescript:dts-overrides",
|
|
1012
982
|
rules: {
|
|
1013
|
-
"eslint-comments/no-unlimited-disable":
|
|
1014
|
-
"import/no-duplicates":
|
|
1015
|
-
"
|
|
983
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
984
|
+
"import/no-duplicates": "off",
|
|
985
|
+
"no-restricted-syntax": "off",
|
|
986
|
+
"unused-imports/no-unused-vars": "off"
|
|
1016
987
|
}
|
|
1017
988
|
},
|
|
1018
989
|
{
|
|
1019
|
-
files:
|
|
990
|
+
files: ["**/*.{test,spec}.ts?(x)"],
|
|
991
|
+
name: "coderwyd:typescript:tests-overrides",
|
|
1020
992
|
rules: {
|
|
1021
|
-
"no-unused-expressions":
|
|
993
|
+
"no-unused-expressions": "off"
|
|
1022
994
|
}
|
|
1023
995
|
},
|
|
1024
996
|
{
|
|
1025
|
-
files: [
|
|
997
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
998
|
+
name: "coderwyd:typescript:javascript-overrides",
|
|
1026
999
|
rules: {
|
|
1027
|
-
"ts/no-require-imports":
|
|
1028
|
-
"ts/no-var-requires":
|
|
1000
|
+
"ts/no-require-imports": "off",
|
|
1001
|
+
"ts/no-var-requires": "off"
|
|
1029
1002
|
}
|
|
1030
1003
|
}
|
|
1031
1004
|
];
|
|
1032
1005
|
}
|
|
1033
1006
|
|
|
1034
1007
|
// src/configs/unicorn.ts
|
|
1035
|
-
function unicorn() {
|
|
1008
|
+
async function unicorn() {
|
|
1036
1009
|
return [
|
|
1037
1010
|
{
|
|
1011
|
+
name: "coderwyd:unicorn",
|
|
1038
1012
|
plugins: {
|
|
1039
|
-
unicorn:
|
|
1040
|
-
}
|
|
1041
|
-
},
|
|
1042
|
-
{
|
|
1013
|
+
unicorn: default5
|
|
1014
|
+
},
|
|
1043
1015
|
rules: {
|
|
1044
1016
|
// Pass error message when throwing errors
|
|
1045
1017
|
"unicorn/error-message": "error",
|
|
@@ -1051,10 +1023,10 @@ function unicorn() {
|
|
|
1051
1023
|
"unicorn/no-new-array": "error",
|
|
1052
1024
|
// Prevent deprecated `new Buffer()`
|
|
1053
1025
|
"unicorn/no-new-buffer": "error",
|
|
1054
|
-
// Keep regex literals safe!
|
|
1055
|
-
"unicorn/no-unsafe-regex": "error",
|
|
1056
1026
|
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
|
|
1057
1027
|
"unicorn/number-literal-case": "error",
|
|
1028
|
+
// textContent instead of innerText
|
|
1029
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
1058
1030
|
// includes over indexOf when checking for existence
|
|
1059
1031
|
"unicorn/prefer-includes": "error",
|
|
1060
1032
|
// Prefer using the node: protocol
|
|
@@ -1063,8 +1035,6 @@ function unicorn() {
|
|
|
1063
1035
|
"unicorn/prefer-number-properties": "error",
|
|
1064
1036
|
// String methods startsWith/endsWith instead of more complicated stuff
|
|
1065
1037
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1066
|
-
// textContent instead of innerText
|
|
1067
|
-
"unicorn/prefer-text-content": "error",
|
|
1068
1038
|
// Enforce throwing type error when throwing error while checking typeof
|
|
1069
1039
|
"unicorn/prefer-type-error": "error",
|
|
1070
1040
|
// Use new when throwing error
|
|
@@ -1075,55 +1045,61 @@ function unicorn() {
|
|
|
1075
1045
|
}
|
|
1076
1046
|
|
|
1077
1047
|
// src/configs/vue.ts
|
|
1078
|
-
|
|
1079
|
-
import { getPackageInfoSync } from "local-pkg";
|
|
1080
|
-
function getVueVersion() {
|
|
1081
|
-
const pkg = getPackageInfoSync("vue", { paths: [process2.cwd()] });
|
|
1082
|
-
if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
|
|
1083
|
-
return +pkg.version[0];
|
|
1084
|
-
return 3;
|
|
1085
|
-
}
|
|
1086
|
-
var isVue3 = getVueVersion() === 3;
|
|
1087
|
-
var vue3Rules = {
|
|
1088
|
-
...default13.configs.base.rules,
|
|
1089
|
-
...default13.configs["vue3-essential"].rules,
|
|
1090
|
-
...default13.configs["vue3-strongly-recommended"].rules,
|
|
1091
|
-
...default13.configs["vue3-recommended"].rules
|
|
1092
|
-
};
|
|
1093
|
-
var vue2Rules = {
|
|
1094
|
-
...default13.configs.base.rules,
|
|
1095
|
-
...default13.configs.essential.rules,
|
|
1096
|
-
...default13.configs["strongly-recommended"].rules,
|
|
1097
|
-
...default13.configs.recommended.rules
|
|
1098
|
-
};
|
|
1099
|
-
function vue(options = {}) {
|
|
1048
|
+
async function vue(options = {}) {
|
|
1100
1049
|
const {
|
|
1050
|
+
files = [GLOB_VUE],
|
|
1101
1051
|
overrides = {},
|
|
1102
1052
|
stylistic: stylistic2 = true
|
|
1103
1053
|
} = options;
|
|
1054
|
+
const {
|
|
1055
|
+
indent = 2
|
|
1056
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1057
|
+
const isVue3 = getVueVersion() === 3;
|
|
1058
|
+
const [
|
|
1059
|
+
pluginVue,
|
|
1060
|
+
parserVue
|
|
1061
|
+
] = await Promise.all([
|
|
1062
|
+
// @ts-expect-error missing types
|
|
1063
|
+
interopDefault(import("eslint-plugin-vue")),
|
|
1064
|
+
interopDefault(import("vue-eslint-parser"))
|
|
1065
|
+
]);
|
|
1066
|
+
const vue3Rules = {
|
|
1067
|
+
...pluginVue.configs.base.rules,
|
|
1068
|
+
...pluginVue.configs["vue3-essential"].rules,
|
|
1069
|
+
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1070
|
+
...pluginVue.configs["vue3-recommended"].rules
|
|
1071
|
+
};
|
|
1072
|
+
const vue2Rules = {
|
|
1073
|
+
...pluginVue.configs.base.rules,
|
|
1074
|
+
...pluginVue.configs.essential.rules,
|
|
1075
|
+
...pluginVue.configs["strongly-recommended"].rules,
|
|
1076
|
+
...pluginVue.configs.recommended.rules
|
|
1077
|
+
};
|
|
1104
1078
|
return [
|
|
1105
1079
|
{
|
|
1080
|
+
name: "coderwyd:vue:setup",
|
|
1106
1081
|
plugins: {
|
|
1107
|
-
vue:
|
|
1082
|
+
vue: pluginVue
|
|
1108
1083
|
}
|
|
1109
1084
|
},
|
|
1110
1085
|
{
|
|
1111
|
-
files
|
|
1086
|
+
files,
|
|
1112
1087
|
languageOptions: {
|
|
1113
|
-
parser:
|
|
1088
|
+
parser: parserVue,
|
|
1114
1089
|
parserOptions: {
|
|
1115
1090
|
ecmaFeatures: {
|
|
1116
1091
|
jsx: true
|
|
1117
1092
|
},
|
|
1118
1093
|
extraFileExtensions: [".vue"],
|
|
1119
|
-
parser: options.typescript ?
|
|
1094
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1120
1095
|
sourceType: "module"
|
|
1121
1096
|
}
|
|
1122
1097
|
},
|
|
1123
|
-
|
|
1098
|
+
name: "coderwyd:vue:rules",
|
|
1099
|
+
processor: pluginVue.processors[".vue"],
|
|
1124
1100
|
rules: {
|
|
1125
1101
|
...isVue3 ? vue3Rules : vue2Rules,
|
|
1126
|
-
"node/prefer-global/process":
|
|
1102
|
+
"node/prefer-global/process": "off",
|
|
1127
1103
|
"vue/block-order": ["error", {
|
|
1128
1104
|
order: ["script", "template", "style"]
|
|
1129
1105
|
}],
|
|
@@ -1136,9 +1112,11 @@ function vue(options = {}) {
|
|
|
1136
1112
|
"vue/dot-location": ["error", "property"],
|
|
1137
1113
|
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
1138
1114
|
"vue/eqeqeq": ["error", "smart"],
|
|
1139
|
-
"vue/
|
|
1140
|
-
"vue/
|
|
1141
|
-
"vue/
|
|
1115
|
+
"vue/html-indent": ["error", indent],
|
|
1116
|
+
"vue/html-quotes": ["error", "double"],
|
|
1117
|
+
"vue/max-attributes-per-line": "off",
|
|
1118
|
+
"vue/multi-word-component-names": "off",
|
|
1119
|
+
"vue/no-dupe-keys": "off",
|
|
1142
1120
|
"vue/no-empty-pattern": "error",
|
|
1143
1121
|
"vue/no-extra-parens": ["error", "functions"],
|
|
1144
1122
|
"vue/no-irregular-whitespace": "error",
|
|
@@ -1150,11 +1128,11 @@ function vue(options = {}) {
|
|
|
1150
1128
|
"WithStatement"
|
|
1151
1129
|
],
|
|
1152
1130
|
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1153
|
-
"vue/no-setup-props-reactivity-loss":
|
|
1131
|
+
"vue/no-setup-props-reactivity-loss": "off",
|
|
1154
1132
|
"vue/no-sparse-arrays": "error",
|
|
1155
1133
|
"vue/no-unused-refs": "error",
|
|
1156
1134
|
"vue/no-useless-v-bind": "error",
|
|
1157
|
-
"vue/no-v-html":
|
|
1135
|
+
"vue/no-v-html": "off",
|
|
1158
1136
|
"vue/object-shorthand": [
|
|
1159
1137
|
"error",
|
|
1160
1138
|
"always",
|
|
@@ -1165,8 +1143,9 @@ function vue(options = {}) {
|
|
|
1165
1143
|
],
|
|
1166
1144
|
"vue/prefer-separate-static-class": "error",
|
|
1167
1145
|
"vue/prefer-template": "error",
|
|
1168
|
-
"vue/
|
|
1169
|
-
"vue/require-prop
|
|
1146
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
1147
|
+
"vue/require-default-prop": "off",
|
|
1148
|
+
"vue/require-prop-types": "off",
|
|
1170
1149
|
"vue/space-infix-ops": "error",
|
|
1171
1150
|
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
1172
1151
|
...stylistic2 ? {
|
|
@@ -1186,7 +1165,7 @@ function vue(options = {}) {
|
|
|
1186
1165
|
}],
|
|
1187
1166
|
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
1188
1167
|
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1189
|
-
"vue/object-curly-newline":
|
|
1168
|
+
"vue/object-curly-newline": "off",
|
|
1190
1169
|
"vue/object-curly-spacing": ["error", "always"],
|
|
1191
1170
|
"vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
1192
1171
|
"vue/operator-linebreak": ["error", "before"],
|
|
@@ -1202,24 +1181,38 @@ function vue(options = {}) {
|
|
|
1202
1181
|
}
|
|
1203
1182
|
|
|
1204
1183
|
// src/configs/yaml.ts
|
|
1205
|
-
function yaml(options = {}) {
|
|
1184
|
+
async function yaml(options = {}) {
|
|
1206
1185
|
const {
|
|
1186
|
+
files = [GLOB_YAML],
|
|
1207
1187
|
overrides = {},
|
|
1208
1188
|
stylistic: stylistic2 = true
|
|
1209
1189
|
} = options;
|
|
1190
|
+
const {
|
|
1191
|
+
indent = 2,
|
|
1192
|
+
quotes = "single"
|
|
1193
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1194
|
+
const [
|
|
1195
|
+
pluginYaml,
|
|
1196
|
+
parserYaml
|
|
1197
|
+
] = await Promise.all([
|
|
1198
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
1199
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1200
|
+
]);
|
|
1210
1201
|
return [
|
|
1211
1202
|
{
|
|
1203
|
+
name: "coderwyd:yaml:setup",
|
|
1212
1204
|
plugins: {
|
|
1213
|
-
yaml:
|
|
1205
|
+
yaml: pluginYaml
|
|
1214
1206
|
}
|
|
1215
1207
|
},
|
|
1216
1208
|
{
|
|
1217
|
-
files
|
|
1209
|
+
files,
|
|
1218
1210
|
languageOptions: {
|
|
1219
|
-
parser:
|
|
1211
|
+
parser: parserYaml
|
|
1220
1212
|
},
|
|
1213
|
+
name: "coderwyd:yaml:rules",
|
|
1221
1214
|
rules: {
|
|
1222
|
-
"style/spaced-comment":
|
|
1215
|
+
"style/spaced-comment": "off",
|
|
1223
1216
|
"yaml/block-mapping": "error",
|
|
1224
1217
|
"yaml/block-sequence": "error",
|
|
1225
1218
|
"yaml/no-empty-key": "error",
|
|
@@ -1234,10 +1227,10 @@ function yaml(options = {}) {
|
|
|
1234
1227
|
"yaml/flow-mapping-curly-spacing": "error",
|
|
1235
1228
|
"yaml/flow-sequence-bracket-newline": "error",
|
|
1236
1229
|
"yaml/flow-sequence-bracket-spacing": "error",
|
|
1237
|
-
"yaml/indent": ["error", 2],
|
|
1230
|
+
"yaml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
1238
1231
|
"yaml/key-spacing": "error",
|
|
1239
1232
|
"yaml/no-tab-indent": "error",
|
|
1240
|
-
"yaml/quotes": ["error", { avoidEscape: false, prefer:
|
|
1233
|
+
"yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
|
|
1241
1234
|
"yaml/spaced-comment": "error"
|
|
1242
1235
|
} : {},
|
|
1243
1236
|
...overrides
|
|
@@ -1247,84 +1240,180 @@ function yaml(options = {}) {
|
|
|
1247
1240
|
}
|
|
1248
1241
|
|
|
1249
1242
|
// src/configs/test.ts
|
|
1250
|
-
function test(options = {}) {
|
|
1243
|
+
async function test(options = {}) {
|
|
1251
1244
|
const {
|
|
1245
|
+
files = GLOB_TESTS,
|
|
1252
1246
|
isInEditor = false,
|
|
1253
1247
|
overrides = {}
|
|
1254
1248
|
} = options;
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1249
|
+
const [
|
|
1250
|
+
pluginVitest,
|
|
1251
|
+
pluginNoOnlyTests
|
|
1252
|
+
] = await Promise.all([
|
|
1253
|
+
interopDefault(import("eslint-plugin-vitest")),
|
|
1254
|
+
// @ts-expect-error missing types
|
|
1255
|
+
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1256
|
+
]);
|
|
1257
|
+
return [
|
|
1258
|
+
{
|
|
1259
|
+
name: "coderwyd:test:setup",
|
|
1260
|
+
plugins: {
|
|
1261
|
+
test: {
|
|
1262
|
+
...pluginVitest,
|
|
1263
|
+
rules: {
|
|
1264
|
+
...pluginVitest.rules,
|
|
1265
|
+
// extend `test/no-only-tests` rule
|
|
1266
|
+
...pluginNoOnlyTests.rules
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
files,
|
|
1273
|
+
name: "coderwyd:test:rules",
|
|
1274
|
+
rules: {
|
|
1275
|
+
"node/prefer-global/process": "off",
|
|
1276
|
+
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1277
|
+
"test/no-identical-title": "error",
|
|
1278
|
+
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
1279
|
+
"test/prefer-hooks-in-order": "error",
|
|
1280
|
+
"test/prefer-lowercase-title": "error",
|
|
1281
|
+
...overrides
|
|
1282
|
+
}
|
|
1258
1283
|
}
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1284
|
+
];
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// src/configs/perfectionist.ts
|
|
1288
|
+
async function perfectionist() {
|
|
1289
|
+
return [
|
|
1290
|
+
{
|
|
1291
|
+
name: "coderwyd:perfectionist",
|
|
1292
|
+
plugins: {
|
|
1293
|
+
perfectionist: default7
|
|
1294
|
+
}
|
|
1264
1295
|
}
|
|
1265
|
-
|
|
1296
|
+
];
|
|
1266
1297
|
}
|
|
1267
1298
|
|
|
1268
1299
|
// src/configs/react.ts
|
|
1269
|
-
|
|
1300
|
+
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
1301
|
+
var ReactRefreshAllowConstantExportPackages = [
|
|
1302
|
+
"vite"
|
|
1303
|
+
];
|
|
1304
|
+
async function react(options = {}) {
|
|
1270
1305
|
const {
|
|
1271
|
-
|
|
1306
|
+
files = [GLOB_JSX, GLOB_TSX],
|
|
1307
|
+
overrides = {},
|
|
1308
|
+
typescript: typescript2 = true
|
|
1272
1309
|
} = options;
|
|
1310
|
+
await ensurePackages([
|
|
1311
|
+
"eslint-plugin-react",
|
|
1312
|
+
"eslint-plugin-react-hooks",
|
|
1313
|
+
"eslint-plugin-react-refresh"
|
|
1314
|
+
]);
|
|
1315
|
+
const [
|
|
1316
|
+
pluginReact,
|
|
1317
|
+
pluginReactHooks,
|
|
1318
|
+
pluginReactRefresh
|
|
1319
|
+
] = await Promise.all([
|
|
1320
|
+
interopDefault(import("eslint-plugin-react")),
|
|
1321
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1322
|
+
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1323
|
+
]);
|
|
1324
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1325
|
+
(i) => isPackageExists2(i)
|
|
1326
|
+
);
|
|
1273
1327
|
return [
|
|
1274
1328
|
{
|
|
1329
|
+
name: "coderwyd:react:setup",
|
|
1275
1330
|
plugins: {
|
|
1276
|
-
"react":
|
|
1277
|
-
"react-hooks":
|
|
1331
|
+
"react": pluginReact,
|
|
1332
|
+
"react-hooks": pluginReactHooks,
|
|
1333
|
+
"react-refresh": pluginReactRefresh
|
|
1278
1334
|
}
|
|
1279
1335
|
},
|
|
1280
1336
|
{
|
|
1281
|
-
files
|
|
1337
|
+
files,
|
|
1282
1338
|
languageOptions: {
|
|
1283
1339
|
parserOptions: {
|
|
1284
1340
|
ecmaFeatures: {
|
|
1285
1341
|
jsx: true
|
|
1286
|
-
}
|
|
1287
|
-
parser: options.typescript ? default19 : null,
|
|
1288
|
-
sourceType: "module"
|
|
1342
|
+
}
|
|
1289
1343
|
}
|
|
1290
1344
|
},
|
|
1345
|
+
name: "coderwyd:react:rules",
|
|
1291
1346
|
rules: {
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
"react/
|
|
1295
|
-
|
|
1347
|
+
// recommended rules react-hooks
|
|
1348
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
1349
|
+
"react-hooks/rules-of-hooks": "error",
|
|
1350
|
+
// react refresh
|
|
1351
|
+
"react-refresh/only-export-components": [
|
|
1352
|
+
"warn",
|
|
1353
|
+
{ allowConstantExport: isAllowConstantExport }
|
|
1354
|
+
],
|
|
1355
|
+
// recommended rules react
|
|
1356
|
+
"react/display-name": "error",
|
|
1357
|
+
"react/jsx-key": "error",
|
|
1358
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
1359
|
+
"react/jsx-no-duplicate-props": "error",
|
|
1360
|
+
"react/jsx-no-target-blank": "error",
|
|
1361
|
+
"react/jsx-no-undef": "error",
|
|
1362
|
+
"react/jsx-uses-react": "error",
|
|
1363
|
+
"react/jsx-uses-vars": "error",
|
|
1364
|
+
"react/no-children-prop": "error",
|
|
1365
|
+
"react/no-danger-with-children": "error",
|
|
1366
|
+
"react/no-deprecated": "error",
|
|
1367
|
+
"react/no-direct-mutation-state": "error",
|
|
1368
|
+
"react/no-find-dom-node": "error",
|
|
1369
|
+
"react/no-is-mounted": "error",
|
|
1370
|
+
"react/no-render-return-value": "error",
|
|
1371
|
+
"react/no-string-refs": "error",
|
|
1372
|
+
"react/no-unescaped-entities": "error",
|
|
1373
|
+
"react/no-unknown-property": "error",
|
|
1374
|
+
"react/no-unsafe": "off",
|
|
1375
|
+
"react/prop-types": "error",
|
|
1376
|
+
"react/react-in-jsx-scope": "off",
|
|
1377
|
+
"react/require-render-return": "error",
|
|
1378
|
+
...typescript2 ? {
|
|
1379
|
+
"react/jsx-no-undef": "off",
|
|
1380
|
+
"react/prop-type": "off"
|
|
1381
|
+
} : {},
|
|
1382
|
+
// overrides
|
|
1296
1383
|
...overrides
|
|
1297
|
-
},
|
|
1298
|
-
settings: {
|
|
1299
|
-
react: {
|
|
1300
|
-
version: "detect"
|
|
1301
|
-
}
|
|
1302
1384
|
}
|
|
1303
1385
|
}
|
|
1304
1386
|
];
|
|
1305
1387
|
}
|
|
1306
1388
|
|
|
1307
|
-
// src/configs/
|
|
1308
|
-
function
|
|
1309
|
-
const {
|
|
1389
|
+
// src/configs/unocss.ts
|
|
1390
|
+
async function unocss(options = {}) {
|
|
1391
|
+
const {
|
|
1392
|
+
attributify = true,
|
|
1393
|
+
strict = false
|
|
1394
|
+
} = options;
|
|
1395
|
+
await ensurePackages([
|
|
1396
|
+
"@unocss/eslint-plugin"
|
|
1397
|
+
]);
|
|
1398
|
+
const [
|
|
1399
|
+
pluginUnoCSS
|
|
1400
|
+
] = await Promise.all([
|
|
1401
|
+
interopDefault(import("@unocss/eslint-plugin"))
|
|
1402
|
+
]);
|
|
1310
1403
|
return [
|
|
1311
1404
|
{
|
|
1405
|
+
name: "antfu:unocss",
|
|
1312
1406
|
plugins: {
|
|
1313
|
-
|
|
1314
|
-
}
|
|
1315
|
-
},
|
|
1316
|
-
{
|
|
1317
|
-
files: [GLOB_ASTRO],
|
|
1318
|
-
languageOptions: {
|
|
1319
|
-
parser: default23,
|
|
1320
|
-
parserOptions: {
|
|
1321
|
-
extraFileExtensions: [".astro"],
|
|
1322
|
-
parser: options.typescript ? default19 : null
|
|
1323
|
-
}
|
|
1407
|
+
unocss: pluginUnoCSS
|
|
1324
1408
|
},
|
|
1325
1409
|
rules: {
|
|
1326
|
-
|
|
1327
|
-
...
|
|
1410
|
+
"unocss/order": "warn",
|
|
1411
|
+
...attributify ? {
|
|
1412
|
+
"unocss/order-attributify": "warn"
|
|
1413
|
+
} : {},
|
|
1414
|
+
...strict ? {
|
|
1415
|
+
"unocss/blocklist": "error"
|
|
1416
|
+
} : {}
|
|
1328
1417
|
}
|
|
1329
1418
|
}
|
|
1330
1419
|
];
|
|
@@ -1347,46 +1436,46 @@ var VuePackages = [
|
|
|
1347
1436
|
"vitepress",
|
|
1348
1437
|
"@slidev/cli"
|
|
1349
1438
|
];
|
|
1350
|
-
|
|
1351
|
-
"react",
|
|
1352
|
-
"next"
|
|
1353
|
-
];
|
|
1354
|
-
var AstroPackages = [
|
|
1355
|
-
"astro"
|
|
1356
|
-
];
|
|
1357
|
-
function coderwyd(options = {}, ...userConfigs) {
|
|
1439
|
+
async function coderwyd(options = {}, ...userConfigs) {
|
|
1358
1440
|
const {
|
|
1359
|
-
|
|
1360
|
-
vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
|
|
1361
|
-
react: enableReact = ReactPackages.some((i) => isPackageExists(i)),
|
|
1362
|
-
astro: enableAstro = AstroPackages.some((i) => isPackageExists(i)),
|
|
1363
|
-
typescript: enableTypeScript = isPackageExists("typescript"),
|
|
1364
|
-
stylistic: enableStylistic = true,
|
|
1441
|
+
componentExts = [],
|
|
1365
1442
|
gitignore: enableGitignore = true,
|
|
1443
|
+
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
|
|
1366
1444
|
overrides = {},
|
|
1367
|
-
|
|
1445
|
+
react: enableReact = false,
|
|
1446
|
+
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
1447
|
+
unocss: enableUnoCSS = false,
|
|
1448
|
+
vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
|
|
1368
1449
|
} = options;
|
|
1450
|
+
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1451
|
+
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
1452
|
+
stylisticOptions.jsx = options.jsx ?? true;
|
|
1369
1453
|
const configs = [];
|
|
1370
1454
|
if (enableGitignore) {
|
|
1371
1455
|
if (typeof enableGitignore !== "boolean") {
|
|
1372
|
-
configs.push(
|
|
1456
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1373
1457
|
} else {
|
|
1374
1458
|
if (fs.existsSync(".gitignore"))
|
|
1375
|
-
configs.push(
|
|
1459
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
1376
1460
|
}
|
|
1377
1461
|
}
|
|
1378
1462
|
configs.push(
|
|
1379
1463
|
ignores(),
|
|
1380
|
-
javascript({
|
|
1464
|
+
javascript({
|
|
1465
|
+
isInEditor,
|
|
1466
|
+
overrides: overrides.javascript
|
|
1467
|
+
}),
|
|
1381
1468
|
comments(),
|
|
1382
1469
|
node(),
|
|
1383
1470
|
jsdoc({
|
|
1384
|
-
stylistic:
|
|
1471
|
+
stylistic: stylisticOptions
|
|
1385
1472
|
}),
|
|
1386
1473
|
imports({
|
|
1387
|
-
stylistic:
|
|
1474
|
+
stylistic: stylisticOptions
|
|
1388
1475
|
}),
|
|
1389
|
-
unicorn()
|
|
1476
|
+
unicorn(),
|
|
1477
|
+
// Optional plugins (installed but not enabled by default)
|
|
1478
|
+
perfectionist()
|
|
1390
1479
|
);
|
|
1391
1480
|
if (enableVue)
|
|
1392
1481
|
componentExts.push("vue");
|
|
@@ -1397,14 +1486,18 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1397
1486
|
overrides: overrides.typescript
|
|
1398
1487
|
}));
|
|
1399
1488
|
}
|
|
1400
|
-
if (
|
|
1401
|
-
configs.push(stylistic());
|
|
1402
|
-
if (options.test ?? true)
|
|
1403
|
-
configs.push(test({
|
|
1489
|
+
if (stylisticOptions)
|
|
1490
|
+
configs.push(stylistic(stylisticOptions));
|
|
1491
|
+
if (options.test ?? true) {
|
|
1492
|
+
configs.push(test({
|
|
1493
|
+
isInEditor,
|
|
1494
|
+
overrides: overrides.test
|
|
1495
|
+
}));
|
|
1496
|
+
}
|
|
1404
1497
|
if (enableVue) {
|
|
1405
1498
|
configs.push(vue({
|
|
1406
1499
|
overrides: overrides.vue,
|
|
1407
|
-
stylistic:
|
|
1500
|
+
stylistic: stylisticOptions,
|
|
1408
1501
|
typescript: !!enableTypeScript
|
|
1409
1502
|
}));
|
|
1410
1503
|
}
|
|
@@ -1414,15 +1507,17 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1414
1507
|
typescript: !!enableTypeScript
|
|
1415
1508
|
}));
|
|
1416
1509
|
}
|
|
1417
|
-
if (
|
|
1418
|
-
configs.push(
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
}));
|
|
1510
|
+
if (enableUnoCSS) {
|
|
1511
|
+
configs.push(unocss(
|
|
1512
|
+
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1513
|
+
));
|
|
1422
1514
|
}
|
|
1423
1515
|
if (options.jsonc ?? true) {
|
|
1424
1516
|
configs.push(
|
|
1425
|
-
jsonc(
|
|
1517
|
+
jsonc({
|
|
1518
|
+
overrides: overrides.jsonc,
|
|
1519
|
+
stylistic: stylisticOptions
|
|
1520
|
+
}),
|
|
1426
1521
|
sortPackageJson(),
|
|
1427
1522
|
sortTsconfig()
|
|
1428
1523
|
);
|
|
@@ -1430,11 +1525,15 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1430
1525
|
if (options.yaml ?? true) {
|
|
1431
1526
|
configs.push(yaml({
|
|
1432
1527
|
overrides: overrides.yaml,
|
|
1433
|
-
stylistic:
|
|
1528
|
+
stylistic: stylisticOptions
|
|
1529
|
+
}));
|
|
1530
|
+
}
|
|
1531
|
+
if (options.markdown ?? true) {
|
|
1532
|
+
configs.push(markdown({
|
|
1533
|
+
componentExts,
|
|
1534
|
+
overrides: overrides.markdown
|
|
1434
1535
|
}));
|
|
1435
1536
|
}
|
|
1436
|
-
if (options.markdown ?? true)
|
|
1437
|
-
configs.push(markdown({ componentExts, overrides: overrides.markdown }));
|
|
1438
1537
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1439
1538
|
if (key in options)
|
|
1440
1539
|
acc[key] = options[key];
|
|
@@ -1453,7 +1552,6 @@ function coderwyd(options = {}, ...userConfigs) {
|
|
|
1453
1552
|
var src_default = coderwyd;
|
|
1454
1553
|
export {
|
|
1455
1554
|
GLOB_ALL_SRC,
|
|
1456
|
-
GLOB_ASTRO,
|
|
1457
1555
|
GLOB_CSS,
|
|
1458
1556
|
GLOB_EXCLUDE,
|
|
1459
1557
|
GLOB_HTML,
|
|
@@ -1474,49 +1572,31 @@ export {
|
|
|
1474
1572
|
GLOB_TSX,
|
|
1475
1573
|
GLOB_VUE,
|
|
1476
1574
|
GLOB_YAML,
|
|
1477
|
-
astro,
|
|
1478
1575
|
coderwyd,
|
|
1479
1576
|
combine,
|
|
1480
1577
|
comments,
|
|
1481
1578
|
src_default as default,
|
|
1579
|
+
ensurePackages,
|
|
1482
1580
|
getVueVersion,
|
|
1483
1581
|
ignores,
|
|
1484
1582
|
imports,
|
|
1583
|
+
interopDefault,
|
|
1485
1584
|
javascript,
|
|
1486
1585
|
jsdoc,
|
|
1487
1586
|
jsonc,
|
|
1488
1587
|
markdown,
|
|
1489
1588
|
node,
|
|
1490
|
-
|
|
1491
|
-
default22 as parserJsonc,
|
|
1492
|
-
default19 as parserTs,
|
|
1493
|
-
default20 as parserVue,
|
|
1494
|
-
default21 as parserYaml,
|
|
1495
|
-
default2 as pluginAntfu,
|
|
1496
|
-
default18 as pluginAstro,
|
|
1497
|
-
default3 as pluginComments,
|
|
1498
|
-
default4 as pluginImport,
|
|
1499
|
-
default5 as pluginJsdoc,
|
|
1500
|
-
default6 as pluginJsonc,
|
|
1501
|
-
default7 as pluginMarkdown,
|
|
1502
|
-
default15 as pluginNoOnlyTests,
|
|
1503
|
-
default8 as pluginNode,
|
|
1504
|
-
default16 as pluginReact,
|
|
1505
|
-
default17 as pluginReactHooks,
|
|
1506
|
-
default9 as pluginStylistic,
|
|
1507
|
-
default10 as pluginTs,
|
|
1508
|
-
default11 as pluginUnicorn,
|
|
1509
|
-
default12 as pluginUnusedImports,
|
|
1510
|
-
default13 as pluginVue,
|
|
1511
|
-
default14 as pluginYaml,
|
|
1589
|
+
perfectionist,
|
|
1512
1590
|
react,
|
|
1513
1591
|
renameRules,
|
|
1514
1592
|
sortPackageJson,
|
|
1515
1593
|
sortTsconfig,
|
|
1516
1594
|
stylistic,
|
|
1517
1595
|
test,
|
|
1596
|
+
toArray,
|
|
1518
1597
|
typescript,
|
|
1519
1598
|
unicorn,
|
|
1599
|
+
unocss,
|
|
1520
1600
|
vue,
|
|
1521
1601
|
yaml
|
|
1522
1602
|
};
|