“ parserOptions.project”已为@ typescript-eslint / parser设置 [英] "parserOptions.project" has been set for @typescript-eslint/parser

查看:3927
本文介绍了“ parserOptions.project”已为@ typescript-eslint / parser设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用-template typescript

我删除了 template 目录,它是样板的一部分。

I deleted the template directory which came as part of the boilerplate.

然后我继续添加ESLint:

I then proceeded to add ESLint:

module.exports = {
  parser: "@typescript-eslint/parser",
  plugins: ["@typescript-eslint"],
  extends: ["airbnb-typescript-prettier"]
};

但是,当我打开 babel.config.js 时,我出现此错误

However, when I open babel.config.js, I get this error


解析错误: parserOptions.project已为@ typescript-eslint / parser设置。
文件与您的项目配置不匹配: /Users/Dan/site/babel.config.js
该文件必须至少包含在所提供的至少一个项目中。eslint

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config: /Users/Dan/site/babel.config.js. The file must be included in at least one of the projects provided.eslint


推荐答案

您可以创建一个单独的TypeScript配置文件( tsconfig.eslint.json ),用于 eslint 配置。该文件扩展了 tsconfig 的配置,并为必须删除的文件设置了 include 键。

You can create a separate TypeScript config file (tsconfig.eslint.json) intended for eslint configuration. That file extends tsconfig configuration and setups include key for files that have to be linted.

.eslint.js

// ...
parserOptions: {
  // ...
  project: "./tsconfig.eslint.json",
  // ...
},
// ...

tsconfig.eslint.json

{
  "extends": "./tsconfig.json",
  "include": [
    // ...
    "babel.config.js"
  ]
}

或者如果要忽略它,可以将其放入 .eslintignore

Or if you want to ignore it, you can put it into .eslintignore.

.eslintignore

// ...
babel.config.js

这篇关于“ parserOptions.project”已为@ typescript-eslint / parser设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆