Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

When I open .vue file, below error appears in my 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

Of course I will be glad if you teach me the solution, but first what I know what it means and WHY it appears.

I suspect that it is a some kind of bug, or inaccurate error message. Experimentally known what:

  1. Sometimes it appears, sometimes - no.
  2. It always appears when update eslint.
  3. If to run eslint from console for some .vue file, eslint will finish the execution correctly. So seems like it is no eslint bug.

My Eslint config (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 settings:

{
  "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": {
      // ...
    }
  }
}

like image 823
Takeshi Tokugawa YD Avatar asked Sep 14 '20 06:09

Takeshi Tokugawa YD


People also ask

How do you fix parsing error parserOptions project has been set for TypeScript Eslint parser?

The error 'Parsing error: "parserOptions. project" has been set for @typescript-eslint/parser' occurs when we try to lint files that aren't included in our TypeScript project. To solve the error, add the files in which you get the error to your . eslintignore file.

What does TypeScript Eslint parser do?

This option allows you to programmatically provide an array of one or more instances of a TypeScript Program object that will provide type information to rules.


1 Answers

You need to add your files to the include array in your tsconfig:

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

Source: Github and StackOverflow

like image 193
gbalduzzi Avatar answered Sep 23 '22 10:09

gbalduzzi