From d370b6a888f8ceb85a11c5ea50485590c5f877de Mon Sep 17 00:00:00 2001 From: zhaoyun Date: Fri, 24 Apr 2026 19:16:33 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85ESLint=20flat=20confi?= =?UTF-8?q?g=E9=85=8D=E7=BD=AE=E7=A4=BA=E4=BE=8B=E5=88=B0CI/CD=E9=97=A8?= =?UTF-8?q?=E7=A6=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/specs/cicd-gatekeeper.md | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/docs/specs/cicd-gatekeeper.md b/docs/specs/cicd-gatekeeper.md index cac9f840..546f97ee 100644 --- a/docs/specs/cicd-gatekeeper.md +++ b/docs/specs/cicd-gatekeeper.md @@ -52,6 +52,54 @@ ## ⚙️ 具体配置要求 ### 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"] + } +} +``` ## 🚫 失败处理机制