@cuiqg/eslint-config 2.7.2 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +461 -0
- package/package.json +5 -2
- package/.editorconfig +0 -12
- package/.gitattributes +0 -1
- package/.vscode/settings.json +0 -14
- package/bump.config.js +0 -6
- package/eslint-inspector.config.js +0 -7
- package/eslint.config.js +0 -3
- package/pnpm-workspace.yaml +0 -3
- package/src/configs/compat.js +0 -17
- package/src/configs/ignores.js +0 -17
- package/src/configs/imports.js +0 -12
- package/src/configs/index.js +0 -13
- package/src/configs/javascript.js +0 -38
- package/src/configs/jsdoc.js +0 -33
- package/src/configs/macros.js +0 -12
- package/src/configs/package-json.js +0 -16
- package/src/configs/prettier.js +0 -21
- package/src/configs/promise.js +0 -12
- package/src/configs/stylistic.js +0 -24
- package/src/configs/unicorn.js +0 -17
- package/src/configs/unocss.js +0 -19
- package/src/configs/vue.js +0 -143
- package/src/env.js +0 -27
- package/src/globs.js +0 -70
- package/src/index.js +0 -8
- package/src/presets.js +0 -75
- package/src/utils.js +0 -24
- package/tsdown.config.js +0 -19
- package/vercel.json +0 -7
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { isPackageExists } from "local-pkg";
|
|
5
|
+
|
|
6
|
+
//#region src/globs.js
|
|
7
|
+
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
8
|
+
const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
|
|
9
|
+
const GLOB_TS = `**/*.?([cm])ts`;
|
|
10
|
+
const GLOB_TSX = `**/*.?([cm])tsx`;
|
|
11
|
+
const GLOB_JS = `**/*.?([cm])js`;
|
|
12
|
+
const GLOB_JSX = `**/*.?([cm])jsx`;
|
|
13
|
+
const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
14
|
+
const GLOB_CSS = "**/*.css";
|
|
15
|
+
const GLOB_SCSS = "**/*.scss";
|
|
16
|
+
const GLOB_LESS = "**/*.less";
|
|
17
|
+
const GLOB_STYLUS = "**/*.styl";
|
|
18
|
+
const GLOB_POSTCSS = "**/*.{p,post}css";
|
|
19
|
+
const GLOB_JSON = "**/*.json";
|
|
20
|
+
const GLOB_JSON5 = "**/*.json5";
|
|
21
|
+
const GLOB_JSONC = "**/*.jsonc";
|
|
22
|
+
const GLOB_MARKDOWN = "**/*.md";
|
|
23
|
+
const GLOB_VUE = "**/*.vue";
|
|
24
|
+
const GLOB_YAML = "**/*.y?(a)ml";
|
|
25
|
+
const GLOB_TOML = "**/*.toml";
|
|
26
|
+
const GLOB_XML = "**/*.xml";
|
|
27
|
+
const GLOB_SVG = "**/*.svg";
|
|
28
|
+
const GLOB_HTML = "**/*.htm?(l)";
|
|
29
|
+
const GLOB_EXCLUDE = [
|
|
30
|
+
"**/node_modules",
|
|
31
|
+
"**/dist",
|
|
32
|
+
"**/package-lock.json",
|
|
33
|
+
"**/yarn.lock",
|
|
34
|
+
"**/pnpm-lock.yaml",
|
|
35
|
+
"**/bun.lockb",
|
|
36
|
+
"**/output",
|
|
37
|
+
"**/coverage",
|
|
38
|
+
"**/temp",
|
|
39
|
+
"**/.temp",
|
|
40
|
+
"**/tmp",
|
|
41
|
+
"**/.tmp",
|
|
42
|
+
"**/.history",
|
|
43
|
+
"**/.vitepress/cache",
|
|
44
|
+
"**/.nuxt",
|
|
45
|
+
"**/.next",
|
|
46
|
+
"**/.svelte-kit",
|
|
47
|
+
"**/.vercel",
|
|
48
|
+
"**/.changeset",
|
|
49
|
+
"**/.idea",
|
|
50
|
+
"**/.DS_Store",
|
|
51
|
+
"**/Thumbs.db",
|
|
52
|
+
"**/ehthumbs.db",
|
|
53
|
+
"**/Desktop.ini",
|
|
54
|
+
"**/$RECYCLE.BIN",
|
|
55
|
+
"**/.cache",
|
|
56
|
+
"**/.output",
|
|
57
|
+
"**/.vite-inspect",
|
|
58
|
+
"**/.yarn",
|
|
59
|
+
"**/vite.config.*.timestamp-*",
|
|
60
|
+
"**/CHANGELOG*.md",
|
|
61
|
+
"**/*.min.*",
|
|
62
|
+
"**/LICENSE*",
|
|
63
|
+
"**/__snapshots__",
|
|
64
|
+
"**/auto-import?(s).d.ts",
|
|
65
|
+
"**/components.d.ts",
|
|
66
|
+
"**/typed-router.d.ts",
|
|
67
|
+
"**/.eslint-config-inspector"
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/utils.js
|
|
72
|
+
async function interopDefault(module) {
|
|
73
|
+
try {
|
|
74
|
+
let resolved = await module;
|
|
75
|
+
return resolved?.default || resolved;
|
|
76
|
+
} catch (error) {
|
|
77
|
+
throw new Error(`Cannot import module: ${String(error)}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function renameRules(rules, map) {
|
|
81
|
+
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
82
|
+
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
83
|
+
return [key, value];
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/configs/ignores.js
|
|
89
|
+
async function ignores() {
|
|
90
|
+
const configGitignore = await interopDefault(import("eslint-config-flat-gitignore"));
|
|
91
|
+
return [{
|
|
92
|
+
ignores: [...GLOB_EXCLUDE],
|
|
93
|
+
name: "cuiqg/ignores"
|
|
94
|
+
}, configGitignore({
|
|
95
|
+
name: "cuiqg/gitignore",
|
|
96
|
+
strict: false
|
|
97
|
+
})];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/configs/javascript.js
|
|
102
|
+
async function javascript() {
|
|
103
|
+
const [pluginJs] = await Promise.all([interopDefault(import("@eslint/js"))]);
|
|
104
|
+
return [{
|
|
105
|
+
languageOptions: {
|
|
106
|
+
ecmaVersion: "latest",
|
|
107
|
+
globals: {
|
|
108
|
+
...globals.browser,
|
|
109
|
+
...globals.es2025,
|
|
110
|
+
...globals.node
|
|
111
|
+
},
|
|
112
|
+
parserOptions: {
|
|
113
|
+
ecmaFeatures: { jsx: true },
|
|
114
|
+
ecmaVersion: "latest",
|
|
115
|
+
sourceType: "module"
|
|
116
|
+
},
|
|
117
|
+
sourceType: "module"
|
|
118
|
+
},
|
|
119
|
+
linterOptions: { reportUnusedDisableDirectives: true },
|
|
120
|
+
name: "cuiqg/javascript",
|
|
121
|
+
plugins: { js: pluginJs },
|
|
122
|
+
rules: { ...pluginJs.configs.recommended.rules }
|
|
123
|
+
}];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/configs/jsdoc.js
|
|
128
|
+
async function jsdoc() {
|
|
129
|
+
return [{
|
|
130
|
+
name: "cuiqg/jsdoc",
|
|
131
|
+
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
|
|
132
|
+
rules: {
|
|
133
|
+
"jsdoc/check-access": "warn",
|
|
134
|
+
"jsdoc/check-param-names": "warn",
|
|
135
|
+
"jsdoc/check-property-names": "warn",
|
|
136
|
+
"jsdoc/check-types": "warn",
|
|
137
|
+
"jsdoc/empty-tags": "warn",
|
|
138
|
+
"jsdoc/implements-on-classes": "warn",
|
|
139
|
+
"jsdoc/no-defaults": "warn",
|
|
140
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
141
|
+
"jsdoc/require-param-name": "warn",
|
|
142
|
+
"jsdoc/require-property": "warn",
|
|
143
|
+
"jsdoc/require-property-description": "warn",
|
|
144
|
+
"jsdoc/require-property-name": "warn",
|
|
145
|
+
"jsdoc/require-returns-check": "warn",
|
|
146
|
+
"jsdoc/require-returns-description": "warn",
|
|
147
|
+
"jsdoc/require-yields-check": "warn",
|
|
148
|
+
"jsdoc/check-alignment": "warn",
|
|
149
|
+
"jsdoc/multiline-blocks": "warn"
|
|
150
|
+
}
|
|
151
|
+
}];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/configs/macros.js
|
|
156
|
+
async function macros() {
|
|
157
|
+
return [{
|
|
158
|
+
...await interopDefault(import("@vue-macros/eslint-config")),
|
|
159
|
+
name: "cuiqg/macros"
|
|
160
|
+
}];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/configs/package-json.js
|
|
165
|
+
async function packageJson() {
|
|
166
|
+
const pluginPackageJson = await interopDefault(import("eslint-plugin-package-json"));
|
|
167
|
+
return [{
|
|
168
|
+
...pluginPackageJson.configs.recommended,
|
|
169
|
+
rules: {
|
|
170
|
+
...pluginPackageJson.configs.recommended.rules,
|
|
171
|
+
...pluginPackageJson.configs.stylistic.rules
|
|
172
|
+
},
|
|
173
|
+
name: "cuiqg/package-json"
|
|
174
|
+
}];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/configs/prettier.js
|
|
179
|
+
async function prettier() {
|
|
180
|
+
const [pluginPrettier, recommendedPrettier] = await Promise.all([interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-plugin-prettier/recommended"))]);
|
|
181
|
+
return [{
|
|
182
|
+
name: "cuiqg/prettier",
|
|
183
|
+
plugins: { prettier: pluginPrettier },
|
|
184
|
+
rules: {
|
|
185
|
+
...recommendedPrettier.rules,
|
|
186
|
+
"prettier/prettier": "warn"
|
|
187
|
+
}
|
|
188
|
+
}];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/configs/stylistic.js
|
|
193
|
+
async function stylistic() {
|
|
194
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
195
|
+
const config = pluginStylistic.configs.customize({
|
|
196
|
+
commaDangle: "never",
|
|
197
|
+
indent: 2,
|
|
198
|
+
pluginName: "style",
|
|
199
|
+
quotes: "single",
|
|
200
|
+
semi: false
|
|
201
|
+
});
|
|
202
|
+
return [{
|
|
203
|
+
name: "cuiqg/stylistic",
|
|
204
|
+
plugins: { style: pluginStylistic },
|
|
205
|
+
rules: { ...config.rules }
|
|
206
|
+
}];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/configs/unocss.js
|
|
211
|
+
async function unocss() {
|
|
212
|
+
const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
|
|
213
|
+
return [{
|
|
214
|
+
name: "cuiqg/unocss",
|
|
215
|
+
plugins: { unocss: pluginUnoCSS },
|
|
216
|
+
rules: { ...renameRules(pluginUnoCSS.configs.recommended.rules, { "@unocss": "unocss" }) }
|
|
217
|
+
}];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/configs/vue.js
|
|
222
|
+
async function vue() {
|
|
223
|
+
const files = [GLOB_VUE];
|
|
224
|
+
const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
|
|
225
|
+
return [{
|
|
226
|
+
files,
|
|
227
|
+
languageOptions: {
|
|
228
|
+
globals: {
|
|
229
|
+
computed: "readonly",
|
|
230
|
+
defineEmits: "readonly",
|
|
231
|
+
defineExpose: "readonly",
|
|
232
|
+
defineModel: "readonly",
|
|
233
|
+
defineOptions: "readonly",
|
|
234
|
+
defineProps: "readonly",
|
|
235
|
+
defineSlots: "readonly",
|
|
236
|
+
onActivated: "readonly",
|
|
237
|
+
onDeactivated: "readonly",
|
|
238
|
+
onMounted: "readonly",
|
|
239
|
+
onUnmounted: "readonly",
|
|
240
|
+
reactive: "readonly",
|
|
241
|
+
ref: "readonly",
|
|
242
|
+
toRef: "readonly",
|
|
243
|
+
toRefs: "readonly",
|
|
244
|
+
useAttrs: "readonly",
|
|
245
|
+
useSlots: "readonly",
|
|
246
|
+
watch: "readonly",
|
|
247
|
+
watchEffect: "readonly"
|
|
248
|
+
},
|
|
249
|
+
parser: parserVue,
|
|
250
|
+
parserOptions: {
|
|
251
|
+
ecmaFeatures: { jsx: true },
|
|
252
|
+
extraFileExtensions: [".vue"],
|
|
253
|
+
parser: null,
|
|
254
|
+
sourceType: "module"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
name: "cuiqg/vue",
|
|
258
|
+
plugins: { vue: pluginVue },
|
|
259
|
+
processor: pluginVue.processors[".vue"],
|
|
260
|
+
rules: {
|
|
261
|
+
...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
262
|
+
...acc,
|
|
263
|
+
...c
|
|
264
|
+
}), {}),
|
|
265
|
+
"node/prefer-global/process": "off",
|
|
266
|
+
"vue/array-bracket-spacing": ["error", "never"],
|
|
267
|
+
"vue/arrow-spacing": ["error", {
|
|
268
|
+
after: true,
|
|
269
|
+
before: true
|
|
270
|
+
}],
|
|
271
|
+
"vue/block-order": ["error", { order: [
|
|
272
|
+
"script",
|
|
273
|
+
"template",
|
|
274
|
+
"style"
|
|
275
|
+
] }],
|
|
276
|
+
"vue/block-spacing": ["error", "always"],
|
|
277
|
+
"vue/block-tag-newline": ["error", {
|
|
278
|
+
multiline: "always",
|
|
279
|
+
singleline: "always"
|
|
280
|
+
}],
|
|
281
|
+
"vue/brace-style": [
|
|
282
|
+
"error",
|
|
283
|
+
"stroustrup",
|
|
284
|
+
{ allowSingleLine: true }
|
|
285
|
+
],
|
|
286
|
+
"vue/comma-dangle": ["error", "always-multiline"],
|
|
287
|
+
"vue/comma-spacing": ["error", {
|
|
288
|
+
after: true,
|
|
289
|
+
before: false
|
|
290
|
+
}],
|
|
291
|
+
"vue/comma-style": ["error", "last"],
|
|
292
|
+
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
293
|
+
"vue/define-macros-order": ["error", { order: [
|
|
294
|
+
"defineOptions",
|
|
295
|
+
"defineProps",
|
|
296
|
+
"defineEmits",
|
|
297
|
+
"defineSlots"
|
|
298
|
+
] }],
|
|
299
|
+
"vue/dot-location": ["error", "property"],
|
|
300
|
+
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
301
|
+
"vue/eqeqeq": ["error", "smart"],
|
|
302
|
+
"vue/html-comment-content-spacing": [
|
|
303
|
+
"error",
|
|
304
|
+
"always",
|
|
305
|
+
{ exceptions: ["-"] }
|
|
306
|
+
],
|
|
307
|
+
"vue/html-indent": ["error", 2],
|
|
308
|
+
"vue/html-quotes": ["error", "double"],
|
|
309
|
+
"vue/key-spacing": ["error", {
|
|
310
|
+
afterColon: true,
|
|
311
|
+
beforeColon: false
|
|
312
|
+
}],
|
|
313
|
+
"vue/keyword-spacing": ["error", {
|
|
314
|
+
after: true,
|
|
315
|
+
before: true
|
|
316
|
+
}],
|
|
317
|
+
"vue/max-attributes-per-line": "off",
|
|
318
|
+
"vue/multi-word-component-names": "off",
|
|
319
|
+
"vue/no-dupe-keys": "off",
|
|
320
|
+
"vue/no-empty-pattern": "error",
|
|
321
|
+
"vue/no-irregular-whitespace": "error",
|
|
322
|
+
"vue/no-loss-of-precision": "error",
|
|
323
|
+
"vue/no-restricted-syntax": [
|
|
324
|
+
"error",
|
|
325
|
+
"DebuggerStatement",
|
|
326
|
+
"LabeledStatement",
|
|
327
|
+
"WithStatement"
|
|
328
|
+
],
|
|
329
|
+
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
330
|
+
"vue/no-setup-props-reactivity-loss": "off",
|
|
331
|
+
"vue/no-sparse-arrays": "error",
|
|
332
|
+
"vue/no-unused-refs": "error",
|
|
333
|
+
"vue/no-useless-v-bind": "error",
|
|
334
|
+
"vue/no-v-html": "off",
|
|
335
|
+
"vue/object-curly-newline": "off",
|
|
336
|
+
"vue/object-curly-spacing": ["error", "always"],
|
|
337
|
+
"vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
338
|
+
"vue/object-shorthand": [
|
|
339
|
+
"error",
|
|
340
|
+
"always",
|
|
341
|
+
{
|
|
342
|
+
avoidQuotes: true,
|
|
343
|
+
ignoreConstructors: false
|
|
344
|
+
}
|
|
345
|
+
],
|
|
346
|
+
"vue/operator-linebreak": ["error", "before"],
|
|
347
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
348
|
+
"vue/prefer-separate-static-class": "error",
|
|
349
|
+
"vue/prefer-template": "error",
|
|
350
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
351
|
+
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
352
|
+
"vue/require-default-prop": "off",
|
|
353
|
+
"vue/require-prop-types": "off",
|
|
354
|
+
"vue/space-in-parens": ["error", "never"],
|
|
355
|
+
"vue/space-infix-ops": "error",
|
|
356
|
+
"vue/space-unary-ops": ["error", {
|
|
357
|
+
nonwords: false,
|
|
358
|
+
words: true
|
|
359
|
+
}],
|
|
360
|
+
"vue/template-curly-spacing": "error"
|
|
361
|
+
}
|
|
362
|
+
}];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/configs/compat.js
|
|
367
|
+
async function compat() {
|
|
368
|
+
const pluginCompat = await interopDefault(import("eslint-plugin-compat"));
|
|
369
|
+
return [{
|
|
370
|
+
name: "cuiqg/compat",
|
|
371
|
+
plugins: { compat: pluginCompat },
|
|
372
|
+
rules: { ...pluginCompat.configs.recommended.rules }
|
|
373
|
+
}];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/configs/unicorn.js
|
|
378
|
+
async function unicorn() {
|
|
379
|
+
const pluginUnicorn = await interopDefault(import("eslint-plugin-unicorn"));
|
|
380
|
+
return [{
|
|
381
|
+
name: "cuiqg/unicorn",
|
|
382
|
+
plugins: { unicorn: pluginUnicorn },
|
|
383
|
+
rules: { ...pluginUnicorn.configs?.recommended?.rules }
|
|
384
|
+
}];
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/configs/promise.js
|
|
389
|
+
async function promise() {
|
|
390
|
+
return [{
|
|
391
|
+
...(await interopDefault(import("eslint-plugin-promise"))).configs["flat/recommended"],
|
|
392
|
+
name: "cuiqg/promise"
|
|
393
|
+
}];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/configs/imports.js
|
|
398
|
+
async function imports() {
|
|
399
|
+
return [{
|
|
400
|
+
name: "cuiqg/imports",
|
|
401
|
+
plugins: { import: await interopDefault(import("eslint-plugin-import-lite")) },
|
|
402
|
+
rules: {
|
|
403
|
+
"import/consistent-type-specifier-style": ["error", "top-level"],
|
|
404
|
+
"import/first": "error",
|
|
405
|
+
"import/no-duplicates": "error",
|
|
406
|
+
"import/no-mutable-exports": "error",
|
|
407
|
+
"import/no-named-default": "error",
|
|
408
|
+
"import/newline-after-import": ["error", { count: 1 }]
|
|
409
|
+
}
|
|
410
|
+
}];
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/env.js
|
|
415
|
+
const isInGitHookOrLintStaged = () => {
|
|
416
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
417
|
+
};
|
|
418
|
+
const isInEditor = () => {
|
|
419
|
+
if (process.env.CI) return false;
|
|
420
|
+
if (isInGitHookOrLintStaged()) return false;
|
|
421
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
422
|
+
};
|
|
423
|
+
const hasVue = () => [
|
|
424
|
+
"vue",
|
|
425
|
+
"nuxt",
|
|
426
|
+
"vitepress",
|
|
427
|
+
"@slidev/cli"
|
|
428
|
+
].some((i) => isPackageExists(i));
|
|
429
|
+
const hasTypeScript = () => isPackageExists("typescript");
|
|
430
|
+
const hasUnoCss = () => isPackageExists("unocss");
|
|
431
|
+
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/presets.js
|
|
434
|
+
const defaultPluginRenaming = {
|
|
435
|
+
"@stylistic": "style",
|
|
436
|
+
"@typescript-eslint": "ts"
|
|
437
|
+
};
|
|
438
|
+
/**
|
|
439
|
+
*
|
|
440
|
+
* @param {object} options - 设置选项
|
|
441
|
+
* @param {...any} userConfigs - 用户配置
|
|
442
|
+
* @returns {Promise<any[]>} 合并后的配置
|
|
443
|
+
*/
|
|
444
|
+
function cuiqg(options = {}, ...userConfigs) {
|
|
445
|
+
const { prettier: enablePrettier = false, unocss: enableUnocss = hasUnoCss(), vue: enableVue = hasVue() } = options;
|
|
446
|
+
const configs = [];
|
|
447
|
+
configs.push(compat(), ignores(), javascript(), imports(), jsdoc(), stylistic(), packageJson(), unicorn(), promise());
|
|
448
|
+
if (enableVue) configs.push(vue(), macros());
|
|
449
|
+
if (enableUnocss) configs.push(unocss());
|
|
450
|
+
if (enablePrettier) configs.push(prettier());
|
|
451
|
+
let composer = new FlatConfigComposer();
|
|
452
|
+
composer = composer.append(...configs, ...userConfigs).renamePlugins(defaultPluginRenaming);
|
|
453
|
+
return composer;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/index.js
|
|
458
|
+
var src_default = cuiqg;
|
|
459
|
+
|
|
460
|
+
//#endregion
|
|
461
|
+
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, compat, cuiqg, src_default as default, defaultPluginRenaming, hasTypeScript, hasUnoCss, hasVue, ignores, imports, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, prettier, promise, stylistic, unicorn, unocss, vue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuiqg/eslint-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Eslint config for @cuiqg",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint-config"
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
".": "./dist/index.mjs",
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"@cuiqg/prettier-config": "latest",
|
|
25
28
|
"@eslint/config-inspector": "^1.4.2",
|
|
@@ -40,7 +43,7 @@
|
|
|
40
43
|
"eslint-config-prettier": "^10.1.8",
|
|
41
44
|
"eslint-flat-config-utils": "^2.1.4",
|
|
42
45
|
"eslint-plugin-compat": "^6.0.2",
|
|
43
|
-
"eslint-plugin-import": "^
|
|
46
|
+
"eslint-plugin-import-lite": "^0.3.0",
|
|
44
47
|
"eslint-plugin-jsdoc": "^61.4.1",
|
|
45
48
|
"eslint-plugin-package-json": "^0.85.0",
|
|
46
49
|
"eslint-plugin-perfectionist": "^4.15.1",
|
package/.editorconfig
DELETED
package/.gitattributes
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* text=auto eol=lf
|
package/.vscode/settings.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"editor.formatOnSave": false,
|
|
3
|
-
"editor.codeActionsOnSave": {
|
|
4
|
-
"source.fixAll.eslint": "explicit",
|
|
5
|
-
"source.organizeImports": "never"
|
|
6
|
-
},
|
|
7
|
-
"eslint.runtime": "node",
|
|
8
|
-
"eslint.validate": [
|
|
9
|
-
"javascript",
|
|
10
|
-
"vue",
|
|
11
|
-
"html",
|
|
12
|
-
"jsonc"
|
|
13
|
-
]
|
|
14
|
-
}
|
package/bump.config.js
DELETED
package/eslint.config.js
DELETED
package/pnpm-workspace.yaml
DELETED
package/src/configs/compat.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { interopDefault } from '../utils'
|
|
2
|
-
|
|
3
|
-
export async function compat() {
|
|
4
|
-
const pluginCompat = await interopDefault(import('eslint-plugin-compat'))
|
|
5
|
-
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
name: 'cuiqg/compat',
|
|
9
|
-
plugins: {
|
|
10
|
-
compat: pluginCompat
|
|
11
|
-
},
|
|
12
|
-
rules: {
|
|
13
|
-
...pluginCompat.configs.recommended.rules
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
}
|
package/src/configs/ignores.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { GLOB_EXCLUDE } from '../globs'
|
|
2
|
-
import { interopDefault } from '../utils'
|
|
3
|
-
|
|
4
|
-
export async function ignores() {
|
|
5
|
-
const configGitignore = await interopDefault(import('eslint-config-flat-gitignore'))
|
|
6
|
-
|
|
7
|
-
return [
|
|
8
|
-
{
|
|
9
|
-
ignores: [...GLOB_EXCLUDE],
|
|
10
|
-
name: 'cuiqg/ignores'
|
|
11
|
-
},
|
|
12
|
-
configGitignore({
|
|
13
|
-
name: 'cuiqg/gitignore',
|
|
14
|
-
strict: false
|
|
15
|
-
})
|
|
16
|
-
]
|
|
17
|
-
}
|
package/src/configs/imports.js
DELETED
package/src/configs/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from './ignores'
|
|
2
|
-
export * from './javascript'
|
|
3
|
-
export * from './jsdoc'
|
|
4
|
-
export * from './macros'
|
|
5
|
-
export * from './package-json'
|
|
6
|
-
export * from './prettier'
|
|
7
|
-
export * from './stylistic'
|
|
8
|
-
export * from './unocss'
|
|
9
|
-
export * from './vue'
|
|
10
|
-
export * from './compat'
|
|
11
|
-
export * from './unicorn'
|
|
12
|
-
export * from './promise'
|
|
13
|
-
export * from './imports'
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import globals from 'globals'
|
|
2
|
-
import { interopDefault } from '../utils'
|
|
3
|
-
export async function javascript() {
|
|
4
|
-
const [pluginJs] = await Promise.all([
|
|
5
|
-
interopDefault(import('@eslint/js'))
|
|
6
|
-
])
|
|
7
|
-
|
|
8
|
-
return [
|
|
9
|
-
{
|
|
10
|
-
languageOptions: {
|
|
11
|
-
ecmaVersion: 'latest',
|
|
12
|
-
globals: {
|
|
13
|
-
...globals.browser,
|
|
14
|
-
...globals.es2025,
|
|
15
|
-
...globals.node
|
|
16
|
-
},
|
|
17
|
-
parserOptions: {
|
|
18
|
-
ecmaFeatures: {
|
|
19
|
-
jsx: true
|
|
20
|
-
},
|
|
21
|
-
ecmaVersion: 'latest',
|
|
22
|
-
sourceType: 'module'
|
|
23
|
-
},
|
|
24
|
-
sourceType: 'module'
|
|
25
|
-
},
|
|
26
|
-
linterOptions: {
|
|
27
|
-
reportUnusedDisableDirectives: true
|
|
28
|
-
},
|
|
29
|
-
name: 'cuiqg/javascript',
|
|
30
|
-
plugins: {
|
|
31
|
-
js: pluginJs
|
|
32
|
-
},
|
|
33
|
-
rules: {
|
|
34
|
-
...pluginJs.configs.recommended.rules
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|
package/src/configs/jsdoc.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { interopDefault } from '../utils'
|
|
2
|
-
|
|
3
|
-
export async function jsdoc() {
|
|
4
|
-
const pluginJsdoc = await interopDefault(import('eslint-plugin-jsdoc'))
|
|
5
|
-
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
name: 'cuiqg/jsdoc',
|
|
9
|
-
plugins: {
|
|
10
|
-
jsdoc: pluginJsdoc
|
|
11
|
-
},
|
|
12
|
-
rules: {
|
|
13
|
-
'jsdoc/check-access': 'warn',
|
|
14
|
-
'jsdoc/check-param-names': 'warn',
|
|
15
|
-
'jsdoc/check-property-names': 'warn',
|
|
16
|
-
'jsdoc/check-types': 'warn',
|
|
17
|
-
'jsdoc/empty-tags': 'warn',
|
|
18
|
-
'jsdoc/implements-on-classes': 'warn',
|
|
19
|
-
'jsdoc/no-defaults': 'warn',
|
|
20
|
-
'jsdoc/no-multi-asterisks': 'warn',
|
|
21
|
-
'jsdoc/require-param-name': 'warn',
|
|
22
|
-
'jsdoc/require-property': 'warn',
|
|
23
|
-
'jsdoc/require-property-description': 'warn',
|
|
24
|
-
'jsdoc/require-property-name': 'warn',
|
|
25
|
-
'jsdoc/require-returns-check': 'warn',
|
|
26
|
-
'jsdoc/require-returns-description': 'warn',
|
|
27
|
-
'jsdoc/require-yields-check': 'warn',
|
|
28
|
-
'jsdoc/check-alignment': 'warn',
|
|
29
|
-
'jsdoc/multiline-blocks': 'warn'
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
}
|
package/src/configs/macros.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { interopDefault } from '../utils'
|
|
2
|
-
|
|
3
|
-
export async function packageJson() {
|
|
4
|
-
const pluginPackageJson = await interopDefault(import('eslint-plugin-package-json'))
|
|
5
|
-
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
...pluginPackageJson.configs.recommended,
|
|
9
|
-
rules: {
|
|
10
|
-
...pluginPackageJson.configs.recommended.rules,
|
|
11
|
-
...pluginPackageJson.configs.stylistic.rules
|
|
12
|
-
},
|
|
13
|
-
name: 'cuiqg/package-json'
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
package/src/configs/prettier.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { interopDefault } from '../utils'
|
|
2
|
-
|
|
3
|
-
export async function prettier() {
|
|
4
|
-
const [pluginPrettier, recommendedPrettier] = await Promise.all([
|
|
5
|
-
interopDefault(import('eslint-plugin-prettier')),
|
|
6
|
-
interopDefault(import('eslint-plugin-prettier/recommended'))
|
|
7
|
-
])
|
|
8
|
-
|
|
9
|
-
return [
|
|
10
|
-
{
|
|
11
|
-
name: 'cuiqg/prettier',
|
|
12
|
-
plugins: {
|
|
13
|
-
prettier: pluginPrettier
|
|
14
|
-
},
|
|
15
|
-
rules: {
|
|
16
|
-
...recommendedPrettier.rules,
|
|
17
|
-
'prettier/prettier': 'warn'
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
package/src/configs/promise.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { interopDefault } from '../utils'
|
|
2
|
-
|
|
3
|
-
export async function promise() {
|
|
4
|
-
const pluginPromise = await interopDefault(import('eslint-plugin-promise'))
|
|
5
|
-
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
...pluginPromise.configs['flat/recommended'],
|
|
9
|
-
name: 'cuiqg/promise'
|
|
10
|
-
}
|
|
11
|
-
]
|
|
12
|
-
}
|
package/src/configs/stylistic.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { interopDefault } from '../utils'
|
|
2
|
-
|
|
3
|
-
export async function stylistic() {
|
|
4
|
-
const pluginStylistic = await interopDefault(import('@stylistic/eslint-plugin'))
|
|
5
|
-
|
|
6
|
-
const config = pluginStylistic.configs.customize({
|
|
7
|
-
commaDangle: 'never',
|
|
8
|
-
indent: 2,
|
|
9
|
-
pluginName: 'style',
|
|
10
|
-
quotes: 'single',
|
|
11
|
-
semi: false
|
|
12
|
-
})
|
|
13
|
-
return [
|
|
14
|
-
{
|
|
15
|
-
name: 'cuiqg/stylistic',
|
|
16
|
-
plugins: {
|
|
17
|
-
style: pluginStylistic
|
|
18
|
-
},
|
|
19
|
-
rules: {
|
|
20
|
-
...config.rules
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}
|
package/src/configs/unicorn.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { interopDefault } from '../utils'
|
|
2
|
-
|
|
3
|
-
export async function unicorn() {
|
|
4
|
-
const pluginUnicorn = await interopDefault(import('eslint-plugin-unicorn'))
|
|
5
|
-
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
name: 'cuiqg/unicorn',
|
|
9
|
-
plugins: {
|
|
10
|
-
unicorn: pluginUnicorn
|
|
11
|
-
},
|
|
12
|
-
rules: {
|
|
13
|
-
...pluginUnicorn.configs?.recommended?.rules
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
}
|
package/src/configs/unocss.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { interopDefault, renameRules } from '../utils'
|
|
2
|
-
|
|
3
|
-
export async function unocss() {
|
|
4
|
-
const pluginUnoCSS = await interopDefault(import('@unocss/eslint-plugin'))
|
|
5
|
-
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
name: 'cuiqg/unocss',
|
|
9
|
-
plugins: {
|
|
10
|
-
unocss: pluginUnoCSS
|
|
11
|
-
},
|
|
12
|
-
rules: {
|
|
13
|
-
...renameRules(pluginUnoCSS.configs.recommended.rules, {
|
|
14
|
-
'@unocss': 'unocss'
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
package/src/configs/vue.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { GLOB_VUE } from '../globs'
|
|
2
|
-
import { interopDefault } from '../utils'
|
|
3
|
-
|
|
4
|
-
export async function vue() {
|
|
5
|
-
const files = [GLOB_VUE]
|
|
6
|
-
|
|
7
|
-
const [pluginVue, parserVue] = await Promise.all([
|
|
8
|
-
interopDefault(import('eslint-plugin-vue')),
|
|
9
|
-
interopDefault(import('vue-eslint-parser'))
|
|
10
|
-
])
|
|
11
|
-
|
|
12
|
-
return [
|
|
13
|
-
{
|
|
14
|
-
files,
|
|
15
|
-
languageOptions: {
|
|
16
|
-
globals: {
|
|
17
|
-
computed: 'readonly',
|
|
18
|
-
defineEmits: 'readonly',
|
|
19
|
-
defineExpose: 'readonly',
|
|
20
|
-
defineModel: 'readonly',
|
|
21
|
-
defineOptions: 'readonly',
|
|
22
|
-
defineProps: 'readonly',
|
|
23
|
-
defineSlots: 'readonly',
|
|
24
|
-
onActivated: 'readonly',
|
|
25
|
-
onDeactivated: 'readonly',
|
|
26
|
-
onMounted: 'readonly',
|
|
27
|
-
onUnmounted: 'readonly',
|
|
28
|
-
reactive: 'readonly',
|
|
29
|
-
ref: 'readonly',
|
|
30
|
-
toRef: 'readonly',
|
|
31
|
-
toRefs: 'readonly',
|
|
32
|
-
useAttrs: 'readonly',
|
|
33
|
-
useSlots: 'readonly',
|
|
34
|
-
watch: 'readonly',
|
|
35
|
-
watchEffect: 'readonly'
|
|
36
|
-
},
|
|
37
|
-
parser: parserVue,
|
|
38
|
-
parserOptions: {
|
|
39
|
-
ecmaFeatures: {
|
|
40
|
-
jsx: true
|
|
41
|
-
},
|
|
42
|
-
extraFileExtensions: ['.vue'],
|
|
43
|
-
parser: null,
|
|
44
|
-
sourceType: 'module'
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
name: 'cuiqg/vue',
|
|
48
|
-
plugins: {
|
|
49
|
-
vue: pluginVue
|
|
50
|
-
},
|
|
51
|
-
processor: pluginVue.processors['.vue'],
|
|
52
|
-
rules: {
|
|
53
|
-
...(pluginVue.configs['flat/recommended']
|
|
54
|
-
.map(c => c.rules)
|
|
55
|
-
.reduce((acc, c) => ({ ...acc, ...c }), {})),
|
|
56
|
-
|
|
57
|
-
'node/prefer-global/process': 'off',
|
|
58
|
-
'vue/array-bracket-spacing': ['error', 'never'],
|
|
59
|
-
'vue/arrow-spacing': ['error', { after: true, before: true }],
|
|
60
|
-
'vue/block-order': [
|
|
61
|
-
'error',
|
|
62
|
-
{
|
|
63
|
-
order: ['script', 'template', 'style']
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
'vue/block-spacing': ['error', 'always'],
|
|
67
|
-
'vue/block-tag-newline': [
|
|
68
|
-
'error',
|
|
69
|
-
{
|
|
70
|
-
multiline: 'always',
|
|
71
|
-
singleline: 'always'
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
'vue/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
|
75
|
-
'vue/comma-dangle': ['error', 'always-multiline'],
|
|
76
|
-
'vue/comma-spacing': ['error', { after: true, before: false }],
|
|
77
|
-
'vue/comma-style': ['error', 'last'],
|
|
78
|
-
'vue/custom-event-name-casing': ['error', 'camelCase'],
|
|
79
|
-
'vue/define-macros-order': [
|
|
80
|
-
'error',
|
|
81
|
-
{
|
|
82
|
-
order: ['defineOptions', 'defineProps', 'defineEmits', 'defineSlots']
|
|
83
|
-
}
|
|
84
|
-
],
|
|
85
|
-
'vue/dot-location': ['error', 'property'],
|
|
86
|
-
'vue/dot-notation': ['error', { allowKeywords: true }],
|
|
87
|
-
'vue/eqeqeq': ['error', 'smart'],
|
|
88
|
-
'vue/html-comment-content-spacing': [
|
|
89
|
-
'error',
|
|
90
|
-
'always',
|
|
91
|
-
{
|
|
92
|
-
exceptions: ['-']
|
|
93
|
-
}
|
|
94
|
-
],
|
|
95
|
-
'vue/html-indent': ['error', 2],
|
|
96
|
-
'vue/html-quotes': ['error', 'double'],
|
|
97
|
-
'vue/key-spacing': ['error', { afterColon: true, beforeColon: false }],
|
|
98
|
-
'vue/keyword-spacing': ['error', { after: true, before: true }],
|
|
99
|
-
'vue/max-attributes-per-line': 'off',
|
|
100
|
-
'vue/multi-word-component-names': 'off',
|
|
101
|
-
'vue/no-dupe-keys': 'off',
|
|
102
|
-
'vue/no-empty-pattern': 'error',
|
|
103
|
-
'vue/no-irregular-whitespace': 'error',
|
|
104
|
-
'vue/no-loss-of-precision': 'error',
|
|
105
|
-
'vue/no-restricted-syntax': [
|
|
106
|
-
'error',
|
|
107
|
-
'DebuggerStatement',
|
|
108
|
-
'LabeledStatement',
|
|
109
|
-
'WithStatement'
|
|
110
|
-
],
|
|
111
|
-
'vue/no-restricted-v-bind': ['error', '/^v-/'],
|
|
112
|
-
'vue/no-setup-props-reactivity-loss': 'off',
|
|
113
|
-
'vue/no-sparse-arrays': 'error',
|
|
114
|
-
'vue/no-unused-refs': 'error',
|
|
115
|
-
'vue/no-useless-v-bind': 'error',
|
|
116
|
-
'vue/no-v-html': 'off',
|
|
117
|
-
'vue/object-curly-newline': 'off',
|
|
118
|
-
'vue/object-curly-spacing': ['error', 'always'],
|
|
119
|
-
'vue/object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
|
|
120
|
-
'vue/object-shorthand': [
|
|
121
|
-
'error',
|
|
122
|
-
'always',
|
|
123
|
-
{
|
|
124
|
-
avoidQuotes: true,
|
|
125
|
-
ignoreConstructors: false
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
'vue/operator-linebreak': ['error', 'before'],
|
|
129
|
-
'vue/padding-line-between-blocks': ['error', 'always'],
|
|
130
|
-
'vue/prefer-separate-static-class': 'error',
|
|
131
|
-
'vue/prefer-template': 'error',
|
|
132
|
-
'vue/prop-name-casing': ['error', 'camelCase'],
|
|
133
|
-
'vue/quote-props': ['error', 'consistent-as-needed'],
|
|
134
|
-
'vue/require-default-prop': 'off',
|
|
135
|
-
'vue/require-prop-types': 'off',
|
|
136
|
-
'vue/space-in-parens': ['error', 'never'],
|
|
137
|
-
'vue/space-infix-ops': 'error',
|
|
138
|
-
'vue/space-unary-ops': ['error', { nonwords: false, words: true }],
|
|
139
|
-
'vue/template-curly-spacing': 'error'
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
]
|
|
143
|
-
}
|
package/src/env.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import process from 'node:process'
|
|
2
|
-
import { isPackageExists } from 'local-pkg'
|
|
3
|
-
|
|
4
|
-
export const isInGitHookOrLintStaged = () => {
|
|
5
|
-
return !!(
|
|
6
|
-
process.env.GIT_PARAMS
|
|
7
|
-
|| process.env.VSCODE_GIT_COMMAND
|
|
8
|
-
|| process.env.npm_lifecycle_script?.startsWith('lint-staged')
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const isInEditor = () => {
|
|
13
|
-
if (process.env.CI) return false
|
|
14
|
-
if (isInGitHookOrLintStaged()) return false
|
|
15
|
-
return !!(
|
|
16
|
-
process.env.VSCODE_PID
|
|
17
|
-
|| process.env.VSCODE_CWD
|
|
18
|
-
|| process.env.JETBRAINS_IDE
|
|
19
|
-
|| process.env.VIM
|
|
20
|
-
|| process.env.NVIM
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const hasVue = () =>
|
|
25
|
-
['vue', 'nuxt', 'vitepress', '@slidev/cli'].some(i => isPackageExists(i))
|
|
26
|
-
export const hasTypeScript = () => isPackageExists('typescript')
|
|
27
|
-
export const hasUnoCss = () => isPackageExists('unocss')
|
package/src/globs.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
export const GLOB_SRC_EXT = '?([cm])[jt]s?(x)'
|
|
2
|
-
export const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`
|
|
3
|
-
|
|
4
|
-
export const GLOB_TS = `**/*.?([cm])ts`
|
|
5
|
-
export const GLOB_TSX = `**/*.?([cm])tsx`
|
|
6
|
-
|
|
7
|
-
export const GLOB_JS = `**/*.?([cm])js`
|
|
8
|
-
export const GLOB_JSX = `**/*.?([cm])jsx`
|
|
9
|
-
|
|
10
|
-
export const GLOB_STYLE = '**/*.{c,le,sc}ss'
|
|
11
|
-
export const GLOB_CSS = '**/*.css'
|
|
12
|
-
export const GLOB_SCSS = '**/*.scss'
|
|
13
|
-
export const GLOB_LESS = '**/*.less'
|
|
14
|
-
export const GLOB_STYLUS = '**/*.styl'
|
|
15
|
-
export const GLOB_POSTCSS = '**/*.{p,post}css'
|
|
16
|
-
|
|
17
|
-
export const GLOB_JSON = '**/*.json'
|
|
18
|
-
export const GLOB_JSON5 = '**/*.json5'
|
|
19
|
-
export const GLOB_JSONC = '**/*.jsonc'
|
|
20
|
-
|
|
21
|
-
export const GLOB_MARKDOWN = '**/*.md'
|
|
22
|
-
export const GLOB_VUE = '**/*.vue'
|
|
23
|
-
export const GLOB_YAML = '**/*.y?(a)ml'
|
|
24
|
-
export const GLOB_TOML = '**/*.toml'
|
|
25
|
-
export const GLOB_XML = '**/*.xml'
|
|
26
|
-
export const GLOB_SVG = '**/*.svg'
|
|
27
|
-
export const GLOB_HTML = '**/*.htm?(l)'
|
|
28
|
-
|
|
29
|
-
export const GLOB_EXCLUDE = [
|
|
30
|
-
'**/node_modules',
|
|
31
|
-
'**/dist',
|
|
32
|
-
'**/package-lock.json',
|
|
33
|
-
'**/yarn.lock',
|
|
34
|
-
'**/pnpm-lock.yaml',
|
|
35
|
-
'**/bun.lockb',
|
|
36
|
-
|
|
37
|
-
'**/output',
|
|
38
|
-
'**/coverage',
|
|
39
|
-
'**/temp',
|
|
40
|
-
'**/.temp',
|
|
41
|
-
'**/tmp',
|
|
42
|
-
'**/.tmp',
|
|
43
|
-
'**/.history',
|
|
44
|
-
'**/.vitepress/cache',
|
|
45
|
-
'**/.nuxt',
|
|
46
|
-
'**/.next',
|
|
47
|
-
'**/.svelte-kit',
|
|
48
|
-
'**/.vercel',
|
|
49
|
-
'**/.changeset',
|
|
50
|
-
'**/.idea',
|
|
51
|
-
'**/.DS_Store',
|
|
52
|
-
'**/Thumbs.db',
|
|
53
|
-
'**/ehthumbs.db',
|
|
54
|
-
'**/Desktop.ini',
|
|
55
|
-
'**/$RECYCLE.BIN',
|
|
56
|
-
'**/.cache',
|
|
57
|
-
'**/.output',
|
|
58
|
-
'**/.vite-inspect',
|
|
59
|
-
'**/.yarn',
|
|
60
|
-
'**/vite.config.*.timestamp-*',
|
|
61
|
-
|
|
62
|
-
'**/CHANGELOG*.md',
|
|
63
|
-
'**/*.min.*',
|
|
64
|
-
'**/LICENSE*',
|
|
65
|
-
'**/__snapshots__',
|
|
66
|
-
'**/auto-import?(s).d.ts',
|
|
67
|
-
'**/components.d.ts',
|
|
68
|
-
'**/typed-router.d.ts',
|
|
69
|
-
'**/.eslint-config-inspector'
|
|
70
|
-
]
|
package/src/index.js
DELETED
package/src/presets.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { FlatConfigComposer } from 'eslint-flat-config-utils'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
compat,
|
|
5
|
-
ignores,
|
|
6
|
-
imports,
|
|
7
|
-
javascript,
|
|
8
|
-
jsdoc,
|
|
9
|
-
macros,
|
|
10
|
-
packageJson,
|
|
11
|
-
prettier,
|
|
12
|
-
stylistic,
|
|
13
|
-
unocss,
|
|
14
|
-
vue,
|
|
15
|
-
unicorn,
|
|
16
|
-
promise
|
|
17
|
-
} from './configs'
|
|
18
|
-
|
|
19
|
-
import { hasUnoCss, hasVue } from './env'
|
|
20
|
-
|
|
21
|
-
export const defaultPluginRenaming = {
|
|
22
|
-
'@stylistic': 'style',
|
|
23
|
-
'@typescript-eslint': 'ts'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param {object} options - 设置选项
|
|
29
|
-
* @param {...any} userConfigs - 用户配置
|
|
30
|
-
* @returns {Promise<any[]>} 合并后的配置
|
|
31
|
-
*/
|
|
32
|
-
export function cuiqg(
|
|
33
|
-
options = {},
|
|
34
|
-
...userConfigs
|
|
35
|
-
) {
|
|
36
|
-
const {
|
|
37
|
-
prettier: enablePrettier = false,
|
|
38
|
-
unocss: enableUnocss = hasUnoCss(),
|
|
39
|
-
vue: enableVue = hasVue()
|
|
40
|
-
} = options
|
|
41
|
-
|
|
42
|
-
const configs = []
|
|
43
|
-
|
|
44
|
-
configs.push(
|
|
45
|
-
compat(),
|
|
46
|
-
ignores(),
|
|
47
|
-
javascript(),
|
|
48
|
-
imports(),
|
|
49
|
-
jsdoc(),
|
|
50
|
-
stylistic(),
|
|
51
|
-
packageJson(),
|
|
52
|
-
unicorn(),
|
|
53
|
-
promise()
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
if (enableVue) {
|
|
57
|
-
configs.push(vue(), macros())
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (enableUnocss) {
|
|
61
|
-
configs.push(unocss())
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (enablePrettier) {
|
|
65
|
-
configs.push(prettier())
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
let composer = new FlatConfigComposer()
|
|
69
|
-
|
|
70
|
-
composer = composer
|
|
71
|
-
.append(...configs, ...userConfigs)
|
|
72
|
-
.renamePlugins(defaultPluginRenaming)
|
|
73
|
-
|
|
74
|
-
return composer
|
|
75
|
-
}
|
package/src/utils.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export async function interopDefault(
|
|
2
|
-
module
|
|
3
|
-
) {
|
|
4
|
-
try {
|
|
5
|
-
let resolved = await module
|
|
6
|
-
return resolved?.default || resolved
|
|
7
|
-
}
|
|
8
|
-
catch (error) {
|
|
9
|
-
throw new Error(`Cannot import module: ${String(error)}`)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function renameRules(rules, map) {
|
|
14
|
-
return Object.fromEntries(
|
|
15
|
-
Object.entries(rules).map(([key, value]) => {
|
|
16
|
-
for (const [from, to] of Object.entries(map)) {
|
|
17
|
-
if (key.startsWith(`${from}/`)) {
|
|
18
|
-
return [to + key.slice(from.length), value]
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return [key, value]
|
|
22
|
-
})
|
|
23
|
-
)
|
|
24
|
-
}
|
package/tsdown.config.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsdown'
|
|
2
|
-
import { spawn } from 'node:child_process'
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: 'src/index.js',
|
|
5
|
-
clean: true,
|
|
6
|
-
shims: true,
|
|
7
|
-
format: ['esm'],
|
|
8
|
-
exports: true,
|
|
9
|
-
hooks: {
|
|
10
|
-
'build:done': async (args) => {
|
|
11
|
-
if (args.options?.watch) {
|
|
12
|
-
spawn('pnpx', ['@eslint/config-inspector', '--open', 'false', '--config', 'eslint-inspector.config.js'], {
|
|
13
|
-
stdio: 'inherit',
|
|
14
|
-
shell: true
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
})
|