docs: 补充ESLint flat config配置示例到CI/CD门禁规范
This commit is contained in:
@@ -52,6 +52,54 @@
|
|||||||
## ⚙️ 具体配置要求
|
## ⚙️ 具体配置要求
|
||||||
|
|
||||||
### ESLint 配置
|
### ESLint 配置
|
||||||
|
```javascript
|
||||||
|
// eslint.config.js 关键配置
|
||||||
|
import globals from "globals";
|
||||||
|
import pluginVue from "eslint-plugin-vue";
|
||||||
|
import parserVue from "vue-eslint-parser";
|
||||||
|
import importPlugin from "eslint-plugin-import";
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
name: "app/files-to-lint",
|
||||||
|
files: ["**/*.{js,mjs,jsx,vue}"],
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "app/files-to-ignore",
|
||||||
|
ignores: ["**/dist/**", "**/node_modules/**", "**/help-center/**"],
|
||||||
|
},
|
||||||
|
|
||||||
|
...pluginVue.configs["flat/recommended"],
|
||||||
|
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.node,
|
||||||
|
},
|
||||||
|
parser: parserVue,
|
||||||
|
ecmaVersion: "latest",
|
||||||
|
sourceType: "module",
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
import: importPlugin,
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
// 确保导入的模块实际存在(核心规则,防止构建失败)
|
||||||
|
"import/no-unresolved": "error",
|
||||||
|
// 确保导入的命名导出实际存在
|
||||||
|
"import/named": "error",
|
||||||
|
// 确保默认导出存在
|
||||||
|
"import/default": "error",
|
||||||
|
// 确保命名空间导出存在
|
||||||
|
"import/namespace": "error",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
```
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -114,6 +162,15 @@ npm run test:unit && npm run build:prod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
```json
|
||||||
|
// package.json
|
||||||
|
{
|
||||||
|
"lint-staged": {
|
||||||
|
"*.{js,vue}": ["eslint --fix", "prettier --write"],
|
||||||
|
"*.{css,scss}": ["stylelint --fix", "prettier --write"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 🚫 失败处理机制
|
## 🚫 失败处理机制
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user