@cuiqg/eslint-config 2.8.14 → 2.8.15
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 +39 -46
- package/package.json +15 -12
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
2
2
|
import globals from "globals";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { isPackageExists } from "local-pkg";
|
|
5
3
|
import path from "node:path";
|
|
6
4
|
import fs from "node:fs";
|
|
7
5
|
import process$1 from "node:process";
|
|
6
|
+
import { isPackageExists } from "local-pkg";
|
|
7
|
+
|
|
8
|
+
//#region src/utils.js
|
|
9
|
+
async function interopDefault(module) {
|
|
10
|
+
const resolved = await module;
|
|
11
|
+
return resolved.default || resolved;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/configs/baseline.js
|
|
16
|
+
async function baseline() {
|
|
17
|
+
const [pluginBaseline] = await Promise.all([interopDefault(import("eslint-plugin-baseline-js"))]);
|
|
18
|
+
return [{
|
|
19
|
+
name: "cuiqg/baseline",
|
|
20
|
+
plugins: { "baseline-js": pluginBaseline },
|
|
21
|
+
rules: { ...pluginBaseline.configs.recommended({
|
|
22
|
+
available: "widely",
|
|
23
|
+
level: "warn"
|
|
24
|
+
}).rules }
|
|
25
|
+
}];
|
|
26
|
+
}
|
|
8
27
|
|
|
28
|
+
//#endregion
|
|
9
29
|
//#region src/globs.js
|
|
10
30
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
11
31
|
const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
|
|
@@ -13,12 +33,9 @@ const GLOB_TS = `**/*.?([cm])ts`;
|
|
|
13
33
|
const GLOB_TSX = `**/*.?([cm])tsx`;
|
|
14
34
|
const GLOB_JS = `**/*.?([cm])js`;
|
|
15
35
|
const GLOB_JSX = `**/*.?([cm])jsx`;
|
|
16
|
-
const GLOB_STYLE = "**/*.{c,
|
|
36
|
+
const GLOB_STYLE = "**/*.{c,sc}ss";
|
|
17
37
|
const GLOB_CSS = "**/*.css";
|
|
18
38
|
const GLOB_SCSS = "**/*.scss";
|
|
19
|
-
const GLOB_LESS = "**/*.less";
|
|
20
|
-
const GLOB_STYLUS = "**/*.styl";
|
|
21
|
-
const GLOB_POSTCSS = "**/*.{p,post}css";
|
|
22
39
|
const GLOB_VUE = "**/*.vue";
|
|
23
40
|
const GLOB_EXCLUDE = [
|
|
24
41
|
"**/node_modules",
|
|
@@ -64,22 +81,14 @@ const GLOB_EXCLUDE = [
|
|
|
64
81
|
//#endregion
|
|
65
82
|
//#region src/configs/ignores.js
|
|
66
83
|
async function ignores() {
|
|
84
|
+
const [pluginGitignore] = await Promise.all([interopDefault(import("eslint-config-flat-gitignore"))]);
|
|
67
85
|
return [{
|
|
68
86
|
ignores: [...GLOB_EXCLUDE],
|
|
69
87
|
name: "cuiqg/ignores"
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
//#region src/utils.js
|
|
75
|
-
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
76
|
-
async function interopDefault(module) {
|
|
77
|
-
try {
|
|
78
|
-
let resolved = await module;
|
|
79
|
-
return resolved?.default || resolved;
|
|
80
|
-
} catch (error) {
|
|
81
|
-
throw new Error(`Cannot import module: ${String(error)}`);
|
|
82
|
-
}
|
|
88
|
+
}, { ...pluginGitignore({
|
|
89
|
+
name: "cuiqg/ignores/gitignore",
|
|
90
|
+
strict: false
|
|
91
|
+
}) }];
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
//#endregion
|
|
@@ -327,8 +336,9 @@ async function jsdoc() {
|
|
|
327
336
|
//#endregion
|
|
328
337
|
//#region src/configs/macros.js
|
|
329
338
|
async function macros() {
|
|
339
|
+
const [configMacros] = await Promise.all([interopDefault(import("@vue-macros/eslint-config"))]);
|
|
330
340
|
return [{
|
|
331
|
-
...
|
|
341
|
+
...configMacros,
|
|
332
342
|
name: "cuiqg/macros"
|
|
333
343
|
}];
|
|
334
344
|
}
|
|
@@ -429,7 +439,7 @@ async function stylistic(options = {}) {
|
|
|
429
439
|
//#endregion
|
|
430
440
|
//#region src/configs/unocss.js
|
|
431
441
|
async function unocss() {
|
|
432
|
-
const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
|
|
442
|
+
const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
|
|
433
443
|
return [{
|
|
434
444
|
name: "cuiqg/unocss",
|
|
435
445
|
plugins: { "@unocss": pluginUnoCSS },
|
|
@@ -481,8 +491,8 @@ async function vue(options = {}) {
|
|
|
481
491
|
"vue/define-props-destructuring": ["error", { destructure: "always" }],
|
|
482
492
|
"vue/enforce-style-attribute": ["error", { allow: ["scoped", "plain"] }],
|
|
483
493
|
"vue/max-attributes-per-line": ["error", {
|
|
484
|
-
|
|
485
|
-
|
|
494
|
+
singleline: { max: 1 },
|
|
495
|
+
multiline: { max: 1 }
|
|
486
496
|
}],
|
|
487
497
|
"vue/html-button-has-type": "error",
|
|
488
498
|
"vue/html-end-tags": "error",
|
|
@@ -619,7 +629,7 @@ async function vue(options = {}) {
|
|
|
619
629
|
//#endregion
|
|
620
630
|
//#region src/configs/tailwindcss.js
|
|
621
631
|
async function tailwindcss() {
|
|
622
|
-
const pluginTailwindcss = await interopDefault(import("eslint-plugin-tailwindcss"));
|
|
632
|
+
const [pluginTailwindcss] = await Promise.all([interopDefault(import("eslint-plugin-tailwindcss"))]);
|
|
623
633
|
return [{
|
|
624
634
|
name: "cuiqg/tailwindcss",
|
|
625
635
|
plugins: { tailwindcss: pluginTailwindcss },
|
|
@@ -632,7 +642,7 @@ async function tailwindcss() {
|
|
|
632
642
|
//#endregion
|
|
633
643
|
//#region src/configs/comments.js
|
|
634
644
|
async function comments() {
|
|
635
|
-
const pluginComments = await interopDefault(import("@eslint-community/eslint-plugin-eslint-comments"));
|
|
645
|
+
const [pluginComments] = await Promise.all([interopDefault(import("@eslint-community/eslint-plugin-eslint-comments"))]);
|
|
636
646
|
return [{
|
|
637
647
|
name: "cuiqg/eslint-comments",
|
|
638
648
|
plugins: { "@eslint-community/eslint-comments": pluginComments },
|
|
@@ -863,37 +873,20 @@ const isInEditor = () => {
|
|
|
863
873
|
return !!(process$1.env.VSCODE_PID || process$1.env.VSCODE_CWD || process$1.env.JETBRAINS_IDE || process$1.env.VIM || process$1.env.NVIM);
|
|
864
874
|
};
|
|
865
875
|
const hasVue = () => isPackageExists("vue");
|
|
866
|
-
const hasTypeScript = () => isPackageExists("typescript");
|
|
867
876
|
const hasUnocss = () => isPackageExists("unocss");
|
|
868
|
-
const hasTailwindcss = () => isPackageExists("tailwindcss");
|
|
869
877
|
|
|
870
878
|
//#endregion
|
|
871
879
|
//#region src/presets.js
|
|
872
|
-
/**
|
|
873
|
-
*
|
|
874
|
-
* @param {object} options - 设置选项
|
|
875
|
-
* @param {boolean} [options.typescript] - 是否启用 TypeScript 格式化
|
|
876
|
-
* @param {boolean} [options.unocss] - 是否启用 Unocss 格式化
|
|
877
|
-
* @param {boolean} [options.tailwindcss] - 是否启用 TailwindCSS 格式化
|
|
878
|
-
* @param {boolean} [options.vue] - 是否启用 VUE 格式化
|
|
879
|
-
* @param {boolean} [options.jsdoc=true] - 是否启用 JSDoc 格式化
|
|
880
|
-
* @param {...Object} userConfigs - 用户配置
|
|
881
|
-
*
|
|
882
|
-
* @returns {Promise<Object[]>} 合并后的配置
|
|
883
|
-
*/
|
|
884
880
|
function cuiqg(options = {}, ...userConfigs) {
|
|
885
|
-
const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss =
|
|
881
|
+
const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = false, typescript: enableTypescript = false, vue: enableVue = hasVue() } = options;
|
|
886
882
|
const configs = [];
|
|
887
|
-
configs.push(autoImports(), ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
|
|
883
|
+
configs.push(autoImports(), baseline(), ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
|
|
888
884
|
if (enableTypescript) configs.push(typescript());
|
|
889
885
|
if (enableJsdoc) configs.push(jsdoc());
|
|
890
886
|
if (enableVue) configs.push(vue({ typescript: enableTypescript }), macros());
|
|
891
887
|
if (enableUnocss) configs.push(unocss());
|
|
892
888
|
if (enableTailwindcss) configs.push(tailwindcss());
|
|
893
|
-
|
|
894
|
-
composer = composer.append(...configs, ...userConfigs);
|
|
895
|
-
if (isInEditor) composer = composer.disableRulesFix(["unused-imports/no-unused-imports"], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
896
|
-
return composer;
|
|
889
|
+
return new FlatConfigComposer(...configs, ...userConfigs);
|
|
897
890
|
}
|
|
898
891
|
|
|
899
892
|
//#endregion
|
|
@@ -901,4 +894,4 @@ function cuiqg(options = {}, ...userConfigs) {
|
|
|
901
894
|
var src_default = cuiqg;
|
|
902
895
|
|
|
903
896
|
//#endregion
|
|
904
|
-
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX,
|
|
897
|
+
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TS, GLOB_TSX, GLOB_VUE, autoImports, baseline, comments, cuiqg, src_default as default, hasUnocss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, stylistic, stylisticConfigDefaults, tailwindcss, typescript, unocss, vue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuiqg/eslint-config",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.15",
|
|
4
4
|
"description": "Eslint config for @cuiqg",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint-config"
|
|
@@ -26,21 +26,14 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
|
-
"scripts": {
|
|
30
|
-
"build": "tsdown",
|
|
31
|
-
"dev": "tsdown --watch",
|
|
32
|
-
"build:inspect": "npx @eslint/config-inspector build --config eslint-inspector.config.js",
|
|
33
|
-
"lint": "eslint .",
|
|
34
|
-
"lint:inspect": "npx @eslint/config-inspector --open false --config eslint-inspector.config.js",
|
|
35
|
-
"prepublishOnly": "npm run build",
|
|
36
|
-
"release": "bumpp"
|
|
37
|
-
},
|
|
38
29
|
"devDependencies": {
|
|
39
30
|
"@eslint/config-inspector": "^1.4.2",
|
|
31
|
+
"@types/node": "^25.0.3",
|
|
40
32
|
"bumpp": "^10.3.2",
|
|
41
33
|
"eslint": "^9.39.2",
|
|
42
34
|
"tsdown": "^0.18.2",
|
|
43
|
-
"typescript": "^5.9.3"
|
|
35
|
+
"typescript": "^5.9.3",
|
|
36
|
+
"unrun": "^0.2.22"
|
|
44
37
|
},
|
|
45
38
|
"peerDependencies": {
|
|
46
39
|
"eslint": ">=9.28.0"
|
|
@@ -52,7 +45,9 @@
|
|
|
52
45
|
"@typescript-eslint/parser": "^8.50.1",
|
|
53
46
|
"@unocss/eslint-plugin": "^66.5.10",
|
|
54
47
|
"@vue-macros/eslint-config": "3.0.0-beta.21",
|
|
48
|
+
"eslint-config-flat-gitignore": "^2.1.0",
|
|
55
49
|
"eslint-flat-config-utils": "^2.1.4",
|
|
50
|
+
"eslint-plugin-baseline-js": "^0.4.2",
|
|
56
51
|
"eslint-plugin-depend": "^1.4.0",
|
|
57
52
|
"eslint-plugin-import-x": "^4.16.1",
|
|
58
53
|
"eslint-plugin-jsdoc": "^61.5.0",
|
|
@@ -64,5 +59,13 @@
|
|
|
64
59
|
"jsonc-eslint-parser": "^2.4.2",
|
|
65
60
|
"local-pkg": "^1.1.2",
|
|
66
61
|
"vue-eslint-parser": "^10.2.0"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsdown",
|
|
65
|
+
"dev": "tsdown --watch",
|
|
66
|
+
"build:inspect": "npx @eslint/config-inspector build --config eslint-inspector.config.js",
|
|
67
|
+
"lint": "eslint .",
|
|
68
|
+
"lint:inspect": "npx @eslint/config-inspector --open false --config eslint-inspector.config.js",
|
|
69
|
+
"release": "bumpp"
|
|
67
70
|
}
|
|
68
|
-
}
|
|
71
|
+
}
|