本文主要是介绍【已解决】在 Vite 项目中使用 eslint-config-ali 时遇到的解析错误,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
错误还原
- 搭建
Vite
项目
pnpm create vite my-vue-app --template vue-ts
- 安装
eslint-config-ali
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
{"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
{"extends": ["eslint-config-ali/typescript/vue"],"parserOptions": {"project": ["tsconfig.json", "tsconfig.node.json"]}
}
这篇关于【已解决】在 Vite 项目中使用 eslint-config-ali 时遇到的解析错误的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!