angular-eslint: Crash when running ng lint
version: “0.0.1-alpha.23”
> cat /private/var/folders/qx/l6dzbht15fj_s89bxrv7x7740000gp/T/ng-JaEvnr/angular-errors.log
[error] TypeError: Cannot read property 'range' of undefined
at /path/to/angular_project/node_modules/@angular-eslint/eslint-plugin-template/dist/index.js:1:1353
at Array.map (<anonymous>)
at postprocess (/path/to/angular_project/node_modules/@angular-eslint/eslint-plugin-template/dist/index.js:1:1156)
at Linter._verifyWithProcessor (/path/to/angular_project/node_modules/eslint/lib/linter/linter.js:1311:16)
at Linter._verifyWithConfigArray (/path/to/angular_project/node_modules/eslint/lib/linter/linter.js:1248:25)
at Linter.verify (/path/to/angular_project/node_modules/eslint/lib/linter/linter.js:1210:25)
at Linter.verifyAndFix (/path/to/angular_project/node_modules/eslint/lib/linter/linter.js:1400:29)
at verifyText (/path/to/angular_project/node_modules/eslint/lib/cli-engine/cli-engine.js:230:48)
at CLIEngine.executeOnFiles (/path/to/angular_project/node_modules/eslint/lib/cli-engine/cli-engine.js:798:28)
at _lint (/path/to/angular_project/node_modules/@angular-eslint/builder/dist/index.js:1:4477)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (8 by maintainers)
Ha I always knew that quick prototyping work I did would stay in until it caused an actual issue. I’ll try and take a look later on, will likely make it AST based instead of string manipulation
I’m getting a similar error, eslint crashes on a component template. This is my .eslintrc.js:
@digeomel Thanks for sharing your config. I did not realize I needed to configure the
.component.html
rules separately from the.ts
rules, nor did I see anything documenting the existence ofoverrides
anywhere.Additionally, the repo doesn’t explain that we need to use
"@angular-eslint/template/banana-in-a-box"
in order to use that rule - I was trying justbanana-in-a-box
and got nothing.Also, I tried it as
"@angular-eslint/template/banana-in-a-box"
but didn’t realize we need to add the plugin["@angular-eslint/template"]
and the parser"@angular-eslint/template-parser"
. I didn’t know about the parser option at all!A valid config object is almost always helpful! I suggest the readme could have some of these things updated to reflect these small little “gotchas”. 😄
Released
v0.0.1-alpha.28
Thanks a lot for the detailed report! I did a quick investigation and looks like the issue happens due to “:”.
During the pre-processing of eslint-plugin-template the component decorator is parsed and the “:” is making the output of the parsing incomplete, triggering future errors.
The fix should be on this split (maybe use “String.prototype.match()” instead?): https://github.com/angular-eslint/angular-eslint/blob/266486e3c9870eb350aac9c7b41a7b8c7d9e5bbc/packages/eslint-plugin-template/src/processors.ts#L53
I don’t know if I will be able to work on it this weekend, so if anyone wants to take it, be free. If not I can check that later.