// ESLint 9 flat config:vue3 + TS strict 配套(README §3.5:any 全面禁用) import js from '@eslint/js'; import tseslint from 'typescript-eslint'; import pluginVue from 'eslint-plugin-vue'; import prettier from 'eslint-config-prettier'; /** * 框架运行时模块名(业务代码禁"值 import",见 README §3.3-1)。 * * 精确边界: * - `import type { Ref } from 'vue'` 属**类型导入**(编译期擦除、零运行时足迹)—— * 不在限内,TS strict 下类型必须有来源,type import 是唯一合规写法; * - `import { ref } from 'vue'` 属**值导入**——会把框架运行时打包进 dist,必须拦。 * * 实现用 `no-restricted-syntax`(而非 no-restricted-imports,后者不区分 type/value): * `importKind` 属性仅 @typescript-eslint/parser 产生: * import type {...} → 'type'(放行) | import {...} → 'value'(拦截) */ const FRAMEWORK_MODULE_SELECTOR = ":is([source.value='vue'],[source.value='vue-router'],[source.value='pinia'],[source.value='axios'],[source.value='element-plus'])"; export default [ js.configs.recommended, ...tseslint.configs.recommended, ...pluginVue.configs['flat/essential'], prettier, { // shims/ 由 scripts/gen-shims.cjs 生成(含逐行 eslint-disable 注释,引用了未安装的 import 插件),不 lint // scripts/ 是 Node CJS 工具脚本(require / __dirname),不属于浏览器 TS 产物,不 lint ignores: ['dist/**', 'vendor/**', 'node_modules/**', 'shims/**', 'scripts/**', '**/*.cjs'], }, { // .vue:SFC 内