是什么意思“为@ typescript-eslint / parser设置了“解析错误:” parserOptions.project“ IntelliJ IDEs系列中出现错误?

问题描述

当我打开.vue文件时,IntelliJ IDEA中出现以下错误

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: XX\XX\CurrentFile.vue.
The file must be included in at least one of the projects provided.

enter image description here

如果您能教我解决方案,我当然会很高兴,但首先我知道它的意思,为什么会出现。

我怀疑这是某种错误错误消息。实验上知道什么:

  1. 有时会出现-否。
  2. 总是在更新时出现。
  3. 如果要从控制台针对某些eslint文件运行.vue,则eslint将正确完成执行。因此,似乎这不是犯错误的行为。

我的Eslint配置(YAML):

parser: vue-eslint-parser
parserOptions:
  parser: "@typescript-eslint/parser"
  sourceType: module
  project: tsconfig.json
  tsconfigRootDir: ./
  extraFileExtensions: [ ".vue" ]

env:
  es6: true
  browser: true
  node: true

plugins:
  - "@typescript-eslint"
  - vue


rules:
  // ...

TypeScript设置:

{
  "compilerOptions": {

    "target": "ES2017","module": "Commonjs","moduleResolution": "node","esModuleInterop": true,"allowSyntheticDefaultImports": true,"sourceMap": true,"experimentalDecorators": true,"skipLibCheck": true,"strict": true,"noUnusedParameters": true,"noImplicitReturns": true,"importsNotUsedAsValues": "preserve",// Limitation of the transpileOnly mode from ts-loader for .vue files.

    "baseUrl": "./","paths": {
      // ...
    }
  }
}

解决方法

您需要将文件添加到tsconfig中的include数组中:

"include": [
  "path/to/src/**/*"
]

来源:GithubStackOverflow