nest: eslint: Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
Here 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?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 22 (4 by maintainers)
Links to this issue
Commits related to this issue
- fix(eslint): Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. https://github.com/nestjs/nest/issues/4900 — committed to pan93412/ciscc-api by pan93412 3 years ago
- :rotating_light: ESLint : "parserOptions.project" 오류 해결 참고 링크 : https://github.com/nestjs/nest/issues/4900 — committed to m-dzn/react-component-dictionary by m-dzn 2 years ago
- build: use createDefaultProgram instead of project it was an issue in the whole project about the eslint can not find the `tsconfig.json` file, this solution could be a temporally, until we find a be... — committed to nl-design-system/utrecht by AliKdhim87 a year ago
- build: use createDefaultProgram instead of project it was an issue in the whole project about the eslint can not find the `tsconfig.json` file, this solution could be a temporally, until we find a be... — committed to nl-design-system/utrecht by AliKdhim87 a year ago
- build: use createDefaultProgram instead of project it was an issue in the whole project about the eslint can not find the `tsconfig.json` file, this solution could be a temporally, until we find a be... — committed to nl-design-system/utrecht by AliKdhim87 a year ago
- build: use createDefaultProgram instead of project it was an issue in the whole project about the eslint can not find the `tsconfig.json` file, this solution could be a temporally, until we find a be... — committed to nl-design-system/utrecht by AliKdhim87 a year ago
- build: use createDefaultProgram instead of project it was an issue in the whole project about the eslint can not find the `tsconfig.json` file, this solution could be a temporally, until we find a be... — committed to nl-design-system/utrecht by AliKdhim87 a year ago
In my opinion, NestJS creates an erroneous configuration.
The file
.eslintrc.jsshoud look like this:By adding
ignorePatterns: ['.eslintrc.js']eslint is told to ignore the.eslintrc.jsfile itself.Otherwise it results in an error, because eslint tries to lint the
.eslintrc.jsfile, even though it is not included in thetsconfig.jsonconfiguration.See also https://github.com/typescript-eslint/typescript-eslint/issues/967#issuecomment-530907956.
Adding
"createDefaultProgram": trueto the tsconfig, after doing https://github.com/nestjs/nest/issues/4900#issuecomment-669743374 fixed it for me.SO… all the fix was about
I had to change the extension of the
.eslintrc.jstots. Then it was resolved.You should install this dependencies
yarn add eslint-config-prettier eslint-plugin-prettier --devornpm install eslint-config-prettier eslint-plugin-prettier --save-devAnd replace extends object in .eslintrc by this“extends”: [ “plugin:@typescript-eslint/eslint-recommended”, “plugin:@typescript-eslint/recommended”, “prettier/@typescript-eslint”, “plugin:prettier/recommended” ]
After VsCode reload should work
@OlegBrony, looks like this happened because webstorm automatically tries to apply eslint to
.eslintrc.jsfile and parse it with typescript config (which is not working withjsfiles). You can safely ignore it.Does not worked for me
Solved by replacing filename from .eslintrc.js to .eslintrc and removing module.exports etc.