eslint: template-curly-spacing rule exception
Tell us about your environment
Node version: v14.4.0 npm version: v6.14.4 Local ESLint version: v7.13.0 (Currently used)
What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using?
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Not exactly production ready code, but while testing something out I stumbled across a line of JS that breaks the template-curly-spacing rule:
const nonParameterArgs = this.context.module.controllerConstructor.args.filter(a => !this[`${a}Target`]?.selectedOptions[0]?.hasAttribute('data-parameter-id')).map(a => this[`${a}Argument`]);
What did you expect to happen? Not raise an exception
What actually happened? Please include the actual, raw output from ESLint. The linter broke
Offending line: https://github.com/eslint/eslint/blob/master/lib/rules/template-curly-spacing.js#L52
TypeError: Cannot read property 'value' of null
Occurred while linting /myrepo/app/javascript/controllers/plots/plot_controller.js:51
at checkSpacingBefore (/myrepo/node_modules/eslint/lib/rules/template-curly-spacing.js:52:24)
at TemplateElement (/myrepo/node_modules/eslint/lib/rules/template-curly-spacing.js:136:17)
at /myrepo/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/myrepo/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/myrepo/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
at NodeEventGenerator.applySelectors (/myrepo/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
at NodeEventGenerator.enterNode (/myrepo/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
at CodePathAnalyzer.enterNode (/myrepo/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
at /myrepo/node_modules/eslint/lib/linter/linter.js:952:32
error Command failed with exit code 2.
Are you willing to submit a pull request to fix this bug? Not right now, sorry
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (7 by maintainers)
Got a fix for this. Run the following npm commands to update the eslint packages manually(I think):
npm install --save-dev @babel/types@7.2.0 @babel/traverse@7.1.6npm dedupenpm uninstall --save-dev @babel/types @babel/traverseI don’t really know how it works, but it worked for me.
This worked for me as well.