feat: 启用ESLint import规则 - 实时检测缺失导出,防止构建失败

This commit is contained in:
2026-04-24 18:12:12 +08:00
parent 90cf7f43d7
commit f2c71b08bb
3 changed files with 1433 additions and 11 deletions

View File

@@ -0,0 +1,59 @@
/* eslint-env node */
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",
// Vue 相关规则
"vue/multi-word-component-names": "off",
},
settings: {
"import/resolver": {
alias: {
map: [
["@", "./src"],
],
extensions: [".js", ".jsx", ".vue"],
},
},
},
},
];

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,7 @@
"test:run": "vitest run",
"test:coverage": "vitest run --coverage",
"test:ui": "vitest --ui",
"prepare": "cd .. && husky openhis-ui-vue3/.husky"
"lint": "eslint . --ext .js,.vue src/"
},
"repository": {
"type": "git",
@@ -68,6 +68,11 @@
"@vitejs/plugin-vue": "4.5.0",
"@vue/compiler-sfc": "3.3.9",
"@vue/test-utils": "^2.4.6",
"eslint": "^9.39.4",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-vue": "^10.9.0",
"globals": "^17.5.0",
"happy-dom": "^20.8.3",
"jsdom": "^28.1.0",
"pg": "^8.18.0",
@@ -81,14 +86,5 @@
"vite-plugin-vue-mcp": "^0.3.2",
"vitest": "^4.0.18",
"vue-tsc": "^3.1.8"
},
"lint-staged": {
"openhis-ui-vue3/**/*.{js,vue,ts}": [
"cd openhis-ui-vue3 && npm run lint -- --fix",
"cd openhis-ui-vue3 && npm run build:dev"
],
"**/*.{js,vue,ts}": [
"echo \"文件变更已记录构建检查将在pre-commit中执行\""
]
}
}
}