Skip to content

Commit

Permalink
fixes palantir#17
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinr committed Aug 22, 2013
1 parent 298e85d commit d8e78ac
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bin/tslint-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27623,6 +27623,18 @@ var Lint;
this.hasReturned = false;
};

UnreachableWalker.prototype.visitCaseSwitchClause = function (node) {
this.hasReturned = false;
_super.prototype.visitCaseSwitchClause.call(this, node);
this.hasReturned = false;
};

UnreachableWalker.prototype.visitDefaultSwitchClause = function (node) {
this.hasReturned = false;
_super.prototype.visitDefaultSwitchClause.call(this, node);
this.hasReturned = false;
};

UnreachableWalker.prototype.visitBreakStatement = function (node) {
_super.prototype.visitBreakStatement.call(this, node);
this.hasReturned = true;
Expand Down
12 changes: 12 additions & 0 deletions lib/tslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -27623,6 +27623,18 @@ var Lint;
this.hasReturned = false;
};

UnreachableWalker.prototype.visitCaseSwitchClause = function (node) {
this.hasReturned = false;
_super.prototype.visitCaseSwitchClause.call(this, node);
this.hasReturned = false;
};

UnreachableWalker.prototype.visitDefaultSwitchClause = function (node) {
this.hasReturned = false;
_super.prototype.visitDefaultSwitchClause.call(this, node);
this.hasReturned = false;
};

UnreachableWalker.prototype.visitBreakStatement = function (node) {
_super.prototype.visitBreakStatement.call(this, node);
this.hasReturned = true;
Expand Down
12 changes: 12 additions & 0 deletions src/rules/noUnreachableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ module Lint.Rules {
this.hasReturned = false;
}

public visitCaseSwitchClause(node: TypeScript.CaseSwitchClauseSyntax): void {
this.hasReturned = false;
super.visitCaseSwitchClause(node);
this.hasReturned = false;
}

public visitDefaultSwitchClause(node: TypeScript.DefaultSwitchClauseSyntax): void {
this.hasReturned = false;
super.visitDefaultSwitchClause(node);
this.hasReturned = false;
}

public visitBreakStatement(node: TypeScript.BreakStatementSyntax): void {
super.visitBreakStatement(node);
this.hasReturned = true;
Expand Down
12 changes: 12 additions & 0 deletions test/files/rules/nounreachable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ var f2 = () => {

return 123;
};

switch (x) {
case 1:
i = 2;
break;
case 2:
i = 3;
break;
default:
i = 4;
break;
}

0 comments on commit d8e78ac

Please sign in to comment.