繁体   English   中英

'解析错误:已为@typescript-eslint/parser 设置了“parserOptions.project”是什么意思。 IntelliJ IDE 系列中的错误?

[英]What means 'Parsing error: “parserOptions.project” has been set for @typescript-eslint/parser.' error in IntelliJ IDEs family?

当我打开.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.

在此处输入图片说明

当然,如果你教我解决方案,我会很高兴,但首先我知道它意味着什么以及为什么会出现。

我怀疑这是某种错误或不准确的错误消息。 实验已知:

  1. 有时它会出现,有时 - 不。
  2. 更新 eslint 时总是出现。
  3. 如果从控制台为某些.vue文件运行eslint ,eslint 将正确完成执行。 所以看起来它不是 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:
  // ...

打字稿设置:

{
  "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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM