@cuiqg/eslint-config 2.8.11 → 2.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -9
- package/dist/index.mjs +35 -17
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -22,17 +22,9 @@ npm i -D eslint @cuiqg/eslint-config
|
|
|
22
22
|
创建 `eslint.config.mjs` 文件
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
|
-
import fs from 'node:fs'
|
|
26
25
|
import cuiqg from '@cuiqg/eslint-config'
|
|
27
|
-
import { FlatCompat } from '@eslint/eslintrc'
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export default cuiqg({},
|
|
32
|
-
fs.existsSync('.eslintrc-auto-import.json')
|
|
33
|
-
? compat.extend('./.eslintrc-auto-import.json')
|
|
34
|
-
: []
|
|
35
|
-
)
|
|
27
|
+
export default cuiqg()
|
|
36
28
|
```
|
|
37
29
|
|
|
38
30
|
## 插件配置
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
2
|
+
import globals from "globals";
|
|
2
3
|
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { isPackageExists } from "local-pkg";
|
|
4
|
-
import
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import fs from "node:fs";
|
|
5
7
|
import process$1 from "node:process";
|
|
6
8
|
|
|
7
9
|
//#region src/globs.js
|
|
@@ -59,6 +61,15 @@ const GLOB_EXCLUDE = [
|
|
|
59
61
|
"**/.eslint-config-inspector"
|
|
60
62
|
];
|
|
61
63
|
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/configs/ignores.js
|
|
66
|
+
async function ignores() {
|
|
67
|
+
return [{
|
|
68
|
+
ignores: [...GLOB_EXCLUDE],
|
|
69
|
+
name: "cuiqg/ignores"
|
|
70
|
+
}];
|
|
71
|
+
}
|
|
72
|
+
|
|
62
73
|
//#endregion
|
|
63
74
|
//#region src/utils.js
|
|
64
75
|
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
@@ -71,19 +82,6 @@ async function interopDefault(module) {
|
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
84
|
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/configs/ignores.js
|
|
76
|
-
async function ignores() {
|
|
77
|
-
const configGitignore = await interopDefault(import("eslint-config-flat-gitignore"));
|
|
78
|
-
return [{
|
|
79
|
-
ignores: [...GLOB_EXCLUDE],
|
|
80
|
-
name: "cuiqg/ignores"
|
|
81
|
-
}, configGitignore({
|
|
82
|
-
name: "cuiqg/gitignore",
|
|
83
|
-
strict: false
|
|
84
|
-
})];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
85
|
//#endregion
|
|
88
86
|
//#region src/configs/javascript.js
|
|
89
87
|
async function javascript(options = {}) {
|
|
@@ -482,6 +480,10 @@ async function vue(options = {}) {
|
|
|
482
480
|
"vue/define-props-declaration": "error",
|
|
483
481
|
"vue/define-props-destructuring": ["error", { destructure: "always" }],
|
|
484
482
|
"vue/enforce-style-attribute": ["error", { allow: ["scoped", "plain"] }],
|
|
483
|
+
"vue/max-attributes-per-line": ["error", {
|
|
484
|
+
"singleline": { "max": 1 },
|
|
485
|
+
"multiline": { "max": 1 }
|
|
486
|
+
}],
|
|
485
487
|
"vue/html-button-has-type": "error",
|
|
486
488
|
"vue/html-end-tags": "error",
|
|
487
489
|
"vue/jsx-uses-vars": "error",
|
|
@@ -544,7 +546,7 @@ async function vue(options = {}) {
|
|
|
544
546
|
"vue/no-undef-properties": "error",
|
|
545
547
|
"vue/no-unused-components": "error",
|
|
546
548
|
"vue/no-unused-emit-declarations": "error",
|
|
547
|
-
"vue/no-unused-vars": "error",
|
|
549
|
+
"vue/no-unused-vars": ["error", { ignorePattern: "^_" }],
|
|
548
550
|
"vue/no-use-computed-property-like-method": "error",
|
|
549
551
|
"vue/no-use-v-else-with-v-for": "error",
|
|
550
552
|
"vue/no-use-v-if-with-v-for": "error",
|
|
@@ -834,6 +836,22 @@ async function typescript() {
|
|
|
834
836
|
}];
|
|
835
837
|
}
|
|
836
838
|
|
|
839
|
+
//#endregion
|
|
840
|
+
//#region src/configs/auto-imports.js
|
|
841
|
+
async function autoImports(options = {}) {
|
|
842
|
+
const { cwd = process.cwd(), filename = ".eslintrc-auto-import.json", strict = true } = options;
|
|
843
|
+
const config = [];
|
|
844
|
+
if (fs.existsSync(path.join(cwd, filename))) try {
|
|
845
|
+
config.push({
|
|
846
|
+
name: "cuiqg/auto-imports",
|
|
847
|
+
languageOptions: { ...JSON.parse(fs.readFileSync(path.join(cwd, filename), "utf8")) }
|
|
848
|
+
});
|
|
849
|
+
} catch (error) {
|
|
850
|
+
if (strict) throw error;
|
|
851
|
+
}
|
|
852
|
+
return config;
|
|
853
|
+
}
|
|
854
|
+
|
|
837
855
|
//#endregion
|
|
838
856
|
//#region src/env.js
|
|
839
857
|
const isInGitHookOrLintStaged = () => {
|
|
@@ -866,7 +884,7 @@ const hasTailwindcss = () => isPackageExists("tailwindcss");
|
|
|
866
884
|
function cuiqg(options = {}, ...userConfigs) {
|
|
867
885
|
const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), typescript: enableTypescript = hasTypeScript(), vue: enableVue = hasVue() } = options;
|
|
868
886
|
const configs = [];
|
|
869
|
-
configs.push(ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
|
|
887
|
+
configs.push(autoImports(), ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
|
|
870
888
|
if (enableTypescript) configs.push(typescript());
|
|
871
889
|
if (enableJsdoc) configs.push(jsdoc());
|
|
872
890
|
if (enableVue) configs.push(vue({ typescript: enableTypescript }), macros());
|
|
@@ -883,4 +901,4 @@ function cuiqg(options = {}, ...userConfigs) {
|
|
|
883
901
|
var src_default = cuiqg;
|
|
884
902
|
|
|
885
903
|
//#endregion
|
|
886
|
-
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_LESS, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_TS, GLOB_TSX, GLOB_VUE, comments, cuiqg, src_default as default, hasTailwindcss, hasTypeScript, hasUnocss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, stylistic, stylisticConfigDefaults, tailwindcss, typescript, unocss, vue };
|
|
904
|
+
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_LESS, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_TS, GLOB_TSX, GLOB_VUE, autoImports, comments, cuiqg, src_default as default, hasTailwindcss, hasTypeScript, 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.13",
|
|
4
4
|
"description": "Eslint config for @cuiqg",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint-config"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"build:inspect": "npx @eslint/config-inspector build --config eslint-inspector.config.js",
|
|
29
29
|
"lint": "eslint .",
|
|
30
30
|
"lint:inspect": "npx @eslint/config-inspector --open false --config eslint-inspector.config.js",
|
|
31
|
-
"
|
|
32
|
-
"release": "bumpp"
|
|
31
|
+
"prerelease": "npm run build",
|
|
32
|
+
"release": "bumpp && npm publish"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@eslint/config-inspector": "^1.4.2",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"@typescript-eslint/parser": "^8.50.1",
|
|
49
49
|
"@unocss/eslint-plugin": "^66.5.10",
|
|
50
50
|
"@vue-macros/eslint-config": "3.0.0-beta.21",
|
|
51
|
-
"eslint-config-flat-gitignore": "^2.1.0",
|
|
52
51
|
"eslint-flat-config-utils": "^2.1.4",
|
|
53
52
|
"eslint-plugin-depend": "^1.4.0",
|
|
54
53
|
"eslint-plugin-import-x": "^4.16.1",
|