@angular-eslint/schematics: missing "tsconfigRootDir" for nested projects in parserOptions
See original GitHub issueDescription
When adding ESLint with angular-eslint
to a “nested” project, (i.e. projects in the “projects” folder), IDEs (tested with VS Code and IntelliJ can’t recognize the .eslintrc.json.
yarn lint <project>
still works, but the highlighting in the IDE willl not.
Solution
Adding "tsconfigRootDir": "../../",
to “parserOptions” solves the issue:
...
"parserOptions": {
"tsconfigRootDir": "../../",
"project": [
"projects/testlib/tsconfig.lib.json",
"projects/testlib/tsconfig.spec.json"
],
"createDefaultProgram": true
},
...
Steps to reproduce
ng add testapp
ng g library testlib
ng add @angular-eslint/schematics
ng g @angular-eslint/schematics:add-eslint-to-project testapp
ng g @angular-eslint/schematics:add-eslint-to-project testlib
The configuration in projects/testlib/.eslintrc.json
will be generated like this:
{
"extends": "../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"projects/testlib/tsconfig.lib.json",
"projects/testlib/tsconfig.spec.json"
],
"createDefaultProgram": true
},
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "lib",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "lib",
"style": "kebab-case"
}
]
}
},
{
"files": [
"*.html"
],
"rules": {}
}
]
}
The IDEs will now display the following:
IntelliJ
VS Code
With "tsconfigRootDir": "../../",
applied, it works in both editors:
IntelliJ
VS Code
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10
Top Results From Across the Web
angular-eslint/schematics: missing "tsconfigRootDir" for ...
Description. When adding ESLint with angular-eslint to a "nested" project, (i.e. projects in the "projects" folder), IDEs (tested with VS ...
Read more >"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 >eslint parseroptions project | The AI Search Engine You Control
"parserOptions.project" has been set for @typescript-eslint/parser ... missing "tsconfigRootDir" for nested projects in parserOptions#609.
Read more >WebStorm incorrectly builds the path to eslint's parserOptions ...
What steps will reproduce the problem? Set up a project with Typescript files and tsconfig.json in the /server directory. Add .eslintrc.js file to...
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 >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 FreeTop 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
Top GitHub Comments
I also wasted my 4-5 hours trying to fix this issue with IntelliJ. Ultimately, I had to enable
Manual ESLint configuration
in IntelliJ withWorking directories
set to./
.@ChristophRSG I solve this issue by following the steps described by @prabh-62 on this issue link: https://github.com/angular-eslint/angular-eslint/issues/462#issuecomment-858073819.
Hopefully, this helps you and others.