eslint: Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
See original GitHub issueHere is the fix
https://github.com/nestjs/nest/issues/4900#issuecomment-669743374
Bug Report
I installed nest and start new project. and there is a problem with eslint: in .eslint.js I got error
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: .eslintrc.js.
The file must be included in at least one of the projects provided.
eslint in code also not working, and command npm run lint
doesn’t find any problems.
Current behavior
Input Code
.eslintrc.js
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
project: 'tsconfig.json'
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
],
...
};
I didn’t change anything actually.
Environment
Nest version: 7.2.0
For Tooling issues:
- Node version: 13.10.1
- Platform: Linux mint
webstorm, npm 6.13.7.
is it reproduced or is it just me?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:22 (4 by maintainers)
Top Results From Across the Web
"parserOptions.project" has been set for @typescript-eslint ...
Parsing error : "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config: /Users/Dan/site ...
Read more >"parserOptions.project" has been set for @typescript-eslint ...
I have tried to change the include config as following, the error still be there. // 1. Error about js file { ...,...
Read more >Solve Typescript error "parserOptions.project" has been set for ...
Solve Typescript error "parserOptions.project" has been set for @typescript-eslint/parser. TL:DR: Add the file to the "include" array in your tsconfig.json.
Read more >IDE displays ESLint error "'parserOptions.project' has been set ...
IDE displays ESLint error "'parserOptions.project' has been set for '@typescript-eslint/parser'" in ".vue" files, but CLI works properly. image.png
Read more >How to fix VSC ESLint error "The file must be included in at ...
Parsing error : "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config: .eslintrc.js ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In my opinion, NestJS creates an erroneous configuration.
The file
.eslintrc.js
shoud look like this:By adding
ignorePatterns: ['.eslintrc.js']
eslint is told to ignore the.eslintrc.js
file itself.Otherwise it results in an error, because eslint tries to lint the
.eslintrc.js
file, even though it is not included in thetsconfig.json
configuration.See also https://github.com/typescript-eslint/typescript-eslint/issues/967#issuecomment-530907956.
Adding
"createDefaultProgram": true
to the tsconfig, after doing https://github.com/nestjs/nest/issues/4900#issuecomment-669743374 fixed it for me.