no-extra-boolean-cast autofixer handles some Boolean() calls incorrectly #7977
Labels
accepted
There is consensus among the team that this change meets the criteria for inclusion
archived due to age
This issue has been archived; please open a new issue for any further discussion
bug
ESLint is working incorrectly
good first issue
Good for people who haven't worked on ESLint before
help wanted
The team would welcome a contribution from the community for this issue
rule
Relates to ESLint's core rules
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
I ran
eslint theFile.js --fix
on three different files:What did you expect to happen?
I expected the syntax of the files to be valid after autofixing
What actually happened? Please include the actual, raw output from ESLint.
In the first two files, the code was autofixed to
An error was thrown when running the command on the third file:
The first autofixed line is a syntax error, and the second autofixed line changes the behavior of the code (it no longer calls
bar()
).To fix this, I think we need to avoid doing an autofix for
no-extra-boolean-cast
in the following cases:Boolean
is called with more than one argumentBoolean
is called with a spread element as the first argumentBoolean
is called with no arguments. (Alternatively, we could just fix!Boolean()
totrue
.)The text was updated successfully, but these errors were encountered: