IMPORTANT: Please see UPDATE EDIT below which provides vital info
I keep getting this error showing in WebStorm 2021.2.2 (and other recent version) when using Angular:
ESLint: Cannot start language service process
See screenshot below
All .ts files report a similar error:
ESLint: Can not get result from language service
I tried to reproduce the problem by creating a new Angular project as follows:
ng new video-and-event-listeners-test --style=scss --routing=true
cd video-and-event-listeners-test/
ng add @angular-eslint/schematics --skip-confirmation
Initially everything worked OK but then the error returned and I cannot get rid of it. I have this error in every project (my projects all contain HLS files - see edit below). The ng lint
command just hangs. WebStorm just fails when you run a code inspection. Any ideas how to fix this please (without just disabling eslint)? Working without eslint is like digging a hole without a spade :(
Other versions of relevant software:
Node.js version 14.17.3
@angular/[email protected] (global install)
Angular 12.2.0
eslint 7.26.0 (installed by the above `ng add` command)
UPDATE EDIT:
OK I finally have a lead to go on! I have a directory as follows:
/src/assets/test-videos
This folder contains a bunch of HLS streaming videos. The HLS video chunks / segments have a .ts extension. A .ts extension is standard for HLS chunks but they seem to be causing ESLint to fail (since ESLint is linting .ts files). If I delete the entire folder, ESLint starts working!!! When I restore the folder, ESLint stops working.
So I tried to put the folder on ignore by adding a .eslintignore file in my project root with the contents:
src/assets/test-videos/**/*
/src/assets/test-videos/**/*
./src/assets/test-videos/**/*
src/assets/test-videos/*
/src/assets/test-videos/*
./src/assets/test-videos/*
src/assets/test-videos/
/src/assets/test-videos/
./src/assets/test-videos/
src/assets/test-videos
/src/assets/test-videos
./src/assets/test-videos
test-videos/**/*
Also I've added the following entry to .eslintrc.json
{
"root": true,
"ignorePatterns": [
"projects/**/*",
"src/assets/test-videos/**/*"
],
etc
}
But still no cigar. If the problem directory is not deleted ESLint just will not work! I suppose I could rename all the HLS files to use a non-standard extension but I'd rather not. Any ideas? Many thanks
CodePudding user response:
Looks as if the settings in .eslintignore
only affect errors reporting, whereas the settings in tsconfig.json
affect parsing. Adding "exclude": ["src/assets/test-videos"]
to the root tsconfig.json
should help.
I've verified that it works the same when running eslint in terminal with eslint src/**/*.*
- if the files are not excluded in tsconfig.json
, ESLint runs out of memory
CodePudding user response:
@lena helped me all day fixing this! Thanks so much @lena
Just wanted to add the final solution.
In .eslintrc.json
I added:
"ignorePatterns": [
"src/assets/test-videos/**/*"
]
In tsconfig.json
I added:
"exclude": [
"src/assets/test-videos",
"dist"
]
All of these changes were necessary for the fix. Removing any of them caused eslint to fail.
Note that the dist folder was generated after doing a build and also stopped eslint from working until I excluded it too.
One day lost but lessons learned!
BTW whilst this effected WebStorm it was not caused by WebStorm since ng lint
was failing too. As soon as ng lint
started working so did WebStorm.