@cuiqg/eslint-config 2.5.8 → 2.5.10
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/.editorconfig +12 -0
- package/.gitattributes +1 -0
- package/.vscode/settings.json +14 -0
- package/LICENSE +24 -24
- package/README.md +45 -45
- package/bump.config.js +6 -0
- package/eslint-inspector.config.js +7 -0
- package/eslint.config.js +3 -0
- package/package.json +27 -28
- package/pnpm-workspace.yaml +3 -0
- package/src/configs/compat.js +17 -0
- package/src/configs/ignores.js +17 -0
- package/src/configs/index.js +12 -0
- package/src/configs/javascript.js +38 -0
- package/src/configs/jsdoc.js +33 -0
- package/src/configs/macros.js +12 -0
- package/src/configs/package-json.js +16 -0
- package/src/configs/prettier.js +21 -0
- package/src/configs/promise.js +12 -0
- package/src/configs/stylistic.js +24 -0
- package/src/configs/unicorn.js +17 -0
- package/src/configs/unocss.js +19 -0
- package/src/configs/vue.js +143 -0
- package/src/env.js +27 -0
- package/src/globs.js +70 -0
- package/src/index.js +8 -0
- package/src/presets.js +72 -0
- package/src/utils.js +24 -0
- package/tsdown.config.js +18 -0
- package/vercel.json +7 -0
- package/dist/index.js +0 -407
package/dist/index.js
DELETED
|
@@ -1,407 +0,0 @@
|
|
|
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
|
-
"**/.cache",
|
|
51
|
-
"**/.output",
|
|
52
|
-
"**/.vite-inspect",
|
|
53
|
-
"**/.yarn",
|
|
54
|
-
"**/vite.config.*.timestamp-*",
|
|
55
|
-
"**/CHANGELOG*.md",
|
|
56
|
-
"**/*.min.*",
|
|
57
|
-
"**/LICENSE*",
|
|
58
|
-
"**/__snapshots__",
|
|
59
|
-
"**/auto-import?(s).d.ts",
|
|
60
|
-
"**/components.d.ts",
|
|
61
|
-
"**/typed-router.d.ts",
|
|
62
|
-
"**/.eslint-config-inspector"
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/utils.js
|
|
67
|
-
async function interopDefault(module) {
|
|
68
|
-
try {
|
|
69
|
-
let resolved = await module;
|
|
70
|
-
return resolved?.default || resolved;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
throw new Error(`Cannot import module: ${String(error)}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function renameRules(rules, map) {
|
|
76
|
-
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
77
|
-
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
78
|
-
return [key, value];
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/configs/ignores.js
|
|
84
|
-
async function ignores() {
|
|
85
|
-
const configGitignore = await interopDefault(import("eslint-config-flat-gitignore"));
|
|
86
|
-
return [{
|
|
87
|
-
ignores: [...GLOB_EXCLUDE],
|
|
88
|
-
name: "cuiqg/ignores"
|
|
89
|
-
}, configGitignore({
|
|
90
|
-
name: "cuiqg/gitignore",
|
|
91
|
-
strict: false
|
|
92
|
-
})];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/configs/javascript.js
|
|
97
|
-
async function javascript() {
|
|
98
|
-
const [pluginJs] = await Promise.all([interopDefault(import("@eslint/js"))]);
|
|
99
|
-
return [{
|
|
100
|
-
languageOptions: {
|
|
101
|
-
ecmaVersion: "latest",
|
|
102
|
-
globals: {
|
|
103
|
-
...globals.browser,
|
|
104
|
-
...globals.es2025,
|
|
105
|
-
...globals.node
|
|
106
|
-
},
|
|
107
|
-
parserOptions: {
|
|
108
|
-
ecmaFeatures: { jsx: true },
|
|
109
|
-
ecmaVersion: "latest",
|
|
110
|
-
sourceType: "module"
|
|
111
|
-
},
|
|
112
|
-
sourceType: "module"
|
|
113
|
-
},
|
|
114
|
-
linterOptions: { reportUnusedDisableDirectives: true },
|
|
115
|
-
name: "cuiqg/javascript",
|
|
116
|
-
plugins: { js: pluginJs },
|
|
117
|
-
rules: { ...pluginJs.configs.recommended.rules }
|
|
118
|
-
}];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/configs/jsdoc.js
|
|
123
|
-
async function jsdoc() {
|
|
124
|
-
const pluginJsdoc = await interopDefault(import("eslint-plugin-jsdoc"));
|
|
125
|
-
return [{
|
|
126
|
-
name: "cuiqg/jsdoc",
|
|
127
|
-
plugins: { jsdoc: pluginJsdoc },
|
|
128
|
-
rules: {
|
|
129
|
-
"jsdoc/check-access": "warn",
|
|
130
|
-
"jsdoc/check-param-names": "warn",
|
|
131
|
-
"jsdoc/check-property-names": "warn",
|
|
132
|
-
"jsdoc/check-types": "warn",
|
|
133
|
-
"jsdoc/empty-tags": "warn",
|
|
134
|
-
"jsdoc/implements-on-classes": "warn",
|
|
135
|
-
"jsdoc/no-defaults": "warn",
|
|
136
|
-
"jsdoc/no-multi-asterisks": "warn",
|
|
137
|
-
"jsdoc/require-param-name": "warn",
|
|
138
|
-
"jsdoc/require-property": "warn",
|
|
139
|
-
"jsdoc/require-property-description": "warn",
|
|
140
|
-
"jsdoc/require-property-name": "warn",
|
|
141
|
-
"jsdoc/require-returns-check": "warn",
|
|
142
|
-
"jsdoc/require-returns-description": "warn",
|
|
143
|
-
"jsdoc/require-yields-check": "warn",
|
|
144
|
-
"jsdoc/check-alignment": "warn",
|
|
145
|
-
"jsdoc/multiline-blocks": "warn"
|
|
146
|
-
}
|
|
147
|
-
}];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/configs/macros.js
|
|
152
|
-
async function macros() {
|
|
153
|
-
const configMacros = await interopDefault(import("@vue-macros/eslint-config"));
|
|
154
|
-
return [{
|
|
155
|
-
...configMacros,
|
|
156
|
-
name: "cuiqg/macros"
|
|
157
|
-
}];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/configs/package-json.js
|
|
162
|
-
async function packageJson() {
|
|
163
|
-
const [pluginPackageJson, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-package-json")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
164
|
-
return [{
|
|
165
|
-
files: ["**/package.json"],
|
|
166
|
-
languageOptions: { parser: parserJsonc },
|
|
167
|
-
name: "cuiqg/package-json",
|
|
168
|
-
plugins: { "package-json": pluginPackageJson },
|
|
169
|
-
rules: { ...pluginPackageJson.configs.recommended.rules },
|
|
170
|
-
settings: { packageJson: { enforceForPrivate: false } }
|
|
171
|
-
}];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/configs/prettier.js
|
|
176
|
-
async function prettier() {
|
|
177
|
-
const [pluginPrettier, recommendedPrettier] = await Promise.all([interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-plugin-prettier/recommended"))]);
|
|
178
|
-
return [{
|
|
179
|
-
name: "cuiqg/prettier",
|
|
180
|
-
plugins: { prettier: pluginPrettier },
|
|
181
|
-
rules: {
|
|
182
|
-
...recommendedPrettier.rules,
|
|
183
|
-
"prettier/prettier": "warn"
|
|
184
|
-
}
|
|
185
|
-
}];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
//#endregion
|
|
189
|
-
//#region src/configs/stylistic.js
|
|
190
|
-
async function stylistic() {
|
|
191
|
-
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
192
|
-
const config = pluginStylistic.configs.customize({
|
|
193
|
-
commaDangle: "never",
|
|
194
|
-
indent: 2,
|
|
195
|
-
pluginName: "style",
|
|
196
|
-
quotes: "single",
|
|
197
|
-
semi: false
|
|
198
|
-
});
|
|
199
|
-
return [{
|
|
200
|
-
name: "cuiqg/stylistic",
|
|
201
|
-
plugins: { style: pluginStylistic },
|
|
202
|
-
rules: { ...config.rules }
|
|
203
|
-
}];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/configs/unocss.js
|
|
208
|
-
async function unocss() {
|
|
209
|
-
const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
|
|
210
|
-
return [{
|
|
211
|
-
name: "cuiqg/unocss",
|
|
212
|
-
plugins: { unocss: pluginUnoCSS },
|
|
213
|
-
rules: { ...renameRules(pluginUnoCSS.configs.recommended.rules, { "@unocss": "unocss" }) }
|
|
214
|
-
}];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/configs/vue.js
|
|
219
|
-
async function vue() {
|
|
220
|
-
const files = [GLOB_VUE];
|
|
221
|
-
const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
|
|
222
|
-
return [{
|
|
223
|
-
files,
|
|
224
|
-
languageOptions: {
|
|
225
|
-
globals: {
|
|
226
|
-
computed: "readonly",
|
|
227
|
-
defineEmits: "readonly",
|
|
228
|
-
defineExpose: "readonly",
|
|
229
|
-
defineModel: "readonly",
|
|
230
|
-
defineOptions: "readonly",
|
|
231
|
-
defineProps: "readonly",
|
|
232
|
-
defineSlots: "readonly",
|
|
233
|
-
onActivated: "readonly",
|
|
234
|
-
onDeactivated: "readonly",
|
|
235
|
-
onMounted: "readonly",
|
|
236
|
-
onUnmounted: "readonly",
|
|
237
|
-
reactive: "readonly",
|
|
238
|
-
ref: "readonly",
|
|
239
|
-
toRef: "readonly",
|
|
240
|
-
toRefs: "readonly",
|
|
241
|
-
useAttrs: "readonly",
|
|
242
|
-
useSlots: "readonly",
|
|
243
|
-
watch: "readonly",
|
|
244
|
-
watchEffect: "readonly"
|
|
245
|
-
},
|
|
246
|
-
parser: parserVue,
|
|
247
|
-
parserOptions: {
|
|
248
|
-
ecmaFeatures: { jsx: true },
|
|
249
|
-
extraFileExtensions: [".vue"],
|
|
250
|
-
parser: null,
|
|
251
|
-
sourceType: "module"
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
name: "cuiqg/vue",
|
|
255
|
-
plugins: { vue: pluginVue },
|
|
256
|
-
processor: pluginVue.processors[".vue"],
|
|
257
|
-
rules: {
|
|
258
|
-
...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
259
|
-
...acc,
|
|
260
|
-
...c
|
|
261
|
-
}), {}),
|
|
262
|
-
"node/prefer-global/process": "off",
|
|
263
|
-
"vue/array-bracket-spacing": ["error", "never"],
|
|
264
|
-
"vue/arrow-spacing": ["error", {
|
|
265
|
-
after: true,
|
|
266
|
-
before: true
|
|
267
|
-
}],
|
|
268
|
-
"vue/block-order": ["error", { order: [
|
|
269
|
-
"script",
|
|
270
|
-
"template",
|
|
271
|
-
"style"
|
|
272
|
-
] }],
|
|
273
|
-
"vue/block-spacing": ["error", "always"],
|
|
274
|
-
"vue/block-tag-newline": ["error", {
|
|
275
|
-
multiline: "always",
|
|
276
|
-
singleline: "always"
|
|
277
|
-
}],
|
|
278
|
-
"vue/brace-style": [
|
|
279
|
-
"error",
|
|
280
|
-
"stroustrup",
|
|
281
|
-
{ allowSingleLine: true }
|
|
282
|
-
],
|
|
283
|
-
"vue/comma-dangle": ["error", "always-multiline"],
|
|
284
|
-
"vue/comma-spacing": ["error", {
|
|
285
|
-
after: true,
|
|
286
|
-
before: false
|
|
287
|
-
}],
|
|
288
|
-
"vue/comma-style": ["error", "last"],
|
|
289
|
-
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
290
|
-
"vue/define-macros-order": ["error", { order: [
|
|
291
|
-
"defineOptions",
|
|
292
|
-
"defineProps",
|
|
293
|
-
"defineEmits",
|
|
294
|
-
"defineSlots"
|
|
295
|
-
] }],
|
|
296
|
-
"vue/dot-location": ["error", "property"],
|
|
297
|
-
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
298
|
-
"vue/eqeqeq": ["error", "smart"],
|
|
299
|
-
"vue/html-comment-content-spacing": [
|
|
300
|
-
"error",
|
|
301
|
-
"always",
|
|
302
|
-
{ exceptions: ["-"] }
|
|
303
|
-
],
|
|
304
|
-
"vue/html-indent": ["error", 2],
|
|
305
|
-
"vue/html-quotes": ["error", "double"],
|
|
306
|
-
"vue/key-spacing": ["error", {
|
|
307
|
-
afterColon: true,
|
|
308
|
-
beforeColon: false
|
|
309
|
-
}],
|
|
310
|
-
"vue/keyword-spacing": ["error", {
|
|
311
|
-
after: true,
|
|
312
|
-
before: true
|
|
313
|
-
}],
|
|
314
|
-
"vue/max-attributes-per-line": "off",
|
|
315
|
-
"vue/multi-word-component-names": "off",
|
|
316
|
-
"vue/no-dupe-keys": "off",
|
|
317
|
-
"vue/no-empty-pattern": "error",
|
|
318
|
-
"vue/no-irregular-whitespace": "error",
|
|
319
|
-
"vue/no-loss-of-precision": "error",
|
|
320
|
-
"vue/no-restricted-syntax": [
|
|
321
|
-
"error",
|
|
322
|
-
"DebuggerStatement",
|
|
323
|
-
"LabeledStatement",
|
|
324
|
-
"WithStatement"
|
|
325
|
-
],
|
|
326
|
-
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
327
|
-
"vue/no-setup-props-reactivity-loss": "off",
|
|
328
|
-
"vue/no-sparse-arrays": "error",
|
|
329
|
-
"vue/no-unused-refs": "error",
|
|
330
|
-
"vue/no-useless-v-bind": "error",
|
|
331
|
-
"vue/no-v-html": "off",
|
|
332
|
-
"vue/object-curly-newline": "off",
|
|
333
|
-
"vue/object-curly-spacing": ["error", "always"],
|
|
334
|
-
"vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
335
|
-
"vue/object-shorthand": [
|
|
336
|
-
"error",
|
|
337
|
-
"always",
|
|
338
|
-
{
|
|
339
|
-
avoidQuotes: true,
|
|
340
|
-
ignoreConstructors: false
|
|
341
|
-
}
|
|
342
|
-
],
|
|
343
|
-
"vue/operator-linebreak": ["error", "before"],
|
|
344
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
|
345
|
-
"vue/prefer-separate-static-class": "error",
|
|
346
|
-
"vue/prefer-template": "error",
|
|
347
|
-
"vue/prop-name-casing": ["error", "camelCase"],
|
|
348
|
-
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
349
|
-
"vue/require-default-prop": "off",
|
|
350
|
-
"vue/require-prop-types": "off",
|
|
351
|
-
"vue/space-in-parens": ["error", "never"],
|
|
352
|
-
"vue/space-infix-ops": "error",
|
|
353
|
-
"vue/space-unary-ops": ["error", {
|
|
354
|
-
nonwords: false,
|
|
355
|
-
words: true
|
|
356
|
-
}],
|
|
357
|
-
"vue/template-curly-spacing": "error"
|
|
358
|
-
}
|
|
359
|
-
}];
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
//#endregion
|
|
363
|
-
//#region src/env.js
|
|
364
|
-
const isInGitHookOrLintStaged = () => {
|
|
365
|
-
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
366
|
-
};
|
|
367
|
-
const isInEditor = () => {
|
|
368
|
-
if (process.env.CI) return false;
|
|
369
|
-
if (isInGitHookOrLintStaged()) return false;
|
|
370
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
371
|
-
};
|
|
372
|
-
const hasVue = () => [
|
|
373
|
-
"vue",
|
|
374
|
-
"nuxt",
|
|
375
|
-
"vitepress",
|
|
376
|
-
"@slidev/cli"
|
|
377
|
-
].some((i) => isPackageExists(i));
|
|
378
|
-
const hasTypeScript = () => isPackageExists("typescript");
|
|
379
|
-
const hasUnoCss = () => isPackageExists("unocss");
|
|
380
|
-
|
|
381
|
-
//#endregion
|
|
382
|
-
//#region src/presets.js
|
|
383
|
-
const defaultPluginRenaming = { "@stylistic": "style" };
|
|
384
|
-
/**
|
|
385
|
-
*
|
|
386
|
-
* @param {object} options - 设置选项
|
|
387
|
-
* @param {...any} userConfigs - 用户配置
|
|
388
|
-
* @returns {Promise<any[]>} 合并后的配置
|
|
389
|
-
*/
|
|
390
|
-
function cuiqg(options = {}, ...userConfigs) {
|
|
391
|
-
const { prettier: enablePrettier = false, unocss: enableUnocss = hasUnoCss(), vue: enableVue = hasVue() } = options;
|
|
392
|
-
const configs = [];
|
|
393
|
-
configs.push(ignores(), javascript(), jsdoc(), stylistic(), packageJson());
|
|
394
|
-
if (enableVue) configs.push(vue(), macros());
|
|
395
|
-
if (enableUnocss) configs.push(unocss());
|
|
396
|
-
if (enablePrettier) configs.push(prettier());
|
|
397
|
-
let composer = new FlatConfigComposer();
|
|
398
|
-
composer = composer.append(...configs, ...userConfigs).renamePlugins(defaultPluginRenaming);
|
|
399
|
-
return composer;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
//#endregion
|
|
403
|
-
//#region src/index.js
|
|
404
|
-
var src_default = cuiqg;
|
|
405
|
-
|
|
406
|
-
//#endregion
|
|
407
|
-
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, cuiqg, src_default as default, defaultPluginRenaming, hasTypeScript, hasUnoCss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, prettier, stylistic, unocss, vue };
|