【已解决】在 Vite 项目中使用 eslint-config-ali 时遇到的解析错误

错误还原

  1. 搭建 Vite 项目
bash 复制代码
pnpm create vite my-vue-app --template vue-ts
  1. 安装 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
  1. 配置 .eslintrc
json 复制代码
{
  "extends": ["eslint-config-ali/typescript/vue"]
}
  1. 安装并启用 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:

解决办法

修改 .eslintrcparserOptions.project 配置,增加 tsconfig.node.json

json 复制代码
{
  "extends": ["eslint-config-ali/typescript/vue"],
  "parserOptions": {
    "project": ["tsconfig.json", "tsconfig.node.json"]
  }
}
相关推荐
Vicky&James7 分钟前
WPF到Web的无缝过渡:英雄联盟客户端项目OpenSilver迁移实战
前端·wpf
m0_7482336410 分钟前
RabbitMQ 进阶
android·前端·后端
不想有bug的小菜鸟19 分钟前
vue3使用iframe全屏展示pdf效果
前端·pdf
m0_7482386319 分钟前
Spring Boot项目接收前端参数的11种方式
前端·spring boot·后端
u01005596020 分钟前
前端代理,解决跨域问题讲解
前端
quitv25 分钟前
react脚手架配置别名
前端·javascript·react.js
m0_5287238134 分钟前
前端如何进行性能优化
前端·性能优化
化作繁星35 分钟前
在 Vue 3 中,如何缓存和复用动态组件
前端·vue.js·缓存
一粒沙-1 小时前
iOS 将GIF图分享至微信
前端·ios
graywen1 小时前
从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
前端