eslint: `func-call-spacing` fix creating bugs
Edit: fix post to reflect real bug.
In the latest ESLint (v3.12.2), the func-call-spacing
fix is really unhelpful for multiline call expressions (overlap with no-unexpected-multiline
), especially when going without semicolons.
// Short snippet
this.cancelled.add(request)
this.decrement(request)
(0, request.reject)(new api.Cancel())
These are likely meant to be separate statements, with the below being (99.99% of the time) what was meant:
// Short snippet
this.cancelled.add(request)
this.decrement(request)
;(0, request.reject)(new api.Cancel())
Instead, func-call-spacing
very unhelpfully fixes it to this, leading to runtime errors nearly every time in practice:
// Short snippet
this.cancelled.add(request)
this.decrement(request)(0, request.reject)(new api.Cancel())
Here’s the same issue, but with trailing semicolons:
Input:
// Short snippet
this.cancelled.add(request);
this.decrement(request)
(0, request.reject)(new api.Cancel());
Meant:
// Short snippet
this.cancelled.add(request);
this.decrement(request);
(0, request.reject)(new api.Cancel());
“Fixed”:
// Short snippet
this.cancelled.add(request);
this.decrement(request)(0, request.reject)(new api.Cancel());
Any chance this could be fixed to be a little less over-zealous?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (7 by maintainers)
Commits related to this issue
- Fix: func-call-spacing "never" doesn't fix w/ line breaks (fixes #7787) — committed to eslint/eslint by platinumazure 8 years ago
I’ll work on a fix, unless someone’s already on it.