`func-call-spacing` fix creating bugs
See original GitHub issueEdit: 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?
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
func-call-spacing reports "unexpected newline", when there is ...
error Unexpected newline between function name and paren func-call-spacing. Are you willing to submit a pull request to fix this bug?
Read more >func-call-spacing - Pluggable JavaScript Linter - ESLint
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >func-call-spacing | typescript-eslint
Require or disallow spacing between function identifiers and their invocations. ... This rule extends the base eslint/func-call-spacing rule.
Read more >Firmware Bugs « State Space - Embedded Gurus
Here, I call the function assert_failed(), commonly used to handle failing assertions. assert_failed() can be a standard C function, but it should not...
Read more >Spaces between function name and opening parenthesis ...
There should be no space between the name of a function and the ( (left parenthesis) of its parameter list, unless case of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll work on a fix, unless someone’s already on it.
I think the autofix was not wrong since it does not change semantics. But surely this is similar to
no-useless-escape
rule’s case as @platinumazure mentioned. I agree that people expectfunc-call-spacing
to not fix it automatically if the spaces include line terminators.