错误还原
- 搭建
Vite
项目
bash
pnpm create vite my-vue-app --template vue-ts
- 安装
eslint-config-ali
bash
pnpm i -D eslint-config-ali @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import eslint-import-resolver-typescript vue-eslint-parser eslint-plugin-vue
- 配置
.eslintrc
json
{
"extends": ["eslint-config-ali/typescript/vue"]
}
- 安装并启用 VSCode 插件 ESLint
报错信息
查看 vite.config.ts
发现出错了,在第 1 行开始处的位置:
Parsing error: ESLint was configured to run on <tsconfigRootDir>/vite.config.ts
using parserOptions.project
: /tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
解决办法
修改 .eslintrc
的 parserOptions.project
配置,增加 tsconfig.node.json
json
{
"extends": ["eslint-config-ali/typescript/vue"],
"parserOptions": {
"project": ["tsconfig.json", "tsconfig.node.json"]
}
}