@coderwyd/eslint-config 4.2.0 → 4.2.2
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/dist/chunk-D2IgMYys.js +33 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +155 -197
- package/dist/index.d.ts +4232 -2648
- package/dist/index.js +1635 -1854
- package/dist/jiti-Cidv43TO.js +45803 -0
- package/dist/src-Bzhof6OA.js +1045 -0
- package/package.json +29 -29
package/dist/index.js
CHANGED
|
@@ -1,1961 +1,1742 @@
|
|
|
1
|
-
|
|
1
|
+
import process from "node:process";
|
|
2
2
|
import createCommand from "eslint-plugin-command/config";
|
|
3
|
+
import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
4
|
+
import pluginAntfu from "eslint-plugin-antfu";
|
|
5
|
+
import pluginDeMorgan from "eslint-plugin-de-morgan";
|
|
6
|
+
import * as pluginImport from "eslint-plugin-import-x";
|
|
7
|
+
import pluginNode from "eslint-plugin-n";
|
|
8
|
+
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
9
|
+
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
10
|
+
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
11
|
+
import globals from "globals";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { getPackageInfoSync, isPackageExists } from "local-pkg";
|
|
14
|
+
import prettierRules from "eslint-config-prettier";
|
|
15
|
+
import { configs } from "eslint-plugin-regexp";
|
|
16
|
+
|
|
17
|
+
//#region src/configs/command.ts
|
|
3
18
|
function command() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
];
|
|
19
|
+
return [{
|
|
20
|
+
...createCommand(),
|
|
21
|
+
name: "coderwyd/command/rules"
|
|
22
|
+
}];
|
|
10
23
|
}
|
|
11
24
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { default as default3 } from "eslint-plugin-antfu";
|
|
15
|
-
import { default as default4 } from "eslint-plugin-de-morgan";
|
|
16
|
-
import * as pluginImport from "eslint-plugin-import-x";
|
|
17
|
-
import { default as default5 } from "eslint-plugin-n";
|
|
18
|
-
import { default as default6 } from "eslint-plugin-perfectionist";
|
|
19
|
-
import { default as default7 } from "eslint-plugin-unicorn";
|
|
20
|
-
import { default as default8 } from "eslint-plugin-unused-imports";
|
|
21
|
-
|
|
22
|
-
// src/configs/comments.ts
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/configs/comments.ts
|
|
23
27
|
function comments() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"eslint-comments/no-unused-enable": "error"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
];
|
|
28
|
+
return [{
|
|
29
|
+
name: "coderwyd/eslint-comments/rules",
|
|
30
|
+
plugins: { "eslint-comments": pluginComments },
|
|
31
|
+
rules: {
|
|
32
|
+
"eslint-comments/no-aggregating-enable": "error",
|
|
33
|
+
"eslint-comments/no-duplicate-disable": "error",
|
|
34
|
+
"eslint-comments/no-unlimited-disable": "error",
|
|
35
|
+
"eslint-comments/no-unused-enable": "error"
|
|
36
|
+
}
|
|
37
|
+
}];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/configs/de-morgan.ts
|
|
41
42
|
function deMorgan() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"de-morgan/no-negated-disjunction": "error"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
];
|
|
43
|
+
return [{
|
|
44
|
+
name: "coderwyd/de-morgan/rules",
|
|
45
|
+
plugins: { "de-morgan": pluginDeMorgan },
|
|
46
|
+
rules: {
|
|
47
|
+
"de-morgan/no-negated-conjunction": "error",
|
|
48
|
+
"de-morgan/no-negated-disjunction": "error"
|
|
49
|
+
}
|
|
50
|
+
}];
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/constants/glob.ts
|
|
55
|
+
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
56
|
+
const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
57
|
+
const GLOB_TS = "**/*.?([cm])ts";
|
|
58
|
+
const GLOB_DTS = "**/*.d.?([cm])ts";
|
|
59
|
+
const GLOB_TSX = "**/*.?([cm])tsx";
|
|
60
|
+
const GLOB_VUE = "**/*.vue";
|
|
61
|
+
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
62
|
+
const GLOB_SVELTE = "**/*.svelte";
|
|
63
|
+
const GLOB_JSON = "**/*.json";
|
|
64
|
+
const GLOB_JSON5 = "**/*.json5";
|
|
65
|
+
const GLOB_JSONC = "**/*.jsonc";
|
|
66
|
+
const GLOB_MARKDOWN = "**/*.md";
|
|
67
|
+
const GLOB_YAML = "**/*.y?(a)ml";
|
|
68
|
+
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
69
|
+
const GLOB_TESTS = [
|
|
70
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
71
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
72
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
73
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
74
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
77
75
|
];
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
76
|
+
const GLOB_EXCLUDE = [
|
|
77
|
+
"**/node_modules",
|
|
78
|
+
"**/dist",
|
|
79
|
+
"**/package-lock.json",
|
|
80
|
+
"**/yarn.lock",
|
|
81
|
+
"**/pnpm-lock.yaml",
|
|
82
|
+
"**/bun.lockb",
|
|
83
|
+
"**/output",
|
|
84
|
+
"**/coverage",
|
|
85
|
+
"**/temp",
|
|
86
|
+
"**/.temp",
|
|
87
|
+
"**/tmp",
|
|
88
|
+
"**/.tmp",
|
|
89
|
+
"**/.history",
|
|
90
|
+
"**/.vitepress/cache",
|
|
91
|
+
"**/.nuxt",
|
|
92
|
+
"**/.next",
|
|
93
|
+
"**/.svelte-kit",
|
|
94
|
+
"**/.vercel",
|
|
95
|
+
"**/.changeset",
|
|
96
|
+
"**/.idea",
|
|
97
|
+
"**/.cache",
|
|
98
|
+
"**/.output",
|
|
99
|
+
"**/.vite-inspect",
|
|
100
|
+
"**/.yarn",
|
|
101
|
+
"**/vite.config.*.timestamp-*",
|
|
102
|
+
"**/CHANGELOG*.md",
|
|
103
|
+
"**/*.min.*",
|
|
104
|
+
"**/LICENSE*",
|
|
105
|
+
"**/__snapshots__",
|
|
106
|
+
"**/auto-import?(s).d.ts",
|
|
107
|
+
"**/components.d.ts"
|
|
110
108
|
];
|
|
111
109
|
|
|
112
|
-
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/configs/ignores.ts
|
|
113
112
|
function ignores(userIgnores = []) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
];
|
|
113
|
+
return [{
|
|
114
|
+
ignores: [...GLOB_EXCLUDE, ...userIgnores],
|
|
115
|
+
name: "coderwyd/ignores"
|
|
116
|
+
}];
|
|
120
117
|
}
|
|
121
118
|
|
|
122
|
-
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/configs/imports.ts
|
|
123
121
|
function imports() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
];
|
|
122
|
+
return [{
|
|
123
|
+
name: "coderwyd/imports/rules",
|
|
124
|
+
plugins: {
|
|
125
|
+
antfu: pluginAntfu,
|
|
126
|
+
import: pluginImport
|
|
127
|
+
},
|
|
128
|
+
rules: {
|
|
129
|
+
"antfu/import-dedupe": "error",
|
|
130
|
+
"antfu/no-import-dist": "error",
|
|
131
|
+
"antfu/no-import-node-modules-by-path": "error",
|
|
132
|
+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
133
|
+
"import/first": "error",
|
|
134
|
+
"import/newline-after-import": ["error", { count: 1 }],
|
|
135
|
+
"import/no-duplicates": "error",
|
|
136
|
+
"import/no-mutable-exports": "error",
|
|
137
|
+
"import/no-named-default": "error",
|
|
138
|
+
"import/no-self-import": "error",
|
|
139
|
+
"import/no-webpack-loader-syntax": "error"
|
|
140
|
+
}
|
|
141
|
+
}];
|
|
145
142
|
}
|
|
146
143
|
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/configs/javascript.ts
|
|
149
146
|
function javascript(options = {}) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
"use-isnan": [
|
|
370
|
-
"error",
|
|
371
|
-
{ enforceForIndexOf: true, enforceForSwitchCase: true }
|
|
372
|
-
],
|
|
373
|
-
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
374
|
-
"vars-on-top": "error",
|
|
375
|
-
yoda: ["error", "never"],
|
|
376
|
-
...overrides
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
];
|
|
147
|
+
const { isInEditor: isInEditor$1 = false, overrides = {} } = options;
|
|
148
|
+
return [{
|
|
149
|
+
languageOptions: {
|
|
150
|
+
ecmaVersion: 2022,
|
|
151
|
+
globals: {
|
|
152
|
+
...globals.browser,
|
|
153
|
+
...globals.es2021,
|
|
154
|
+
...globals.node,
|
|
155
|
+
document: "readonly",
|
|
156
|
+
navigator: "readonly",
|
|
157
|
+
window: "readonly"
|
|
158
|
+
},
|
|
159
|
+
parserOptions: {
|
|
160
|
+
ecmaFeatures: { jsx: true },
|
|
161
|
+
ecmaVersion: 2022,
|
|
162
|
+
sourceType: "module"
|
|
163
|
+
},
|
|
164
|
+
sourceType: "module"
|
|
165
|
+
},
|
|
166
|
+
linterOptions: { reportUnusedDisableDirectives: true },
|
|
167
|
+
name: "coderwyd/javascript/setup"
|
|
168
|
+
}, {
|
|
169
|
+
name: "coderwyd/javascript/rules",
|
|
170
|
+
plugins: { "unused-imports": pluginUnusedImports },
|
|
171
|
+
rules: {
|
|
172
|
+
"accessor-pairs": ["error", {
|
|
173
|
+
enforceForClassMembers: true,
|
|
174
|
+
setWithoutGet: true
|
|
175
|
+
}],
|
|
176
|
+
"antfu/no-top-level-await": "error",
|
|
177
|
+
"antfu/top-level-function": "error",
|
|
178
|
+
"array-callback-return": "error",
|
|
179
|
+
"block-scoped-var": "error",
|
|
180
|
+
"constructor-super": "error",
|
|
181
|
+
"default-case-last": "error",
|
|
182
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
183
|
+
eqeqeq: ["error", "smart"],
|
|
184
|
+
"for-direction": "error",
|
|
185
|
+
"getter-return": "error",
|
|
186
|
+
"new-cap": ["error", {
|
|
187
|
+
capIsNew: false,
|
|
188
|
+
newIsCap: true,
|
|
189
|
+
properties: true
|
|
190
|
+
}],
|
|
191
|
+
"no-alert": "error",
|
|
192
|
+
"no-array-constructor": "error",
|
|
193
|
+
"no-async-promise-executor": "error",
|
|
194
|
+
"no-caller": "error",
|
|
195
|
+
"no-case-declarations": "error",
|
|
196
|
+
"no-class-assign": "error",
|
|
197
|
+
"no-compare-neg-zero": "error",
|
|
198
|
+
"no-cond-assign": ["error", "always"],
|
|
199
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
200
|
+
"no-const-assign": "error",
|
|
201
|
+
"no-constant-binary-expression": "error",
|
|
202
|
+
"no-constant-condition": "error",
|
|
203
|
+
"no-control-regex": "error",
|
|
204
|
+
"no-debugger": "error",
|
|
205
|
+
"no-delete-var": "error",
|
|
206
|
+
"no-dupe-args": "error",
|
|
207
|
+
"no-dupe-class-members": "error",
|
|
208
|
+
"no-dupe-keys": "error",
|
|
209
|
+
"no-duplicate-case": "error",
|
|
210
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
211
|
+
"no-empty-character-class": "error",
|
|
212
|
+
"no-empty-pattern": "error",
|
|
213
|
+
"no-eval": "error",
|
|
214
|
+
"no-ex-assign": "error",
|
|
215
|
+
"no-extend-native": "error",
|
|
216
|
+
"no-extra-bind": "error",
|
|
217
|
+
"no-extra-boolean-cast": "error",
|
|
218
|
+
"no-fallthrough": "error",
|
|
219
|
+
"no-func-assign": "error",
|
|
220
|
+
"no-global-assign": "error",
|
|
221
|
+
"no-implied-eval": "error",
|
|
222
|
+
"no-import-assign": "error",
|
|
223
|
+
"no-invalid-regexp": "error",
|
|
224
|
+
"no-irregular-whitespace": "error",
|
|
225
|
+
"no-iterator": "error",
|
|
226
|
+
"no-labels": ["error", {
|
|
227
|
+
allowLoop: false,
|
|
228
|
+
allowSwitch: false
|
|
229
|
+
}],
|
|
230
|
+
"no-lone-blocks": "error",
|
|
231
|
+
"no-loss-of-precision": "error",
|
|
232
|
+
"no-misleading-character-class": "error",
|
|
233
|
+
"no-multi-str": "error",
|
|
234
|
+
"no-new": "error",
|
|
235
|
+
"no-new-func": "error",
|
|
236
|
+
"no-new-native-nonconstructor": "error",
|
|
237
|
+
"no-new-wrappers": "error",
|
|
238
|
+
"no-obj-calls": "error",
|
|
239
|
+
"no-object-constructor": "error",
|
|
240
|
+
"no-octal": "error",
|
|
241
|
+
"no-octal-escape": "error",
|
|
242
|
+
"no-proto": "error",
|
|
243
|
+
"no-prototype-builtins": "error",
|
|
244
|
+
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
245
|
+
"no-regex-spaces": "error",
|
|
246
|
+
"no-restricted-globals": [
|
|
247
|
+
"error",
|
|
248
|
+
{
|
|
249
|
+
message: "Use `globalThis` instead.",
|
|
250
|
+
name: "global"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
message: "Use `globalThis` instead.",
|
|
254
|
+
name: "self"
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
"no-restricted-properties": [
|
|
258
|
+
"error",
|
|
259
|
+
{
|
|
260
|
+
message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
|
|
261
|
+
property: "__proto__"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
message: "Use `Object.defineProperty` instead.",
|
|
265
|
+
property: "__defineGetter__"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
message: "Use `Object.defineProperty` instead.",
|
|
269
|
+
property: "__defineSetter__"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
273
|
+
property: "__lookupGetter__"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
277
|
+
property: "__lookupSetter__"
|
|
278
|
+
}
|
|
279
|
+
],
|
|
280
|
+
"no-restricted-syntax": [
|
|
281
|
+
"error",
|
|
282
|
+
"TSEnumDeclaration[const=true]",
|
|
283
|
+
"TSExportAssignment"
|
|
284
|
+
],
|
|
285
|
+
"no-self-assign": ["error", { props: true }],
|
|
286
|
+
"no-self-compare": "error",
|
|
287
|
+
"no-sequences": "error",
|
|
288
|
+
"no-shadow-restricted-names": "error",
|
|
289
|
+
"no-sparse-arrays": "error",
|
|
290
|
+
"no-template-curly-in-string": "error",
|
|
291
|
+
"no-this-before-super": "error",
|
|
292
|
+
"no-throw-literal": "error",
|
|
293
|
+
"no-undef": "error",
|
|
294
|
+
"no-undef-init": "error",
|
|
295
|
+
"no-unexpected-multiline": "error",
|
|
296
|
+
"no-unmodified-loop-condition": "error",
|
|
297
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
298
|
+
"no-unreachable": "error",
|
|
299
|
+
"no-unreachable-loop": "error",
|
|
300
|
+
"no-unsafe-finally": "error",
|
|
301
|
+
"no-unsafe-negation": "error",
|
|
302
|
+
"no-unused-expressions": ["error", {
|
|
303
|
+
allowShortCircuit: true,
|
|
304
|
+
allowTaggedTemplates: true,
|
|
305
|
+
allowTernary: true
|
|
306
|
+
}],
|
|
307
|
+
"no-unused-vars": "off",
|
|
308
|
+
"no-use-before-define": ["error", {
|
|
309
|
+
classes: false,
|
|
310
|
+
functions: false,
|
|
311
|
+
variables: true
|
|
312
|
+
}],
|
|
313
|
+
"no-useless-backreference": "error",
|
|
314
|
+
"no-useless-call": "error",
|
|
315
|
+
"no-useless-catch": "error",
|
|
316
|
+
"no-useless-computed-key": "error",
|
|
317
|
+
"no-useless-constructor": "error",
|
|
318
|
+
"no-useless-rename": "error",
|
|
319
|
+
"no-useless-return": "error",
|
|
320
|
+
"no-var": "error",
|
|
321
|
+
"no-with": "error",
|
|
322
|
+
"object-shorthand": [
|
|
323
|
+
"error",
|
|
324
|
+
"always",
|
|
325
|
+
{
|
|
326
|
+
avoidQuotes: true,
|
|
327
|
+
ignoreConstructors: false
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
"one-var": ["error", { initialized: "never" }],
|
|
331
|
+
"prefer-arrow-callback": ["error", {
|
|
332
|
+
allowNamedFunctions: false,
|
|
333
|
+
allowUnboundThis: true
|
|
334
|
+
}],
|
|
335
|
+
"prefer-const": ["error", {
|
|
336
|
+
destructuring: "all",
|
|
337
|
+
ignoreReadBeforeAssign: true
|
|
338
|
+
}],
|
|
339
|
+
"prefer-exponentiation-operator": "error",
|
|
340
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
341
|
+
"prefer-rest-params": "error",
|
|
342
|
+
"prefer-spread": "error",
|
|
343
|
+
"prefer-template": "error",
|
|
344
|
+
"require-await": "error",
|
|
345
|
+
"require-yield": "error",
|
|
346
|
+
"symbol-description": "error",
|
|
347
|
+
"unicode-bom": ["error", "never"],
|
|
348
|
+
"unused-imports/no-unused-imports": isInEditor$1 ? "off" : "error",
|
|
349
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
350
|
+
args: "after-used",
|
|
351
|
+
argsIgnorePattern: "^_",
|
|
352
|
+
ignoreRestSiblings: true,
|
|
353
|
+
vars: "all",
|
|
354
|
+
varsIgnorePattern: "^_"
|
|
355
|
+
}],
|
|
356
|
+
"use-isnan": ["error", {
|
|
357
|
+
enforceForIndexOf: true,
|
|
358
|
+
enforceForSwitchCase: true
|
|
359
|
+
}],
|
|
360
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
361
|
+
"vars-on-top": "error",
|
|
362
|
+
yoda: ["error", "never"],
|
|
363
|
+
...overrides
|
|
364
|
+
}
|
|
365
|
+
}];
|
|
380
366
|
}
|
|
381
367
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/shared/index.ts
|
|
370
|
+
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
371
|
+
const isCwdInScope = isPackageExists("@coderwyd/eslint-config");
|
|
372
|
+
/**
|
|
373
|
+
* Combine array and non-array configs into a single array.
|
|
374
|
+
*/
|
|
375
|
+
async function combine(...configs$1) {
|
|
376
|
+
const resolved = await Promise.all(configs$1);
|
|
377
|
+
return resolved.flat();
|
|
391
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Rename plugin prefixes in a rule object.
|
|
381
|
+
* Accepts a map of prefixes to rename.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```ts
|
|
385
|
+
* import { renameRules } from '@coderwyd/eslint-config'
|
|
386
|
+
*
|
|
387
|
+
* export default [{
|
|
388
|
+
* rules: renameRules(
|
|
389
|
+
* {
|
|
390
|
+
* '@typescript-eslint/indent': 'error'
|
|
391
|
+
* },
|
|
392
|
+
* { '@typescript-eslint': 'ts' }
|
|
393
|
+
* )
|
|
394
|
+
* }]
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
392
397
|
function renameRules(rules, map) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return [to + key.slice(from.length), value];
|
|
398
|
-
}
|
|
399
|
-
return [key, value];
|
|
400
|
-
})
|
|
401
|
-
);
|
|
398
|
+
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
399
|
+
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
400
|
+
return [key, value];
|
|
401
|
+
}));
|
|
402
402
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
403
|
+
/**
|
|
404
|
+
* Rename plugin names a flat configs array
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```ts
|
|
408
|
+
* import { renamePluginInConfigs } from '@antfu/eslint-config'
|
|
409
|
+
* import someConfigs from './some-configs'
|
|
410
|
+
*
|
|
411
|
+
* export default renamePluginInConfigs(someConfigs, {
|
|
412
|
+
* '@typescript-eslint': 'ts',
|
|
413
|
+
* 'import-x': 'import',
|
|
414
|
+
* })
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
function renamePluginInConfigs(configs$1, map) {
|
|
418
|
+
return configs$1.map((i) => {
|
|
419
|
+
const clone = { ...i };
|
|
420
|
+
if (clone.rules) clone.rules = renameRules(clone.rules, map);
|
|
421
|
+
if (clone.plugins) clone.plugins = Object.fromEntries(Object.entries(clone.plugins).map(([key, value]) => {
|
|
422
|
+
if (key in map) return [map[key], value];
|
|
423
|
+
return [key, value];
|
|
424
|
+
}));
|
|
425
|
+
return clone;
|
|
426
|
+
});
|
|
417
427
|
}
|
|
418
428
|
function getVueVersion() {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
return 3;
|
|
429
|
+
const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] });
|
|
430
|
+
if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) return +pkg.version[0];
|
|
431
|
+
return 3;
|
|
423
432
|
}
|
|
424
433
|
function toArray(value) {
|
|
425
|
-
|
|
434
|
+
return Array.isArray(value) ? value : [value];
|
|
426
435
|
}
|
|
427
436
|
async function interopDefault(m) {
|
|
428
|
-
|
|
429
|
-
|
|
437
|
+
const resolved = await m;
|
|
438
|
+
return resolved.default || resolved;
|
|
430
439
|
}
|
|
431
440
|
function isPackageInScope(name) {
|
|
432
|
-
|
|
441
|
+
return isPackageExists(name, { paths: [scopeUrl] });
|
|
433
442
|
}
|
|
434
443
|
async function ensurePackages(packages) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
]);
|
|
447
|
-
if (result) {
|
|
448
|
-
await import("@antfu/install-pkg").then(
|
|
449
|
-
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
450
|
-
);
|
|
451
|
-
}
|
|
444
|
+
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) return;
|
|
445
|
+
const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
|
|
446
|
+
if (nonExistingPackages.length === 0) return;
|
|
447
|
+
const { default: prompts } = await import("prompts");
|
|
448
|
+
const { result } = await prompts([{
|
|
449
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
450
|
+
name: "result",
|
|
451
|
+
type: "confirm"
|
|
452
|
+
}]);
|
|
453
|
+
if (result) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
452
454
|
}
|
|
453
455
|
function resolveSubOptions(options, key) {
|
|
454
|
-
|
|
456
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
455
457
|
}
|
|
456
458
|
function getOverrides(options, key) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
..."overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {}
|
|
460
|
-
};
|
|
459
|
+
const subOptions = resolveSubOptions(options, key);
|
|
460
|
+
return { ..."overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {} };
|
|
461
461
|
}
|
|
462
462
|
function isInEditorEnv() {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
467
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM || false);
|
|
463
|
+
if (process.env.CI) return false;
|
|
464
|
+
if (isInGitHooksOrLintStaged()) return false;
|
|
465
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM || false);
|
|
468
466
|
}
|
|
469
467
|
function isInGitHooksOrLintStaged() {
|
|
470
|
-
|
|
468
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged") || process.env.npm_lifecycle_script?.startsWith("nano-staged") || false);
|
|
471
469
|
}
|
|
472
470
|
|
|
473
|
-
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/configs/jsdoc.ts
|
|
474
473
|
async function jsdoc() {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
"jsdoc/require-yields-check": "warn"
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
];
|
|
474
|
+
return [{
|
|
475
|
+
name: "coderwyd/jsdoc/rules",
|
|
476
|
+
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
|
|
477
|
+
rules: {
|
|
478
|
+
"jsdoc/check-access": "warn",
|
|
479
|
+
"jsdoc/check-param-names": "warn",
|
|
480
|
+
"jsdoc/check-property-names": "warn",
|
|
481
|
+
"jsdoc/check-types": "warn",
|
|
482
|
+
"jsdoc/empty-tags": "warn",
|
|
483
|
+
"jsdoc/implements-on-classes": "warn",
|
|
484
|
+
"jsdoc/no-defaults": "warn",
|
|
485
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
486
|
+
"jsdoc/require-param-name": "warn",
|
|
487
|
+
"jsdoc/require-property": "warn",
|
|
488
|
+
"jsdoc/require-property-description": "warn",
|
|
489
|
+
"jsdoc/require-property-name": "warn",
|
|
490
|
+
"jsdoc/require-returns-check": "warn",
|
|
491
|
+
"jsdoc/require-returns-description": "warn",
|
|
492
|
+
"jsdoc/require-yields-check": "warn"
|
|
493
|
+
}
|
|
494
|
+
}];
|
|
500
495
|
}
|
|
501
496
|
|
|
502
|
-
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/configs/jsonc.ts
|
|
503
499
|
async function jsonc(options = {}) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
"jsonc/valid-json-number": "error",
|
|
548
|
-
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
549
|
-
...overrides
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
];
|
|
500
|
+
const { files = [
|
|
501
|
+
GLOB_JSON,
|
|
502
|
+
GLOB_JSON5,
|
|
503
|
+
GLOB_JSONC
|
|
504
|
+
], overrides = {} } = options || {};
|
|
505
|
+
const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
506
|
+
return [{
|
|
507
|
+
name: "coderwyd/jsonc/setup",
|
|
508
|
+
plugins: { jsonc: pluginJsonc }
|
|
509
|
+
}, {
|
|
510
|
+
files,
|
|
511
|
+
languageOptions: { parser: parserJsonc },
|
|
512
|
+
name: "coderwyd/jsonc/rules",
|
|
513
|
+
rules: {
|
|
514
|
+
"jsonc/no-bigint-literals": "error",
|
|
515
|
+
"jsonc/no-binary-expression": "error",
|
|
516
|
+
"jsonc/no-binary-numeric-literals": "error",
|
|
517
|
+
"jsonc/no-dupe-keys": "error",
|
|
518
|
+
"jsonc/no-escape-sequence-in-identifier": "error",
|
|
519
|
+
"jsonc/no-floating-decimal": "error",
|
|
520
|
+
"jsonc/no-hexadecimal-numeric-literals": "error",
|
|
521
|
+
"jsonc/no-infinity": "error",
|
|
522
|
+
"jsonc/no-multi-str": "error",
|
|
523
|
+
"jsonc/no-nan": "error",
|
|
524
|
+
"jsonc/no-number-props": "error",
|
|
525
|
+
"jsonc/no-numeric-separators": "error",
|
|
526
|
+
"jsonc/no-octal": "error",
|
|
527
|
+
"jsonc/no-octal-escape": "error",
|
|
528
|
+
"jsonc/no-octal-numeric-literals": "error",
|
|
529
|
+
"jsonc/no-parenthesized": "error",
|
|
530
|
+
"jsonc/no-plus-sign": "error",
|
|
531
|
+
"jsonc/no-regexp-literals": "error",
|
|
532
|
+
"jsonc/no-sparse-arrays": "error",
|
|
533
|
+
"jsonc/no-template-literals": "error",
|
|
534
|
+
"jsonc/no-undefined-value": "error",
|
|
535
|
+
"jsonc/no-unicode-codepoint-escapes": "error",
|
|
536
|
+
"jsonc/no-useless-escape": "error",
|
|
537
|
+
"jsonc/space-unary-ops": "error",
|
|
538
|
+
"jsonc/valid-json-number": "error",
|
|
539
|
+
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
540
|
+
...overrides
|
|
541
|
+
}
|
|
542
|
+
}];
|
|
553
543
|
}
|
|
554
544
|
|
|
555
|
-
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/configs/node.ts
|
|
556
547
|
function node() {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
"node/process-exit-as-throw": "error"
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
];
|
|
548
|
+
return [{
|
|
549
|
+
name: "coderwyd/node/rules",
|
|
550
|
+
plugins: { node: pluginNode },
|
|
551
|
+
rules: {
|
|
552
|
+
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
553
|
+
"node/no-deprecated-api": "error",
|
|
554
|
+
"node/no-exports-assign": "error",
|
|
555
|
+
"node/no-new-require": "error",
|
|
556
|
+
"node/no-path-concat": "error",
|
|
557
|
+
"node/no-unsupported-features/es-builtins": "error",
|
|
558
|
+
"node/prefer-global/buffer": ["error", "never"],
|
|
559
|
+
"node/prefer-global/process": ["error", "never"],
|
|
560
|
+
"node/process-exit-as-throw": "error"
|
|
561
|
+
}
|
|
562
|
+
}];
|
|
576
563
|
}
|
|
577
564
|
|
|
578
|
-
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region src/configs/perfectionist.ts
|
|
567
|
+
/**
|
|
568
|
+
* Optional perfectionist plugin for props and items sorting.
|
|
569
|
+
*
|
|
570
|
+
* @see https://github.com/azat-io/eslint-plugin-perfectionist
|
|
571
|
+
*/
|
|
579
572
|
function perfectionist() {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
573
|
+
return [{
|
|
574
|
+
name: "coderwyd/perfectionist/rules",
|
|
575
|
+
plugins: { perfectionist: pluginPerfectionist },
|
|
576
|
+
rules: {
|
|
577
|
+
"perfectionist/sort-exports": ["error", {
|
|
578
|
+
order: "asc",
|
|
579
|
+
type: "natural"
|
|
580
|
+
}],
|
|
581
|
+
"perfectionist/sort-imports": ["warn", {
|
|
582
|
+
groups: [
|
|
583
|
+
"side-effect-style",
|
|
584
|
+
"value-style",
|
|
585
|
+
"value-builtin",
|
|
586
|
+
"value-external",
|
|
587
|
+
"value-subpath",
|
|
588
|
+
"value-internal",
|
|
589
|
+
"value-parent",
|
|
590
|
+
"value-sibling",
|
|
591
|
+
"value-index",
|
|
592
|
+
"ts-equals-import",
|
|
593
|
+
"side-effect",
|
|
594
|
+
"type-builtin",
|
|
595
|
+
"type-external",
|
|
596
|
+
"type-subpath",
|
|
597
|
+
"type-internal",
|
|
598
|
+
"type-parent",
|
|
599
|
+
"type-sibling",
|
|
600
|
+
"type-index",
|
|
601
|
+
"unknown"
|
|
602
|
+
],
|
|
603
|
+
internalPattern: ["^[~@#]/.*"],
|
|
604
|
+
newlinesBetween: "ignore",
|
|
605
|
+
order: "asc",
|
|
606
|
+
type: "natural"
|
|
607
|
+
}],
|
|
608
|
+
"perfectionist/sort-named-exports": ["warn", {
|
|
609
|
+
groupKind: "values-first",
|
|
610
|
+
order: "asc",
|
|
611
|
+
type: "natural"
|
|
612
|
+
}],
|
|
613
|
+
"perfectionist/sort-named-imports": ["warn", {
|
|
614
|
+
groupKind: "values-first",
|
|
615
|
+
order: "asc",
|
|
616
|
+
type: "natural"
|
|
617
|
+
}]
|
|
618
|
+
}
|
|
619
|
+
}];
|
|
624
620
|
}
|
|
625
621
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
622
|
+
//#endregion
|
|
623
|
+
//#region src/configs/prettier.ts
|
|
624
|
+
const { rules: eslintRules } = prettierRules;
|
|
629
625
|
function prettier() {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
];
|
|
626
|
+
return [{
|
|
627
|
+
name: "coderwyd/prettier/rules",
|
|
628
|
+
rules: {
|
|
629
|
+
...eslintRules,
|
|
630
|
+
"arrow-body-style": "off",
|
|
631
|
+
"prefer-arrow-callback": "off"
|
|
632
|
+
}
|
|
633
|
+
}];
|
|
640
634
|
}
|
|
641
635
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
"@remix-run/serve",
|
|
651
|
-
"@remix-run/dev"
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/env.ts
|
|
638
|
+
const isInEditor = !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI);
|
|
639
|
+
const VueJsPackages = [
|
|
640
|
+
"vue",
|
|
641
|
+
"nuxt",
|
|
642
|
+
"vitepress",
|
|
643
|
+
"@slidev/cli"
|
|
652
644
|
];
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
645
|
+
const RemixPackages = [
|
|
646
|
+
"@remix-run/node",
|
|
647
|
+
"@remix-run/react",
|
|
648
|
+
"@remix-run/serve",
|
|
649
|
+
"@remix-run/dev"
|
|
658
650
|
];
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
);
|
|
651
|
+
const ReactRouterPackages = [
|
|
652
|
+
"@react-router/node",
|
|
653
|
+
"@react-router/react",
|
|
654
|
+
"@react-router/serve",
|
|
655
|
+
"@react-router/dev"
|
|
656
|
+
];
|
|
657
|
+
const NextJsPackages = ["next"];
|
|
658
|
+
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
659
|
+
const isUsingTypeScript = isPackageExists("typescript");
|
|
660
|
+
const isUsingVue = hasPackages(VueJsPackages);
|
|
661
|
+
const isUsingRemix = hasPackages(RemixPackages);
|
|
662
|
+
const isUsingReactRouter = hasPackages(ReactRouterPackages);
|
|
663
|
+
const isUsingNext = hasPackages(NextJsPackages);
|
|
664
|
+
const isAllowConstantExport = hasPackages(ReactRefreshAllowConstantExportPackages);
|
|
669
665
|
function hasPackages(packages) {
|
|
670
|
-
|
|
666
|
+
return packages.some((name) => isPackageExists(name));
|
|
671
667
|
}
|
|
672
668
|
|
|
673
|
-
|
|
669
|
+
//#endregion
|
|
670
|
+
//#region src/configs/react.ts
|
|
674
671
|
async function react(options = {}) {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
"react/no-unsafe-component-will-update": "warn",
|
|
809
|
-
"react/no-unstable-context-value": "warn",
|
|
810
|
-
"react/no-unstable-default-props": "warn",
|
|
811
|
-
"react/no-unused-class-component-members": "warn",
|
|
812
|
-
"react/no-unused-state": "warn",
|
|
813
|
-
"react/prefer-destructuring-assignment": "warn",
|
|
814
|
-
"react/prefer-shorthand-boolean": "warn",
|
|
815
|
-
"react/prefer-shorthand-fragment": "warn",
|
|
816
|
-
// overrides
|
|
817
|
-
...overrides
|
|
818
|
-
}
|
|
819
|
-
},
|
|
820
|
-
...isTypeAware ? [
|
|
821
|
-
{
|
|
822
|
-
files: filesTypeAware,
|
|
823
|
-
ignores: ignoresTypeAware,
|
|
824
|
-
name: "coderwyd/react/type-aware-rules",
|
|
825
|
-
rules: {
|
|
826
|
-
...typeAwareRules
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
] : []
|
|
830
|
-
];
|
|
672
|
+
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], overrides = {}, tsconfigPath } = options;
|
|
673
|
+
await ensurePackages([
|
|
674
|
+
"@eslint-react/eslint-plugin",
|
|
675
|
+
"eslint-plugin-react-hooks",
|
|
676
|
+
"eslint-plugin-react-refresh"
|
|
677
|
+
]);
|
|
678
|
+
const isTypeAware = !!tsconfigPath;
|
|
679
|
+
const typeAwareRules = { "react/no-leaked-conditional-rendering": "warn" };
|
|
680
|
+
const [pluginReact, pluginReactHooks, pluginReactRefresh, pluginReactCompiler] = await Promise.all([
|
|
681
|
+
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
682
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
683
|
+
interopDefault(import("eslint-plugin-react-refresh")),
|
|
684
|
+
interopDefault(import("eslint-plugin-react-compiler"))
|
|
685
|
+
]);
|
|
686
|
+
const plugins = pluginReact.configs.all.plugins;
|
|
687
|
+
return [
|
|
688
|
+
{
|
|
689
|
+
name: "coderwyd/react/setup",
|
|
690
|
+
plugins: {
|
|
691
|
+
react: plugins["@eslint-react"],
|
|
692
|
+
"react-compiler": pluginReactCompiler,
|
|
693
|
+
"react-dom": plugins["@eslint-react/dom"],
|
|
694
|
+
"react-hooks": pluginReactHooks,
|
|
695
|
+
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
696
|
+
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
697
|
+
"react-refresh": pluginReactRefresh,
|
|
698
|
+
"react-web-api": plugins["@eslint-react/web-api"]
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
files,
|
|
703
|
+
languageOptions: {
|
|
704
|
+
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
705
|
+
sourceType: "module"
|
|
706
|
+
},
|
|
707
|
+
name: "coderwyd/react/rules",
|
|
708
|
+
rules: {
|
|
709
|
+
"react-compiler/react-compiler": "warn",
|
|
710
|
+
"react/no-access-state-in-setstate": "error",
|
|
711
|
+
"react/no-array-index-key": "warn",
|
|
712
|
+
"react/no-children-count": "warn",
|
|
713
|
+
"react/no-children-for-each": "warn",
|
|
714
|
+
"react/no-children-map": "warn",
|
|
715
|
+
"react/no-children-only": "warn",
|
|
716
|
+
"react/no-children-to-array": "warn",
|
|
717
|
+
"react/no-clone-element": "warn",
|
|
718
|
+
"react/no-comment-textnodes": "warn",
|
|
719
|
+
"react/no-component-will-mount": "error",
|
|
720
|
+
"react/no-component-will-receive-props": "error",
|
|
721
|
+
"react/no-component-will-update": "error",
|
|
722
|
+
"react/no-context-provider": "warn",
|
|
723
|
+
"react/no-create-ref": "error",
|
|
724
|
+
"react/no-default-props": "error",
|
|
725
|
+
"react/no-direct-mutation-state": "error",
|
|
726
|
+
"react/no-duplicate-jsx-props": "warn",
|
|
727
|
+
"react/no-duplicate-key": "warn",
|
|
728
|
+
"react/no-forward-ref": "warn",
|
|
729
|
+
"react/no-implicit-key": "warn",
|
|
730
|
+
"react/no-missing-key": "error",
|
|
731
|
+
"react/no-nested-component-definitions": "error",
|
|
732
|
+
"react/no-prop-types": "error",
|
|
733
|
+
"react/no-redundant-should-component-update": "error",
|
|
734
|
+
"react/no-set-state-in-component-did-mount": "warn",
|
|
735
|
+
"react/no-set-state-in-component-did-update": "warn",
|
|
736
|
+
"react/no-set-state-in-component-will-update": "warn",
|
|
737
|
+
"react/no-string-refs": "error",
|
|
738
|
+
"react/no-unsafe-component-will-mount": "warn",
|
|
739
|
+
"react/no-unsafe-component-will-receive-props": "warn",
|
|
740
|
+
"react/no-unsafe-component-will-update": "warn",
|
|
741
|
+
"react/no-unstable-context-value": "warn",
|
|
742
|
+
"react/no-unstable-default-props": "warn",
|
|
743
|
+
"react/no-unused-class-component-members": "warn",
|
|
744
|
+
"react/no-unused-state": "warn",
|
|
745
|
+
"react/no-use-context": "warn",
|
|
746
|
+
"react/no-useless-forward-ref": "warn",
|
|
747
|
+
"react/use-jsx-vars": "warn",
|
|
748
|
+
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
749
|
+
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
750
|
+
"react-dom/no-find-dom-node": "error",
|
|
751
|
+
"react-dom/no-flush-sync": "error",
|
|
752
|
+
"react-dom/no-hydrate": "error",
|
|
753
|
+
"react-dom/no-missing-button-type": "warn",
|
|
754
|
+
"react-dom/no-missing-iframe-sandbox": "warn",
|
|
755
|
+
"react-dom/no-namespace": "error",
|
|
756
|
+
"react-dom/no-render": "error",
|
|
757
|
+
"react-dom/no-render-return-value": "error",
|
|
758
|
+
"react-dom/no-script-url": "warn",
|
|
759
|
+
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
760
|
+
"react-dom/no-unsafe-target-blank": "warn",
|
|
761
|
+
"react-dom/no-use-form-state": "error",
|
|
762
|
+
"react-dom/no-void-elements-with-children": "error",
|
|
763
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
764
|
+
"react-hooks/rules-of-hooks": "error",
|
|
765
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
766
|
+
"react-hooks-extra/no-unnecessary-use-prefix": "warn",
|
|
767
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
768
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
769
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
770
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
771
|
+
"react-refresh/only-export-components": ["warn", {
|
|
772
|
+
allowConstantExport: isAllowConstantExport,
|
|
773
|
+
allowExportNames: [...isUsingNext ? [
|
|
774
|
+
"dynamic",
|
|
775
|
+
"dynamicParams",
|
|
776
|
+
"revalidate",
|
|
777
|
+
"fetchCache",
|
|
778
|
+
"runtime",
|
|
779
|
+
"preferredRegion",
|
|
780
|
+
"maxDuration",
|
|
781
|
+
"config",
|
|
782
|
+
"generateStaticParams",
|
|
783
|
+
"metadata",
|
|
784
|
+
"generateMetadata",
|
|
785
|
+
"viewport",
|
|
786
|
+
"generateViewport"
|
|
787
|
+
] : [], ...isUsingRemix || isUsingReactRouter ? [
|
|
788
|
+
"meta",
|
|
789
|
+
"links",
|
|
790
|
+
"headers",
|
|
791
|
+
"loader",
|
|
792
|
+
"action"
|
|
793
|
+
] : []]
|
|
794
|
+
}],
|
|
795
|
+
...overrides
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
...isTypeAware ? [{
|
|
799
|
+
files: filesTypeAware,
|
|
800
|
+
ignores: ignoresTypeAware,
|
|
801
|
+
name: "antfu/react/type-aware-rules",
|
|
802
|
+
rules: { ...typeAwareRules }
|
|
803
|
+
}] : []
|
|
804
|
+
];
|
|
831
805
|
}
|
|
832
806
|
|
|
833
|
-
|
|
834
|
-
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region src/configs/regexp.ts
|
|
835
809
|
function regexp(options = {}) {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
rules: {
|
|
850
|
-
...rules,
|
|
851
|
-
...options.overrides
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
];
|
|
810
|
+
const config = configs["flat/recommended"];
|
|
811
|
+
const rules = { ...config.rules };
|
|
812
|
+
if (options.level === "warn") Object.keys(rules).forEach((key) => {
|
|
813
|
+
if (rules[key] === "error") rules[key] = "warn";
|
|
814
|
+
});
|
|
815
|
+
return [{
|
|
816
|
+
...config,
|
|
817
|
+
name: "coderwyd/regexp/rules",
|
|
818
|
+
rules: {
|
|
819
|
+
...rules,
|
|
820
|
+
...options.overrides
|
|
821
|
+
}
|
|
822
|
+
}];
|
|
855
823
|
}
|
|
856
824
|
|
|
857
|
-
|
|
825
|
+
//#endregion
|
|
826
|
+
//#region src/configs/sort.ts
|
|
827
|
+
/**
|
|
828
|
+
* Sort package.json
|
|
829
|
+
*
|
|
830
|
+
* Requires `jsonc` config
|
|
831
|
+
*/
|
|
858
832
|
function sortPackageJson() {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
];
|
|
833
|
+
return [{
|
|
834
|
+
files: ["**/package.json"],
|
|
835
|
+
name: "coderwyd/sort/package-json",
|
|
836
|
+
rules: {
|
|
837
|
+
"jsonc/sort-array-values": ["error", {
|
|
838
|
+
order: { type: "asc" },
|
|
839
|
+
pathPattern: "^files$"
|
|
840
|
+
}],
|
|
841
|
+
"jsonc/sort-keys": [
|
|
842
|
+
"error",
|
|
843
|
+
{
|
|
844
|
+
order: [
|
|
845
|
+
"publisher",
|
|
846
|
+
"name",
|
|
847
|
+
"displayName",
|
|
848
|
+
"type",
|
|
849
|
+
"version",
|
|
850
|
+
"private",
|
|
851
|
+
"packageManager",
|
|
852
|
+
"description",
|
|
853
|
+
"author",
|
|
854
|
+
"license",
|
|
855
|
+
"funding",
|
|
856
|
+
"homepage",
|
|
857
|
+
"repository",
|
|
858
|
+
"bugs",
|
|
859
|
+
"keywords",
|
|
860
|
+
"categories",
|
|
861
|
+
"sideEffects",
|
|
862
|
+
"exports",
|
|
863
|
+
"main",
|
|
864
|
+
"module",
|
|
865
|
+
"unpkg",
|
|
866
|
+
"jsdelivr",
|
|
867
|
+
"types",
|
|
868
|
+
"typesVersions",
|
|
869
|
+
"bin",
|
|
870
|
+
"icon",
|
|
871
|
+
"files",
|
|
872
|
+
"engines",
|
|
873
|
+
"activationEvents",
|
|
874
|
+
"contributes",
|
|
875
|
+
"scripts",
|
|
876
|
+
"peerDependencies",
|
|
877
|
+
"peerDependenciesMeta",
|
|
878
|
+
"dependencies",
|
|
879
|
+
"optionalDependencies",
|
|
880
|
+
"devDependencies",
|
|
881
|
+
"pnpm",
|
|
882
|
+
"overrides",
|
|
883
|
+
"resolutions",
|
|
884
|
+
"husky",
|
|
885
|
+
"simple-git-hooks",
|
|
886
|
+
"lint-staged",
|
|
887
|
+
"nano-staged",
|
|
888
|
+
"eslintConfig"
|
|
889
|
+
],
|
|
890
|
+
pathPattern: "^$"
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
order: { type: "asc" },
|
|
894
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
order: { type: "asc" },
|
|
898
|
+
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
order: [
|
|
902
|
+
"types",
|
|
903
|
+
"import",
|
|
904
|
+
"require",
|
|
905
|
+
"default"
|
|
906
|
+
],
|
|
907
|
+
pathPattern: "^exports.*$"
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
order: [
|
|
911
|
+
"pre-commit",
|
|
912
|
+
"prepare-commit-msg",
|
|
913
|
+
"commit-msg",
|
|
914
|
+
"post-commit",
|
|
915
|
+
"pre-rebase",
|
|
916
|
+
"post-rewrite",
|
|
917
|
+
"post-checkout",
|
|
918
|
+
"post-merge",
|
|
919
|
+
"pre-push",
|
|
920
|
+
"pre-auto-gc"
|
|
921
|
+
],
|
|
922
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
|
|
923
|
+
}
|
|
924
|
+
]
|
|
925
|
+
}
|
|
926
|
+
}];
|
|
954
927
|
}
|
|
928
|
+
/**
|
|
929
|
+
* Sort tsconfig.json
|
|
930
|
+
*
|
|
931
|
+
* Requires `jsonc` config
|
|
932
|
+
*/
|
|
955
933
|
function sortTsconfig() {
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
/* Completeness */
|
|
1071
|
-
"skipDefaultLibCheck",
|
|
1072
|
-
"skipLibCheck"
|
|
1073
|
-
],
|
|
1074
|
-
pathPattern: "^compilerOptions$"
|
|
1075
|
-
}
|
|
1076
|
-
]
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
];
|
|
934
|
+
return [{
|
|
935
|
+
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
936
|
+
name: "coderwyd/sort/tsconfig-json",
|
|
937
|
+
rules: { "jsonc/sort-keys": [
|
|
938
|
+
"error",
|
|
939
|
+
{
|
|
940
|
+
order: [
|
|
941
|
+
"extends",
|
|
942
|
+
"compilerOptions",
|
|
943
|
+
"references",
|
|
944
|
+
"files",
|
|
945
|
+
"include",
|
|
946
|
+
"exclude"
|
|
947
|
+
],
|
|
948
|
+
pathPattern: "^$"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
order: [
|
|
952
|
+
"incremental",
|
|
953
|
+
"composite",
|
|
954
|
+
"tsBuildInfoFile",
|
|
955
|
+
"disableSourceOfProjectReferenceRedirect",
|
|
956
|
+
"disableSolutionSearching",
|
|
957
|
+
"disableReferencedProjectLoad",
|
|
958
|
+
"target",
|
|
959
|
+
"jsx",
|
|
960
|
+
"jsxFactory",
|
|
961
|
+
"jsxFragmentFactory",
|
|
962
|
+
"jsxImportSource",
|
|
963
|
+
"lib",
|
|
964
|
+
"moduleDetection",
|
|
965
|
+
"noLib",
|
|
966
|
+
"reactNamespace",
|
|
967
|
+
"useDefineForClassFields",
|
|
968
|
+
"emitDecoratorMetadata",
|
|
969
|
+
"experimentalDecorators",
|
|
970
|
+
"libReplacement",
|
|
971
|
+
"baseUrl",
|
|
972
|
+
"rootDir",
|
|
973
|
+
"rootDirs",
|
|
974
|
+
"customConditions",
|
|
975
|
+
"module",
|
|
976
|
+
"moduleResolution",
|
|
977
|
+
"moduleSuffixes",
|
|
978
|
+
"noResolve",
|
|
979
|
+
"paths",
|
|
980
|
+
"resolveJsonModule",
|
|
981
|
+
"resolvePackageJsonExports",
|
|
982
|
+
"resolvePackageJsonImports",
|
|
983
|
+
"typeRoots",
|
|
984
|
+
"types",
|
|
985
|
+
"allowArbitraryExtensions",
|
|
986
|
+
"allowImportingTsExtensions",
|
|
987
|
+
"allowUmdGlobalAccess",
|
|
988
|
+
"allowJs",
|
|
989
|
+
"checkJs",
|
|
990
|
+
"maxNodeModuleJsDepth",
|
|
991
|
+
"strict",
|
|
992
|
+
"strictBindCallApply",
|
|
993
|
+
"strictFunctionTypes",
|
|
994
|
+
"strictNullChecks",
|
|
995
|
+
"strictPropertyInitialization",
|
|
996
|
+
"allowUnreachableCode",
|
|
997
|
+
"allowUnusedLabels",
|
|
998
|
+
"alwaysStrict",
|
|
999
|
+
"exactOptionalPropertyTypes",
|
|
1000
|
+
"noFallthroughCasesInSwitch",
|
|
1001
|
+
"noImplicitAny",
|
|
1002
|
+
"noImplicitOverride",
|
|
1003
|
+
"noImplicitReturns",
|
|
1004
|
+
"noImplicitThis",
|
|
1005
|
+
"noPropertyAccessFromIndexSignature",
|
|
1006
|
+
"noUncheckedIndexedAccess",
|
|
1007
|
+
"noUnusedLocals",
|
|
1008
|
+
"noUnusedParameters",
|
|
1009
|
+
"useUnknownInCatchVariables",
|
|
1010
|
+
"declaration",
|
|
1011
|
+
"declarationDir",
|
|
1012
|
+
"declarationMap",
|
|
1013
|
+
"downlevelIteration",
|
|
1014
|
+
"emitBOM",
|
|
1015
|
+
"emitDeclarationOnly",
|
|
1016
|
+
"importHelpers",
|
|
1017
|
+
"importsNotUsedAsValues",
|
|
1018
|
+
"inlineSourceMap",
|
|
1019
|
+
"inlineSources",
|
|
1020
|
+
"mapRoot",
|
|
1021
|
+
"newLine",
|
|
1022
|
+
"noEmit",
|
|
1023
|
+
"noEmitHelpers",
|
|
1024
|
+
"noEmitOnError",
|
|
1025
|
+
"outDir",
|
|
1026
|
+
"outFile",
|
|
1027
|
+
"preserveConstEnums",
|
|
1028
|
+
"preserveValueImports",
|
|
1029
|
+
"removeComments",
|
|
1030
|
+
"sourceMap",
|
|
1031
|
+
"sourceRoot",
|
|
1032
|
+
"stripInternal",
|
|
1033
|
+
"allowSyntheticDefaultImports",
|
|
1034
|
+
"esModuleInterop",
|
|
1035
|
+
"forceConsistentCasingInFileNames",
|
|
1036
|
+
"isolatedDeclarations",
|
|
1037
|
+
"isolatedModules",
|
|
1038
|
+
"preserveSymlinks",
|
|
1039
|
+
"verbatimModuleSyntax",
|
|
1040
|
+
"erasableSyntaxOnly",
|
|
1041
|
+
"skipDefaultLibCheck",
|
|
1042
|
+
"skipLibCheck"
|
|
1043
|
+
],
|
|
1044
|
+
pathPattern: "^compilerOptions$"
|
|
1045
|
+
}
|
|
1046
|
+
] }
|
|
1047
|
+
}];
|
|
1080
1048
|
}
|
|
1081
1049
|
|
|
1082
|
-
|
|
1050
|
+
//#endregion
|
|
1051
|
+
//#region src/configs/specials.ts
|
|
1083
1052
|
function specials() {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
}
|
|
1135
|
-
];
|
|
1053
|
+
return [
|
|
1054
|
+
{
|
|
1055
|
+
files: [`**/scripts/${GLOB_SRC}`],
|
|
1056
|
+
name: "coderwyd/specials/scripts",
|
|
1057
|
+
rules: {
|
|
1058
|
+
"antfu/no-top-level-await": "off",
|
|
1059
|
+
"no-console": "off",
|
|
1060
|
+
"ts/explicit-function-return-type": "off"
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
1065
|
+
name: "coderwyd/specials/cli",
|
|
1066
|
+
rules: {
|
|
1067
|
+
"antfu/no-top-level-await": "off",
|
|
1068
|
+
"no-console": "off"
|
|
1069
|
+
}
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
1073
|
+
name: "coderwyd/specials/bin",
|
|
1074
|
+
rules: {
|
|
1075
|
+
"antfu/no-import-dist": "off",
|
|
1076
|
+
"antfu/no-import-node-modules-by-path": "off"
|
|
1077
|
+
}
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
files: [GLOB_DTS],
|
|
1081
|
+
name: "coderwyd/specials/dts",
|
|
1082
|
+
rules: {
|
|
1083
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
1084
|
+
"import/no-duplicates": "off",
|
|
1085
|
+
"no-restricted-syntax": "off",
|
|
1086
|
+
"unused-imports/no-unused-vars": "off"
|
|
1087
|
+
}
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
files: ["**/*.{test,spec}.([tj])s?(x)"],
|
|
1091
|
+
name: "coderwyd/specials/test",
|
|
1092
|
+
rules: {
|
|
1093
|
+
"antfu/no-top-level-await": "off",
|
|
1094
|
+
"no-unused-expressions": "off"
|
|
1095
|
+
}
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
1099
|
+
name: "coderwyd/specials/cjs",
|
|
1100
|
+
rules: { "ts/no-require-imports": "off" }
|
|
1101
|
+
}
|
|
1102
|
+
];
|
|
1136
1103
|
}
|
|
1137
1104
|
|
|
1138
|
-
|
|
1105
|
+
//#endregion
|
|
1106
|
+
//#region src/configs/svelte.ts
|
|
1139
1107
|
async function svelte(options = {}) {
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
"svelte/no-useless-mustaches": "error",
|
|
1197
|
-
"svelte/require-store-callbacks-use-set-param": "error",
|
|
1198
|
-
"svelte/system": "error",
|
|
1199
|
-
"svelte/valid-each-key": "error",
|
|
1200
|
-
"unused-imports/no-unused-vars": [
|
|
1201
|
-
"error",
|
|
1202
|
-
{
|
|
1203
|
-
args: "after-used",
|
|
1204
|
-
argsIgnorePattern: "^_",
|
|
1205
|
-
vars: "all",
|
|
1206
|
-
varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1207
|
-
}
|
|
1208
|
-
],
|
|
1209
|
-
...overrides
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
];
|
|
1108
|
+
const { files = [GLOB_SVELTE], overrides = {} } = options;
|
|
1109
|
+
await ensurePackages(["eslint-plugin-svelte"]);
|
|
1110
|
+
const [pluginSvelte, parserSvelte] = await Promise.all([interopDefault(import("eslint-plugin-svelte")), interopDefault(import("svelte-eslint-parser"))]);
|
|
1111
|
+
return [{
|
|
1112
|
+
name: "coderwyd/svelte/setup",
|
|
1113
|
+
plugins: { svelte: pluginSvelte }
|
|
1114
|
+
}, {
|
|
1115
|
+
files,
|
|
1116
|
+
languageOptions: {
|
|
1117
|
+
parser: parserSvelte,
|
|
1118
|
+
parserOptions: {
|
|
1119
|
+
extraFileExtensions: [".svelte"],
|
|
1120
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
name: "coderwyd/svelte/rules",
|
|
1124
|
+
processor: pluginSvelte.processors[".svelte"],
|
|
1125
|
+
rules: {
|
|
1126
|
+
"import/no-mutable-exports": "off",
|
|
1127
|
+
"no-undef": "off",
|
|
1128
|
+
"no-unused-vars": ["error", {
|
|
1129
|
+
args: "none",
|
|
1130
|
+
caughtErrors: "none",
|
|
1131
|
+
ignoreRestSiblings: true,
|
|
1132
|
+
vars: "all",
|
|
1133
|
+
varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1134
|
+
}],
|
|
1135
|
+
"svelte/comment-directive": "error",
|
|
1136
|
+
"svelte/no-at-debug-tags": "warn",
|
|
1137
|
+
"svelte/no-at-html-tags": "error",
|
|
1138
|
+
"svelte/no-dupe-else-if-blocks": "error",
|
|
1139
|
+
"svelte/no-dupe-style-properties": "error",
|
|
1140
|
+
"svelte/no-dupe-use-directives": "error",
|
|
1141
|
+
"svelte/no-dynamic-slot-name": "error",
|
|
1142
|
+
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
1143
|
+
"svelte/no-inner-declarations": "error",
|
|
1144
|
+
"svelte/no-not-function-handler": "error",
|
|
1145
|
+
"svelte/no-object-in-text-mustaches": "error",
|
|
1146
|
+
"svelte/no-reactive-functions": "error",
|
|
1147
|
+
"svelte/no-reactive-literals": "error",
|
|
1148
|
+
"svelte/no-shorthand-style-property-overrides": "error",
|
|
1149
|
+
"svelte/no-unknown-style-directive-property": "error",
|
|
1150
|
+
"svelte/no-unused-svelte-ignore": "error",
|
|
1151
|
+
"svelte/no-useless-mustaches": "error",
|
|
1152
|
+
"svelte/require-store-callbacks-use-set-param": "error",
|
|
1153
|
+
"svelte/system": "error",
|
|
1154
|
+
"svelte/valid-each-key": "error",
|
|
1155
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
1156
|
+
args: "after-used",
|
|
1157
|
+
argsIgnorePattern: "^_",
|
|
1158
|
+
vars: "all",
|
|
1159
|
+
varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1160
|
+
}],
|
|
1161
|
+
...overrides
|
|
1162
|
+
}
|
|
1163
|
+
}];
|
|
1213
1164
|
}
|
|
1214
1165
|
|
|
1215
|
-
|
|
1166
|
+
//#endregion
|
|
1167
|
+
//#region src/configs/tailwindcss.ts
|
|
1216
1168
|
async function tailwindcss(options = {}) {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
"tailwindcss/no-custom-classname": "off",
|
|
1236
|
-
"tailwindcss/no-unnecessary-arbitrary-value": "warn",
|
|
1237
|
-
...overrides
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
];
|
|
1169
|
+
const { overrides } = options;
|
|
1170
|
+
await ensurePackages(["eslint-plugin-tailwindcss"]);
|
|
1171
|
+
const pluginTailwindcss = await interopDefault(import("eslint-plugin-tailwindcss"));
|
|
1172
|
+
return [{
|
|
1173
|
+
name: "coderwyd/tailwindcss/rules",
|
|
1174
|
+
plugins: { tailwindcss: pluginTailwindcss },
|
|
1175
|
+
rules: {
|
|
1176
|
+
"tailwindcss/classnames-order": "warn",
|
|
1177
|
+
"tailwindcss/enforces-negative-arbitrary-values": "warn",
|
|
1178
|
+
"tailwindcss/enforces-shorthand": "warn",
|
|
1179
|
+
"tailwindcss/migration-from-tailwind-2": "warn",
|
|
1180
|
+
"tailwindcss/no-arbitrary-value": "off",
|
|
1181
|
+
"tailwindcss/no-contradicting-classname": "warn",
|
|
1182
|
+
"tailwindcss/no-custom-classname": "off",
|
|
1183
|
+
"tailwindcss/no-unnecessary-arbitrary-value": "warn",
|
|
1184
|
+
...overrides
|
|
1185
|
+
}
|
|
1186
|
+
}];
|
|
1241
1187
|
}
|
|
1242
1188
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1189
|
+
//#endregion
|
|
1190
|
+
//#region src/configs/test.ts
|
|
1191
|
+
let _pluginTest;
|
|
1245
1192
|
async function test(options = {}) {
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
"test/no-identical-title": "error",
|
|
1277
|
-
"test/no-import-node-test": "error",
|
|
1278
|
-
"test/no-only-tests": isInEditor2 ? "off" : "error",
|
|
1279
|
-
"test/prefer-hooks-in-order": "error",
|
|
1280
|
-
"test/prefer-lowercase-title": "error",
|
|
1281
|
-
"ts/explicit-function-return-type": "off",
|
|
1282
|
-
...overrides
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
];
|
|
1193
|
+
const { files = GLOB_TESTS, isInEditor: isInEditor$1 = false, overrides = {} } = options;
|
|
1194
|
+
const [pluginVitest, pluginNoOnlyTests] = await Promise.all([interopDefault(import("@vitest/eslint-plugin")), interopDefault(import("eslint-plugin-no-only-tests"))]);
|
|
1195
|
+
_pluginTest = _pluginTest || {
|
|
1196
|
+
...pluginVitest,
|
|
1197
|
+
rules: {
|
|
1198
|
+
...pluginVitest.rules,
|
|
1199
|
+
...pluginNoOnlyTests.rules
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
return [{
|
|
1203
|
+
name: "coderwyd/test/setup",
|
|
1204
|
+
plugins: { test: _pluginTest }
|
|
1205
|
+
}, {
|
|
1206
|
+
files,
|
|
1207
|
+
name: "coderwyd/test/rules",
|
|
1208
|
+
rules: {
|
|
1209
|
+
"node/prefer-global/process": "off",
|
|
1210
|
+
"test/consistent-test-it": ["error", {
|
|
1211
|
+
fn: "it",
|
|
1212
|
+
withinDescribe: "it"
|
|
1213
|
+
}],
|
|
1214
|
+
"test/no-identical-title": "error",
|
|
1215
|
+
"test/no-import-node-test": "error",
|
|
1216
|
+
"test/no-only-tests": isInEditor$1 ? "off" : "error",
|
|
1217
|
+
"test/prefer-hooks-in-order": "error",
|
|
1218
|
+
"test/prefer-lowercase-title": "error",
|
|
1219
|
+
"ts/explicit-function-return-type": "off",
|
|
1220
|
+
...overrides
|
|
1221
|
+
}
|
|
1222
|
+
}];
|
|
1286
1223
|
}
|
|
1287
1224
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1225
|
+
//#endregion
|
|
1226
|
+
//#region src/configs/typescript.ts
|
|
1290
1227
|
async function typescript(options = {}) {
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
"ts/no-invalid-void-type": "off",
|
|
1417
|
-
"ts/no-non-null-assertion": "off",
|
|
1418
|
-
"ts/no-redeclare": ["error", { builtinGlobals: false }],
|
|
1419
|
-
"ts/no-require-imports": "error",
|
|
1420
|
-
"ts/no-unused-expressions": [
|
|
1421
|
-
"error",
|
|
1422
|
-
{
|
|
1423
|
-
allowShortCircuit: true,
|
|
1424
|
-
allowTaggedTemplates: true,
|
|
1425
|
-
allowTernary: true
|
|
1426
|
-
}
|
|
1427
|
-
],
|
|
1428
|
-
"ts/no-unused-vars": "off",
|
|
1429
|
-
"ts/no-use-before-define": [
|
|
1430
|
-
"error",
|
|
1431
|
-
{ classes: false, functions: false, variables: true }
|
|
1432
|
-
],
|
|
1433
|
-
"ts/no-useless-constructor": "off",
|
|
1434
|
-
"ts/no-wrapper-object-types": "error",
|
|
1435
|
-
"ts/triple-slash-reference": "off",
|
|
1436
|
-
"ts/unified-signatures": "off",
|
|
1437
|
-
...overrides
|
|
1438
|
-
}
|
|
1439
|
-
},
|
|
1440
|
-
...isTypeAware ? [
|
|
1441
|
-
{
|
|
1442
|
-
files: filesTypeAware,
|
|
1443
|
-
ignores: ignoresTypeAware,
|
|
1444
|
-
name: "coderwyd/typescript/rules-type-aware",
|
|
1445
|
-
rules: {
|
|
1446
|
-
...typeAwareRules,
|
|
1447
|
-
...overridesTypeAware
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
] : []
|
|
1451
|
-
];
|
|
1228
|
+
const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {} } = options;
|
|
1229
|
+
const files = options.files ?? [
|
|
1230
|
+
GLOB_TS,
|
|
1231
|
+
GLOB_TSX,
|
|
1232
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1233
|
+
];
|
|
1234
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1235
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
|
|
1236
|
+
const tsconfigPath = options.tsconfigPath;
|
|
1237
|
+
const isTypeAware = !!tsconfigPath;
|
|
1238
|
+
const typeAwareRules = {
|
|
1239
|
+
"dot-notation": "off",
|
|
1240
|
+
"no-implied-eval": "off",
|
|
1241
|
+
"ts/await-thenable": "error",
|
|
1242
|
+
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
1243
|
+
"ts/no-floating-promises": "error",
|
|
1244
|
+
"ts/no-for-in-array": "error",
|
|
1245
|
+
"ts/no-implied-eval": "error",
|
|
1246
|
+
"ts/no-misused-promises": "error",
|
|
1247
|
+
"ts/no-unnecessary-type-assertion": "error",
|
|
1248
|
+
"ts/no-unsafe-argument": "error",
|
|
1249
|
+
"ts/no-unsafe-assignment": "error",
|
|
1250
|
+
"ts/no-unsafe-call": "error",
|
|
1251
|
+
"ts/no-unsafe-member-access": "error",
|
|
1252
|
+
"ts/no-unsafe-return": "error",
|
|
1253
|
+
"ts/promise-function-async": "error",
|
|
1254
|
+
"ts/restrict-plus-operands": "error",
|
|
1255
|
+
"ts/restrict-template-expressions": "error",
|
|
1256
|
+
"ts/return-await": "error",
|
|
1257
|
+
"ts/strict-boolean-expressions": "error",
|
|
1258
|
+
"ts/switch-exhaustiveness-check": "error",
|
|
1259
|
+
"ts/unbound-method": "error"
|
|
1260
|
+
};
|
|
1261
|
+
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1262
|
+
function makeParser(typeAware, files$1, ignores$1) {
|
|
1263
|
+
return {
|
|
1264
|
+
files: files$1,
|
|
1265
|
+
...ignores$1 ? { ignores: ignores$1 } : {},
|
|
1266
|
+
languageOptions: {
|
|
1267
|
+
parser: parserTs,
|
|
1268
|
+
parserOptions: {
|
|
1269
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1270
|
+
sourceType: "module",
|
|
1271
|
+
...typeAware ? {
|
|
1272
|
+
projectService: {
|
|
1273
|
+
allowDefaultProject: ["./*.js"],
|
|
1274
|
+
defaultProject: tsconfigPath
|
|
1275
|
+
},
|
|
1276
|
+
tsconfigRootDir: process.cwd()
|
|
1277
|
+
} : {},
|
|
1278
|
+
...parserOptions
|
|
1279
|
+
}
|
|
1280
|
+
},
|
|
1281
|
+
name: `coderwyd/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
return [
|
|
1285
|
+
{
|
|
1286
|
+
name: "coderwyd/typescript/setup",
|
|
1287
|
+
plugins: {
|
|
1288
|
+
antfu: pluginAntfu,
|
|
1289
|
+
ts: pluginTs
|
|
1290
|
+
}
|
|
1291
|
+
},
|
|
1292
|
+
...isTypeAware ? [makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware)] : [makeParser(false, files)],
|
|
1293
|
+
{
|
|
1294
|
+
files,
|
|
1295
|
+
name: "coderwyd/typescript/rules",
|
|
1296
|
+
rules: {
|
|
1297
|
+
...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, { "@typescript-eslint": "ts" }),
|
|
1298
|
+
...renameRules(pluginTs.configs.strict.rules, { "@typescript-eslint": "ts" }),
|
|
1299
|
+
"no-dupe-class-members": "off",
|
|
1300
|
+
"no-redeclare": "off",
|
|
1301
|
+
"no-use-before-define": "off",
|
|
1302
|
+
"no-useless-constructor": "off",
|
|
1303
|
+
"ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
|
|
1304
|
+
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1305
|
+
"ts/consistent-type-imports": ["error", {
|
|
1306
|
+
disallowTypeAnnotations: false,
|
|
1307
|
+
fixStyle: "separate-type-imports",
|
|
1308
|
+
prefer: "type-imports"
|
|
1309
|
+
}],
|
|
1310
|
+
"ts/method-signature-style": ["error", "property"],
|
|
1311
|
+
"ts/no-dupe-class-members": "error",
|
|
1312
|
+
"ts/no-dynamic-delete": "off",
|
|
1313
|
+
"ts/no-empty-object-type": ["error", {
|
|
1314
|
+
allowInterfaces: "with-single-extends",
|
|
1315
|
+
allowObjectTypes: "never",
|
|
1316
|
+
allowWithName: "Props$"
|
|
1317
|
+
}],
|
|
1318
|
+
"ts/no-explicit-any": "off",
|
|
1319
|
+
"ts/no-extraneous-class": "off",
|
|
1320
|
+
"ts/no-import-type-side-effects": "error",
|
|
1321
|
+
"ts/no-invalid-void-type": "off",
|
|
1322
|
+
"ts/no-non-null-assertion": "off",
|
|
1323
|
+
"ts/no-redeclare": ["error", { builtinGlobals: false }],
|
|
1324
|
+
"ts/no-require-imports": "error",
|
|
1325
|
+
"ts/no-unused-expressions": ["error", {
|
|
1326
|
+
allowShortCircuit: true,
|
|
1327
|
+
allowTaggedTemplates: true,
|
|
1328
|
+
allowTernary: true
|
|
1329
|
+
}],
|
|
1330
|
+
"ts/no-unused-vars": "off",
|
|
1331
|
+
"ts/no-use-before-define": ["error", {
|
|
1332
|
+
classes: false,
|
|
1333
|
+
functions: false,
|
|
1334
|
+
variables: true
|
|
1335
|
+
}],
|
|
1336
|
+
"ts/no-useless-constructor": "off",
|
|
1337
|
+
"ts/no-wrapper-object-types": "error",
|
|
1338
|
+
"ts/triple-slash-reference": "off",
|
|
1339
|
+
"ts/unified-signatures": "off",
|
|
1340
|
+
...overrides
|
|
1341
|
+
}
|
|
1342
|
+
},
|
|
1343
|
+
...isTypeAware ? [{
|
|
1344
|
+
files: filesTypeAware,
|
|
1345
|
+
ignores: ignoresTypeAware,
|
|
1346
|
+
name: "coderwyd/typescript/rules-type-aware",
|
|
1347
|
+
rules: {
|
|
1348
|
+
...typeAwareRules,
|
|
1349
|
+
...overridesTypeAware
|
|
1350
|
+
}
|
|
1351
|
+
}] : []
|
|
1352
|
+
];
|
|
1452
1353
|
}
|
|
1453
1354
|
|
|
1454
|
-
|
|
1355
|
+
//#endregion
|
|
1356
|
+
//#region src/configs/unicorn.ts
|
|
1455
1357
|
function unicorn() {
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
"unicorn/prefer-number-properties": "error",
|
|
1518
|
-
"unicorn/prefer-optional-catch-binding": "error",
|
|
1519
|
-
"unicorn/prefer-prototype-methods": "error",
|
|
1520
|
-
"unicorn/prefer-query-selector": "error",
|
|
1521
|
-
"unicorn/prefer-reflect-apply": "error",
|
|
1522
|
-
// 'unicorn/prefer-regexp-test': 'error',
|
|
1523
|
-
"unicorn/prefer-string-replace-all": "error",
|
|
1524
|
-
"unicorn/prefer-string-slice": "error",
|
|
1525
|
-
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1526
|
-
"unicorn/prefer-string-trim-start-end": "error",
|
|
1527
|
-
// top level await is not supported in all environments
|
|
1528
|
-
// 'unicorn/prefer-top-level-await': 'error',
|
|
1529
|
-
"unicorn/prefer-type-error": "error",
|
|
1530
|
-
"unicorn/throw-new-error": "error"
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
];
|
|
1358
|
+
return [{
|
|
1359
|
+
name: "coderwyd/unicorn/rules",
|
|
1360
|
+
plugins: { unicorn: pluginUnicorn },
|
|
1361
|
+
rules: {
|
|
1362
|
+
"unicorn/catch-error-name": "error",
|
|
1363
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
1364
|
+
"unicorn/consistent-existence-index-check": "error",
|
|
1365
|
+
"unicorn/custom-error-definition": "error",
|
|
1366
|
+
"unicorn/error-message": "error",
|
|
1367
|
+
"unicorn/escape-case": "error",
|
|
1368
|
+
"unicorn/new-for-builtins": "error",
|
|
1369
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
1370
|
+
"unicorn/no-array-push-push": "error",
|
|
1371
|
+
"unicorn/no-await-in-promise-methods": "error",
|
|
1372
|
+
"unicorn/no-console-spaces": "error",
|
|
1373
|
+
"unicorn/no-for-loop": "error",
|
|
1374
|
+
"unicorn/no-hex-escape": "error",
|
|
1375
|
+
"unicorn/no-instanceof-builtins": "error",
|
|
1376
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
1377
|
+
"unicorn/no-length-as-slice-end": "error",
|
|
1378
|
+
"unicorn/no-lonely-if": "error",
|
|
1379
|
+
"unicorn/no-negation-in-equality-check": "error",
|
|
1380
|
+
"unicorn/no-new-array": "error",
|
|
1381
|
+
"unicorn/no-new-buffer": "error",
|
|
1382
|
+
"unicorn/no-single-promise-in-promise-methods": "error",
|
|
1383
|
+
"unicorn/no-static-only-class": "error",
|
|
1384
|
+
"unicorn/no-unnecessary-await": "error",
|
|
1385
|
+
"unicorn/no-zero-fractions": "error",
|
|
1386
|
+
"unicorn/prefer-add-event-listener": "error",
|
|
1387
|
+
"unicorn/prefer-array-find": "error",
|
|
1388
|
+
"unicorn/prefer-array-flat-map": "error",
|
|
1389
|
+
"unicorn/prefer-array-index-of": "error",
|
|
1390
|
+
"unicorn/prefer-array-some": "error",
|
|
1391
|
+
"unicorn/prefer-at": "error",
|
|
1392
|
+
"unicorn/prefer-blob-reading-methods": "error",
|
|
1393
|
+
"unicorn/prefer-date-now": "error",
|
|
1394
|
+
"unicorn/prefer-dom-node-append": "error",
|
|
1395
|
+
"unicorn/prefer-dom-node-dataset": "error",
|
|
1396
|
+
"unicorn/prefer-dom-node-remove": "error",
|
|
1397
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
1398
|
+
"unicorn/prefer-includes": "error",
|
|
1399
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
1400
|
+
"unicorn/prefer-math-min-max": "error",
|
|
1401
|
+
"unicorn/prefer-math-trunc": "error",
|
|
1402
|
+
"unicorn/prefer-modern-dom-apis": "error",
|
|
1403
|
+
"unicorn/prefer-modern-math-apis": "error",
|
|
1404
|
+
"unicorn/prefer-negative-index": "error",
|
|
1405
|
+
"unicorn/prefer-node-protocol": "error",
|
|
1406
|
+
"unicorn/prefer-number-properties": "error",
|
|
1407
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
1408
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
1409
|
+
"unicorn/prefer-query-selector": "error",
|
|
1410
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
1411
|
+
"unicorn/prefer-string-replace-all": "error",
|
|
1412
|
+
"unicorn/prefer-string-slice": "error",
|
|
1413
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1414
|
+
"unicorn/prefer-string-trim-start-end": "error",
|
|
1415
|
+
"unicorn/prefer-type-error": "error",
|
|
1416
|
+
"unicorn/throw-new-error": "error"
|
|
1417
|
+
}
|
|
1418
|
+
}];
|
|
1534
1419
|
}
|
|
1535
1420
|
|
|
1536
|
-
|
|
1421
|
+
//#endregion
|
|
1422
|
+
//#region src/configs/unocss.ts
|
|
1537
1423
|
async function unocss(options = {}) {
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
"unocss/order": "warn",
|
|
1551
|
-
...attributify ? {
|
|
1552
|
-
"unocss/order-attributify": "warn"
|
|
1553
|
-
} : {},
|
|
1554
|
-
...strict ? {
|
|
1555
|
-
"unocss/blocklist": "error"
|
|
1556
|
-
} : {}
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
];
|
|
1424
|
+
const { attributify = true, strict = false } = options;
|
|
1425
|
+
await ensurePackages(["@unocss/eslint-plugin"]);
|
|
1426
|
+
const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
|
|
1427
|
+
return [{
|
|
1428
|
+
name: "coderwyd/unocss/rules",
|
|
1429
|
+
plugins: { unocss: pluginUnoCSS },
|
|
1430
|
+
rules: {
|
|
1431
|
+
"unocss/order": "warn",
|
|
1432
|
+
...attributify ? { "unocss/order-attributify": "warn" } : {},
|
|
1433
|
+
...strict ? { "unocss/blocklist": "error" } : {}
|
|
1434
|
+
}
|
|
1435
|
+
}];
|
|
1560
1436
|
}
|
|
1561
1437
|
|
|
1562
|
-
|
|
1438
|
+
//#endregion
|
|
1439
|
+
//#region src/configs/vue.ts
|
|
1563
1440
|
async function vue(options = {}) {
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
defineSlots: "slots",
|
|
1690
|
-
useAttrs: "attrs",
|
|
1691
|
-
useSlots: "slots"
|
|
1692
|
-
}
|
|
1693
|
-
],
|
|
1694
|
-
"vue/require-prop-types": "off",
|
|
1695
|
-
// 'vue/singleline-html-element-content-newline': 'off',
|
|
1696
|
-
"vue/space-infix-ops": "error",
|
|
1697
|
-
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
1698
|
-
"vue/valid-define-options": "warn",
|
|
1699
|
-
...overrides
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
];
|
|
1441
|
+
const { files = [GLOB_VUE], overrides = {} } = options;
|
|
1442
|
+
const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
|
|
1443
|
+
const isVue3 = getVueVersion() === 3;
|
|
1444
|
+
const configKeys = isVue3 ? [
|
|
1445
|
+
"essential",
|
|
1446
|
+
"strongly-recommended",
|
|
1447
|
+
"recommended"
|
|
1448
|
+
] : [
|
|
1449
|
+
"vue2-essential",
|
|
1450
|
+
"vue2-strongly-recommended",
|
|
1451
|
+
"vue2-recommended"
|
|
1452
|
+
];
|
|
1453
|
+
const vueRules = configKeys.reduce((preRules, key) => {
|
|
1454
|
+
const config = pluginVue.configs[key];
|
|
1455
|
+
return {
|
|
1456
|
+
...preRules,
|
|
1457
|
+
...config.rules
|
|
1458
|
+
};
|
|
1459
|
+
}, {});
|
|
1460
|
+
return [{
|
|
1461
|
+
files,
|
|
1462
|
+
languageOptions: {
|
|
1463
|
+
parser: parserVue,
|
|
1464
|
+
parserOptions: {
|
|
1465
|
+
ecmaFeatures: { jsx: true },
|
|
1466
|
+
extraFileExtensions: [".vue"],
|
|
1467
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1468
|
+
sourceType: "module"
|
|
1469
|
+
}
|
|
1470
|
+
},
|
|
1471
|
+
name: "coderwyd/vue/rules",
|
|
1472
|
+
plugins: { vue: pluginVue },
|
|
1473
|
+
processor: pluginVue.processors[".vue"],
|
|
1474
|
+
rules: {
|
|
1475
|
+
...pluginVue.configs.base.rules,
|
|
1476
|
+
...vueRules,
|
|
1477
|
+
"antfu/no-top-level-await": "off",
|
|
1478
|
+
"node/prefer-global/process": "off",
|
|
1479
|
+
"ts/explicit-function-return-type": "off",
|
|
1480
|
+
"vue/block-order": ["error", { order: isVue3 ? [
|
|
1481
|
+
"script",
|
|
1482
|
+
"template",
|
|
1483
|
+
"style"
|
|
1484
|
+
] : [
|
|
1485
|
+
"template",
|
|
1486
|
+
"script",
|
|
1487
|
+
"style"
|
|
1488
|
+
] }],
|
|
1489
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
1490
|
+
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
1491
|
+
"vue/component-tags-order": "off",
|
|
1492
|
+
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
1493
|
+
"vue/define-macros-order": ["error", { order: [
|
|
1494
|
+
"defineOptions",
|
|
1495
|
+
"defineProps",
|
|
1496
|
+
"defineEmits",
|
|
1497
|
+
"defineSlots"
|
|
1498
|
+
] }],
|
|
1499
|
+
"vue/eqeqeq": ["error", "smart"],
|
|
1500
|
+
"vue/html-self-closing": ["error", {
|
|
1501
|
+
html: {
|
|
1502
|
+
component: "always",
|
|
1503
|
+
normal: "always",
|
|
1504
|
+
void: "any"
|
|
1505
|
+
},
|
|
1506
|
+
math: "always",
|
|
1507
|
+
svg: "always"
|
|
1508
|
+
}],
|
|
1509
|
+
"vue/max-attributes-per-line": "off",
|
|
1510
|
+
"vue/multi-word-component-names": "off",
|
|
1511
|
+
"vue/no-constant-condition": "warn",
|
|
1512
|
+
"vue/no-duplicate-attr-inheritance": "warn",
|
|
1513
|
+
"vue/no-empty-pattern": "error",
|
|
1514
|
+
"vue/no-extra-parens": ["error", "functions"],
|
|
1515
|
+
"vue/no-irregular-whitespace": "error",
|
|
1516
|
+
"vue/no-loss-of-precision": "error",
|
|
1517
|
+
"vue/no-required-prop-with-default": "warn",
|
|
1518
|
+
"vue/no-restricted-syntax": [
|
|
1519
|
+
"error",
|
|
1520
|
+
"DebuggerStatement",
|
|
1521
|
+
"LabeledStatement",
|
|
1522
|
+
"WithStatement"
|
|
1523
|
+
],
|
|
1524
|
+
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1525
|
+
"vue/no-setup-props-reactivity-loss": "off",
|
|
1526
|
+
"vue/no-sparse-arrays": "error",
|
|
1527
|
+
"vue/no-unsupported-features": "warn",
|
|
1528
|
+
"vue/no-unused-emit-declarations": "warn",
|
|
1529
|
+
"vue/no-unused-refs": "error",
|
|
1530
|
+
"vue/no-use-v-else-with-v-for": "error",
|
|
1531
|
+
"vue/no-useless-mustaches": "warn",
|
|
1532
|
+
"vue/no-useless-v-bind": "error",
|
|
1533
|
+
"vue/no-v-html": "off",
|
|
1534
|
+
"vue/no-v-text": "warn",
|
|
1535
|
+
"vue/object-shorthand": [
|
|
1536
|
+
"error",
|
|
1537
|
+
"always",
|
|
1538
|
+
{
|
|
1539
|
+
avoidQuotes: true,
|
|
1540
|
+
ignoreConstructors: false
|
|
1541
|
+
}
|
|
1542
|
+
],
|
|
1543
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1544
|
+
"vue/prefer-define-options": "warn",
|
|
1545
|
+
"vue/prefer-separate-static-class": "error",
|
|
1546
|
+
"vue/prefer-template": "error",
|
|
1547
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
1548
|
+
"vue/require-default-prop": "off",
|
|
1549
|
+
"vue/require-macro-variable-name": ["warn", {
|
|
1550
|
+
defineEmits: "emit",
|
|
1551
|
+
defineProps: "props",
|
|
1552
|
+
defineSlots: "slots",
|
|
1553
|
+
useAttrs: "attrs",
|
|
1554
|
+
useSlots: "slots"
|
|
1555
|
+
}],
|
|
1556
|
+
"vue/require-prop-types": "off",
|
|
1557
|
+
"vue/space-infix-ops": "error",
|
|
1558
|
+
"vue/space-unary-ops": ["error", {
|
|
1559
|
+
nonwords: false,
|
|
1560
|
+
words: true
|
|
1561
|
+
}],
|
|
1562
|
+
"vue/valid-define-options": "warn",
|
|
1563
|
+
...overrides
|
|
1564
|
+
}
|
|
1565
|
+
}];
|
|
1703
1566
|
}
|
|
1704
1567
|
|
|
1705
|
-
|
|
1568
|
+
//#endregion
|
|
1569
|
+
//#region src/configs/yaml.ts
|
|
1706
1570
|
async function yaml(options = {}) {
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
},
|
|
1764
|
-
{
|
|
1765
|
-
order: { type: "asc" },
|
|
1766
|
-
pathPattern: ".*"
|
|
1767
|
-
}
|
|
1768
|
-
]
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
];
|
|
1571
|
+
const { files = [GLOB_YAML], overrides = {} } = options;
|
|
1572
|
+
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
1573
|
+
return [
|
|
1574
|
+
{
|
|
1575
|
+
name: "coderwyd/yaml/setup",
|
|
1576
|
+
plugins: { yaml: pluginYaml }
|
|
1577
|
+
},
|
|
1578
|
+
{
|
|
1579
|
+
files,
|
|
1580
|
+
languageOptions: { parser: parserYaml },
|
|
1581
|
+
name: "coderwyd/yaml/rules",
|
|
1582
|
+
rules: {
|
|
1583
|
+
"yaml/block-mapping": "error",
|
|
1584
|
+
"yaml/block-sequence": "error",
|
|
1585
|
+
"yaml/no-empty-key": "error",
|
|
1586
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
1587
|
+
"yaml/no-irregular-whitespace": "error",
|
|
1588
|
+
"yaml/plain-scalar": "error",
|
|
1589
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
1590
|
+
...overrides
|
|
1591
|
+
}
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
files: ["pnpm-workspace.yaml"],
|
|
1595
|
+
name: "coderwyd/yaml/pnpm-workspace",
|
|
1596
|
+
rules: { "yaml/sort-keys": [
|
|
1597
|
+
"error",
|
|
1598
|
+
{
|
|
1599
|
+
order: [
|
|
1600
|
+
"packages",
|
|
1601
|
+
"overrides",
|
|
1602
|
+
"patchedDependencies",
|
|
1603
|
+
"hoistPattern",
|
|
1604
|
+
"catalog",
|
|
1605
|
+
"catalogs",
|
|
1606
|
+
"allowedDeprecatedVersions",
|
|
1607
|
+
"allowNonAppliedPatches",
|
|
1608
|
+
"configDependencies",
|
|
1609
|
+
"ignoredBuiltDependencies",
|
|
1610
|
+
"ignoredOptionalDependencies",
|
|
1611
|
+
"neverBuiltDependencies",
|
|
1612
|
+
"onlyBuiltDependencies",
|
|
1613
|
+
"onlyBuiltDependenciesFile",
|
|
1614
|
+
"packageExtensions",
|
|
1615
|
+
"peerDependencyRules",
|
|
1616
|
+
"supportedArchitectures"
|
|
1617
|
+
],
|
|
1618
|
+
pathPattern: "^$"
|
|
1619
|
+
},
|
|
1620
|
+
{
|
|
1621
|
+
order: { type: "asc" },
|
|
1622
|
+
pathPattern: ".*"
|
|
1623
|
+
}
|
|
1624
|
+
] }
|
|
1625
|
+
}
|
|
1626
|
+
];
|
|
1772
1627
|
}
|
|
1773
1628
|
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1629
|
+
//#endregion
|
|
1630
|
+
//#region src/index.ts
|
|
1631
|
+
const flatConfigProps = [
|
|
1632
|
+
"name",
|
|
1633
|
+
"languageOptions",
|
|
1634
|
+
"linterOptions",
|
|
1635
|
+
"processor",
|
|
1636
|
+
"plugins",
|
|
1637
|
+
"rules",
|
|
1638
|
+
"settings"
|
|
1783
1639
|
];
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1640
|
+
const defaultPluginRenaming = {
|
|
1641
|
+
"@eslint-react": "react",
|
|
1642
|
+
"@eslint-react/dom": "react-dom",
|
|
1643
|
+
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
1644
|
+
"@eslint-react/naming-convention": "react-naming-convention",
|
|
1645
|
+
"@typescript-eslint": "ts",
|
|
1646
|
+
"import-x": "import",
|
|
1647
|
+
n: "node",
|
|
1648
|
+
vitest: "test",
|
|
1649
|
+
yml: "yaml"
|
|
1794
1650
|
};
|
|
1651
|
+
/**
|
|
1652
|
+
* Construct an array of ESLint flat config items.
|
|
1653
|
+
*
|
|
1654
|
+
* @param {OptionsConfig & TypedFlatConfigItem} options
|
|
1655
|
+
* The options for generating the ESLint configurations.
|
|
1656
|
+
* @param {Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | Linter.Config[]>[]} userConfigs
|
|
1657
|
+
* The user configurations to be merged with the generated configurations.
|
|
1658
|
+
* @returns {Promise<TypedFlatConfigItem[]>}
|
|
1659
|
+
* The merged ESLint configurations.
|
|
1660
|
+
*/
|
|
1795
1661
|
async function defineConfig(options = {}, ...userConfigs) {
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
if (enableVue) {
|
|
1874
|
-
configs2.push(
|
|
1875
|
-
vue({
|
|
1876
|
-
...resolveSubOptions(options, "vue"),
|
|
1877
|
-
overrides: getOverrides(options, "typescript"),
|
|
1878
|
-
typescript: !!enableTypeScript
|
|
1879
|
-
})
|
|
1880
|
-
);
|
|
1881
|
-
}
|
|
1882
|
-
if (enableReact) {
|
|
1883
|
-
configs2.push(
|
|
1884
|
-
react({
|
|
1885
|
-
overrides: getOverrides(options, "react"),
|
|
1886
|
-
tsconfigPath
|
|
1887
|
-
})
|
|
1888
|
-
);
|
|
1889
|
-
}
|
|
1890
|
-
if (enableSvelte) {
|
|
1891
|
-
configs2.push(
|
|
1892
|
-
svelte({
|
|
1893
|
-
overrides: getOverrides(options, "svelte"),
|
|
1894
|
-
typescript: !!enableTypeScript
|
|
1895
|
-
})
|
|
1896
|
-
);
|
|
1897
|
-
}
|
|
1898
|
-
if (enableUnoCSS) {
|
|
1899
|
-
configs2.push(
|
|
1900
|
-
unocss({
|
|
1901
|
-
...resolveSubOptions(options, "unocss"),
|
|
1902
|
-
overrides: getOverrides(options, "unocss")
|
|
1903
|
-
})
|
|
1904
|
-
);
|
|
1905
|
-
}
|
|
1906
|
-
if (enableTailwindCSS) {
|
|
1907
|
-
configs2.push(
|
|
1908
|
-
tailwindcss({
|
|
1909
|
-
...resolveSubOptions(options, "tailwindcss"),
|
|
1910
|
-
overrides: getOverrides(options, "tailwindcss")
|
|
1911
|
-
})
|
|
1912
|
-
);
|
|
1913
|
-
}
|
|
1914
|
-
if (options.jsonc ?? true) {
|
|
1915
|
-
configs2.push(
|
|
1916
|
-
jsonc({
|
|
1917
|
-
overrides: getOverrides(options, "jsonc")
|
|
1918
|
-
}),
|
|
1919
|
-
sortPackageJson(),
|
|
1920
|
-
sortTsconfig()
|
|
1921
|
-
);
|
|
1922
|
-
}
|
|
1923
|
-
if (options.yaml ?? true) {
|
|
1924
|
-
configs2.push(
|
|
1925
|
-
yaml({
|
|
1926
|
-
overrides: getOverrides(options, "yaml")
|
|
1927
|
-
})
|
|
1928
|
-
);
|
|
1929
|
-
}
|
|
1930
|
-
configs2.push(specials(), prettier());
|
|
1931
|
-
if ("files" in options) {
|
|
1932
|
-
throw new Error(
|
|
1933
|
-
'[@coderwyd/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.'
|
|
1934
|
-
);
|
|
1935
|
-
}
|
|
1936
|
-
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1937
|
-
if (key in options) acc[key] = options[key];
|
|
1938
|
-
return acc;
|
|
1939
|
-
}, {});
|
|
1940
|
-
if (Object.keys(fusedConfig).length > 0) configs2.push([fusedConfig]);
|
|
1941
|
-
const merged = await combine(...configs2, ...userConfigs);
|
|
1942
|
-
if (autoRenamePlugins)
|
|
1943
|
-
return renamePluginInConfigs(merged, defaultPluginRenaming);
|
|
1944
|
-
return merged;
|
|
1662
|
+
const { autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, react: enableReact = false, regexp: enableRegexp = true, svelte: enableSvelte = false, tailwindcss: enableTailwindCSS = false, typescript: enableTypeScript = isUsingTypeScript, unocss: enableUnoCSS = false, vue: enableVue = isUsingVue } = options;
|
|
1663
|
+
let isInEditor$1 = options.isInEditor;
|
|
1664
|
+
if (isInEditor$1 == null) {
|
|
1665
|
+
isInEditor$1 = isInEditorEnv();
|
|
1666
|
+
if (isInEditor$1) console.log("[@coderwyd/eslint-config] Detected running in editor, some rules are disabled.");
|
|
1667
|
+
}
|
|
1668
|
+
const configs$1 = [];
|
|
1669
|
+
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
1670
|
+
...enableGitignore,
|
|
1671
|
+
name: "coderwyd/gitignore"
|
|
1672
|
+
})]));
|
|
1673
|
+
else configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
1674
|
+
name: "coderwyd/gitignore",
|
|
1675
|
+
strict: false
|
|
1676
|
+
})]));
|
|
1677
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
1678
|
+
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
1679
|
+
configs$1.push(
|
|
1680
|
+
ignores(options.ignores),
|
|
1681
|
+
javascript({
|
|
1682
|
+
isInEditor: isInEditor$1,
|
|
1683
|
+
overrides: getOverrides(options, "javascript")
|
|
1684
|
+
}),
|
|
1685
|
+
comments(),
|
|
1686
|
+
node(),
|
|
1687
|
+
jsdoc(),
|
|
1688
|
+
imports(),
|
|
1689
|
+
unicorn(),
|
|
1690
|
+
command(),
|
|
1691
|
+
deMorgan(),
|
|
1692
|
+
perfectionist()
|
|
1693
|
+
// Optional plugins (installed but not enabled by default)
|
|
1694
|
+
);
|
|
1695
|
+
if (enableVue) componentExts.push("vue");
|
|
1696
|
+
if (enableTypeScript) configs$1.push(typescript({
|
|
1697
|
+
...typescriptOptions,
|
|
1698
|
+
componentExts,
|
|
1699
|
+
overrides: getOverrides(options, "typescript")
|
|
1700
|
+
}));
|
|
1701
|
+
if (enableRegexp) configs$1.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
1702
|
+
if (options.test ?? true) configs$1.push(test({
|
|
1703
|
+
isInEditor: isInEditor$1,
|
|
1704
|
+
overrides: getOverrides(options, "test")
|
|
1705
|
+
}));
|
|
1706
|
+
if (enableVue) configs$1.push(vue({
|
|
1707
|
+
...resolveSubOptions(options, "vue"),
|
|
1708
|
+
overrides: getOverrides(options, "typescript"),
|
|
1709
|
+
typescript: !!enableTypeScript
|
|
1710
|
+
}));
|
|
1711
|
+
if (enableReact) configs$1.push(react({
|
|
1712
|
+
overrides: getOverrides(options, "react"),
|
|
1713
|
+
tsconfigPath
|
|
1714
|
+
}));
|
|
1715
|
+
if (enableSvelte) configs$1.push(svelte({
|
|
1716
|
+
overrides: getOverrides(options, "svelte"),
|
|
1717
|
+
typescript: !!enableTypeScript
|
|
1718
|
+
}));
|
|
1719
|
+
if (enableUnoCSS) configs$1.push(unocss({
|
|
1720
|
+
...resolveSubOptions(options, "unocss"),
|
|
1721
|
+
overrides: getOverrides(options, "unocss")
|
|
1722
|
+
}));
|
|
1723
|
+
if (enableTailwindCSS) configs$1.push(tailwindcss({
|
|
1724
|
+
...resolveSubOptions(options, "tailwindcss"),
|
|
1725
|
+
overrides: getOverrides(options, "tailwindcss")
|
|
1726
|
+
}));
|
|
1727
|
+
if (options.jsonc ?? true) configs$1.push(jsonc({ overrides: getOverrides(options, "jsonc") }), sortPackageJson(), sortTsconfig());
|
|
1728
|
+
if (options.yaml ?? true) configs$1.push(yaml({ overrides: getOverrides(options, "yaml") }));
|
|
1729
|
+
configs$1.push(specials(), prettier());
|
|
1730
|
+
if ("files" in options) throw new Error("[@coderwyd/eslint-config] The first argument should not contain the \"files\" property as the options are supposed to be global. Place it in the second or later config instead.");
|
|
1731
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1732
|
+
if (key in options) acc[key] = options[key];
|
|
1733
|
+
return acc;
|
|
1734
|
+
}, {});
|
|
1735
|
+
if (Object.keys(fusedConfig).length > 0) configs$1.push([fusedConfig]);
|
|
1736
|
+
const merged = await combine(...configs$1, ...userConfigs);
|
|
1737
|
+
if (autoRenamePlugins) return renamePluginInConfigs(merged, defaultPluginRenaming);
|
|
1738
|
+
return merged;
|
|
1945
1739
|
}
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
defineConfig,
|
|
1950
|
-
ensurePackages,
|
|
1951
|
-
getOverrides,
|
|
1952
|
-
getVueVersion,
|
|
1953
|
-
interopDefault,
|
|
1954
|
-
isInEditorEnv,
|
|
1955
|
-
isInGitHooksOrLintStaged,
|
|
1956
|
-
isPackageInScope,
|
|
1957
|
-
renamePluginInConfigs,
|
|
1958
|
-
renameRules,
|
|
1959
|
-
resolveSubOptions,
|
|
1960
|
-
toArray
|
|
1961
|
-
};
|
|
1740
|
+
|
|
1741
|
+
//#endregion
|
|
1742
|
+
export { combine, defaultPluginRenaming, defineConfig, ensurePackages, getOverrides, getVueVersion, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, renamePluginInConfigs, renameRules, resolveSubOptions, toArray };
|