Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-switch-case-fall-through fails when continueing outer loop #509

Closed
dead-claudia opened this issue Jul 17, 2015 · 1 comment
Closed

no-switch-case-fall-through fails when continueing outer loop #509

dead-claudia opened this issue Jul 17, 2015 · 1 comment

Comments

@dead-claudia
Copy link

The following code fails to check, even though it clearly breaks from the switch-case:

loop:
while (condition) {
  switch (foo) {
  case bar:
    continue loop; // Line with errors
  default:
  }
}

The output I got (with every option except for that one above explicitly disabled):

tmp.ts[5, 19]: expected a 'break' before 'case'
tmp.ts[5, 19]: expected a 'break' before 'default'

It should be able to infer that it's clearly breaking a parent loop. This is with the current npm CLI version.

@leeavital
Copy link
Contributor

loop:
while (condition) {
  switch (foo) {
  case bar:
    return true; // Using return instead of break.
  default:
  }
}

Will pass, so adding continue is consistent with the rule.

@leeavital leeavital self-assigned this Jul 17, 2015
leeavital pushed a commit to leeavital/tslint that referenced this issue Jul 17, 2015
Fix palantir#509

NoSwitchCaseFallThroughWalker didn't realize continue statements
would break out of case block.
leeavital pushed a commit to leeavital/tslint that referenced this issue Jul 17, 2015
Fix palantir#509

NoSwitchCaseFallThroughWalker didn't realize continue statements
would break out of case block.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants