question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: no-useless-return triggers wrongly in switch

See original GitHub issue

Environment

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?

@babel/eslint-parser

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:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Jun 27, 2022

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 a return; statement that has no effect on the runtime behavior.

0reactions
snitin315commented, Jun 26, 2022

Alright, I’m guessing it was only issue when writing up the structure before any code, as removing the function call makes it trigger as reported, which I guess technically is right for the error?

Yes. That seems to be the intended behavior to me.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found