no-useless-return
removes return statements in unreachable code
#11647
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
rule
Relates to ESLint's core rules
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
ESLint.org/demo default
Please show your full configuration:
This eslint.org/demo configuration (configured with just the
no-useless-return
rule)What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Using eslint.org/demo link above
I added a
throw
statement to the top of my function to aid debugging, and the critical return statement from later in the code was dropped which I only discovered after removing thethrow
statement and strange errors occurring.What did you expect to happen?
return;
statement should be flagged in unreachable code if and only if it would be flagged in equivalent reachable code. (At least that's how I read the comment in the source code.)If we were to remove the
throw
line, thereturn;
statement would not be flagged; therefore it should not be flagged with thethrow
statement present.What actually happened? Please include the actual, raw output from ESLint.
5:5 Unnecessary return statement.
and fixed code removes thereturn
statement. (See eslint.org/demo link)Are you willing to submit a pull request to fix this bug?
This is currently beyond my ESLint skillset.
The text was updated successfully, but these errors were encountered: