diff --git a/healthlink-his-ui/eslint.config.js b/healthlink-his-ui/eslint.config.js index ae05be5af..1361781dd 100755 --- a/healthlink-his-ui/eslint.config.js +++ b/healthlink-his-ui/eslint.config.js @@ -1,8 +1,12 @@ /* eslint-env node */ +import path from "node:path"; +import { fileURLToPath } from "node:url"; import globals from "globals"; import pluginVue from "eslint-plugin-vue"; import parserVue from "vue-eslint-parser"; -import importPlugin from "eslint-plugin-import"; +import importPlugin, { createNodeResolver } from "eslint-plugin-import-x"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); export default [ { @@ -29,31 +33,31 @@ export default [ }, plugins: { - import: importPlugin, + "import-x": importPlugin, }, rules: { // 确保导入的模块实际存在(核心规则,防止构建失败) - "import/no-unresolved": "error", + "import-x/no-unresolved": "error", // 确保导入的命名导出实际存在 - "import/named": "error", + "import-x/named": "error", // 确保默认导出存在 - "import/default": "error", + "import-x/default": "error", // 确保命名空间导出存在 - "import/namespace": "error", + "import-x/namespace": "error", // Vue 相关规则 "vue/multi-word-component-names": "off", }, settings: { - "import/resolver": { - alias: { - map: [ - ["@", "./src"], - ], - extensions: [".js", ".jsx", ".vue"], - }, - }, + "import-x/resolver-next": [ + createNodeResolver({ + alias: { + "@": [path.join(__dirname, "src")], + }, + extensions: [".mjs", ".cjs", ".js", ".jsx", ".vue", ".json", ".node"], + }), + ], }, }, ]; diff --git a/healthlink-his-ui/package.json b/healthlink-his-ui/package.json index 9a1420d22..555adb5a4 100755 --- a/healthlink-his-ui/package.json +++ b/healthlink-his-ui/package.json @@ -75,8 +75,7 @@ "@vitejs/plugin-vue": "^5.2.4", "@vue/test-utils": "^2.4.6", "eslint": "^10.4.1", - "eslint-import-resolver-alias": "^1.1.2", - "eslint-plugin-import": "^2.32.0", + "eslint-plugin-import-x": "^4.16.1", "eslint-plugin-vue": "^10.9.1", "globals": "^17.5.0", "happy-dom": "^20.8.3",