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

no-fallthrough failing on continue statement #1220

Closed
devangnegandhi opened this issue Sep 5, 2014 · 1 comment · Fixed by #1221
Closed

no-fallthrough failing on continue statement #1220

devangnegandhi opened this issue Sep 5, 2014 · 1 comment · Fixed by #1221
Labels
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

Comments

@devangnegandhi
Copy link

Take a look at the following code

var i;
for (i = 0; i < 1; i += 1) {
    switch (i) {
    case 1:
        continue;
    default:
        break;
    }
}

When I run eslint with the no-fallthrough rule turned on, I get the following error

test.js
  4:4  error  Expected a "break" statement before "default"  no-fallthrough

To fix the issue, I added a break; statement as recommended

var i;
for (i = 0; i < 1; i += 1) {
    switch (i) {
    case 1:
        continue;
        break;
    default:
        break;
    }
}

This time, I get another error:

test.js
  6:8  error  Found unexpected statement after a continue  no-unreachable

Although I can work around this by using a //falls through comment instead of the break;, the code is technically never falling through and the comment will be misleading in that case.

@michaelficarra
Copy link
Member

Working on this.

@nzakas nzakas added bug labels Sep 5, 2014
michaelficarra added a commit to michaelficarra/eslint that referenced this issue Sep 5, 2014
nzakas added a commit that referenced this issue Sep 5, 2014
Fix: no-fallthrough: continue affects control flow, too (fixes #1220)
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants