Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce final break #520

Closed
LinusU opened this issue May 13, 2016 · 2 comments

Comments

@LinusU
Copy link
Member

commented May 13, 2016

Would it make sense to enforce a break even in the last case statement within a switch? I think it's a good practice so that the next guy doesn't forget to add one in.

switch (_) {
  case 1:
    console.log('Hello')
    break
  case 2:
    console.log('world!')
    // standard would enforce a break here
}
@feross

This comment has been minimized.

Copy link
Member

commented May 13, 2016

Sure I'm fine with that. But I don't think ESLint has a rule for it, so it's probably not worth the effort. If you get a rule or option for this into ESLint, happy to enable it in the next major version if there's not too much breakage :)

But it's really not a risk if you're using standard since it will warn about "fall through" when the next programmer adds a new case and forgets to add break.

@feross

This comment has been minimized.

Copy link
Member

commented May 13, 2016

Going to close this since there's no ESLint rule for it. But feel free to send a PR when/if you get it added.

@feross feross closed this May 13, 2016

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.