feat: 启用ESLint import规则 - 实时检测缺失导出,防止构建失败
This commit is contained in:
59
openhis-ui-vue3/eslint.config.js
Normal file
59
openhis-ui-vue3/eslint.config.js
Normal 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"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
1367
openhis-ui-vue3/package-lock.json
generated
1367
openhis-ui-vue3/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
|||||||
"test:run": "vitest run",
|
"test:run": "vitest run",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"test:ui": "vitest --ui",
|
"test:ui": "vitest --ui",
|
||||||
"prepare": "cd .. && husky openhis-ui-vue3/.husky"
|
"lint": "eslint . --ext .js,.vue src/"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -68,6 +68,11 @@
|
|||||||
"@vitejs/plugin-vue": "4.5.0",
|
"@vitejs/plugin-vue": "4.5.0",
|
||||||
"@vue/compiler-sfc": "3.3.9",
|
"@vue/compiler-sfc": "3.3.9",
|
||||||
"@vue/test-utils": "^2.4.6",
|
"@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",
|
"happy-dom": "^20.8.3",
|
||||||
"jsdom": "^28.1.0",
|
"jsdom": "^28.1.0",
|
||||||
"pg": "^8.18.0",
|
"pg": "^8.18.0",
|
||||||
@@ -81,14 +86,5 @@
|
|||||||
"vite-plugin-vue-mcp": "^0.3.2",
|
"vite-plugin-vue-mcp": "^0.3.2",
|
||||||
"vitest": "^4.0.18",
|
"vitest": "^4.0.18",
|
||||||
"vue-tsc": "^3.1.8"
|
"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中执行\""
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user