Bug: no-useless-return triggers wrongly in switch
See original GitHub issueEnvironment
Node version: v16.15.0
npm version: v8.11.0
Local ESLint version: v8.17.0
Global ESLint version: Not found
Operating System: win32 10.0.19043
What parser are you using?
What did you do?
Configuration
'no-useless-return': ['error'],
function doot(blah) {
switch (blah) {
case something:
return;
case somethingElse:
doSomethingReal();
break;
}
}
What did you expect to happen?
The return statement to be kept.
What actually happened?
Return is removed, making the case bleed over to the other one.
Participation
- I am willing to submit a pull request for this issue.
Additional comments
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
The Most Common Nintendo Switch Problems and How to ...
If you've encountered a problem, follow our guide below and we'll have you playing your favorite Nintendo Switch games again in no time....
Read more >How do I check that a switch block is exhaustive in ...
You will get an error if your switch statement is non-exhaustive as there will be a case where nothing is returned.
Read more >How To Fix A Drifting Nintendo Switch Joy-Con Analog Stick
Several solutions to fix drift and put Joy back in the Con ... mechanism causes movement to register without any pressure being applied....
Read more >Bug descriptions — spotbugs 4.7.3 documentation
This class overrides equals(Object) , but does not override hashCode() , and inherits the implementation of hashCode() from java.lang.Object (which returns the ...
Read more >Common Causes of Slow IntraVLAN and InterVLAN ...
In the case of VLAN slowness, the problem most likely lies inside the switch (or multiple switches). If you diagnose the problem incorrectly ......
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 FreeTop 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
Top GitHub Comments
I agree. In the example from https://github.com/eslint/eslint/issues/16055#issuecomment-1166409950, the
no-useless-return
rule works as intended because it reports areturn;
statement that has no effect on the runtime behavior.Yes. That seems to be the intended behavior to me.