indent
throws TypeError: Cannot read property 'loc' of undefined #14538
Description
Tell us about your environment
- ESLint Version: v7.25.0
- Node Version: v14.16.0
- npm Version: 6.14.11 (Yarn 1.22.4)
- Operating System: macOS Catalina 10.15.7
What parser (default, @babel/eslint-parser
, @typescript-eslint/parser
, etc.) are you using?
I'm using @typescript-eslint/parser
. The problem does not occur when using the default parser.
Please show your full configuration:
The problem can be reproduced with this minimal configuration:
{
"parser": "@typescript-eslint/parser",
"rules": {
"indent": "error"
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
The problem occurs whenever there is an incomplete variable declaration. It's sufficient to write var
or const
without a following identifier.
var
This happens all the time when programming in VS code: Each time I'm in the middle of declaring a new variable, an error toast pops up.
Command:
eslint test.ts
What did you expect to happen?
ESLint should run normally and output a parsing error, as it does when using the default parser.
What actually happened? Please copy-paste the actual, raw output from ESLint.
Oops! Something went wrong! :(
ESLint: 7.25.0
TypeError: Cannot read property 'loc' of undefined
Occurred while linting /Users/wolf/dev/crossmip/test.ts:1
at Object.VariableDeclaration [as listener] (/Users/wolf/dev/crossmip/node_modules/eslint/lib/rules/indent.js:1423:69)
at /Users/wolf/dev/crossmip/node_modules/eslint/lib/rules/indent.js:1635:55
at Array.forEach (<anonymous>)
at Program:exit (/Users/wolf/dev/crossmip/node_modules/eslint/lib/rules/indent.js:1635:26)
at /Users/wolf/dev/crossmip/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/Users/wolf/dev/crossmip/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/Users/wolf/dev/crossmip/node_modules/eslint/lib/linter/node-event-generator.js:256:26)
at NodeEventGenerator.applySelectors (/Users/wolf/dev/crossmip/node_modules/eslint/lib/linter/node-event-generator.js:285:22)
at NodeEventGenerator.leaveNode (/Users/wolf/dev/crossmip/node_modules/eslint/lib/linter/node-event-generator.js:308:14)
Steps to reproduce this issue:
- Use the minimal configuration given above
- Run ESLint on a .ts file containing only
var
Are you willing to submit a pull request to fix this bug?
Yes, the fix should be trivial.
Metadata
Assignees
Labels
Type
Projects
Status
Complete
Activity