Skip to content

Commit

Permalink
Don't check declared vars in the unused-variable-rule
Browse files Browse the repository at this point in the history
  • Loading branch information
DickvdBrink committed May 14, 2015
1 parent b08678f commit 5ed5eb6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rules/noUnusedVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ class NoUnusedVariablesWalker extends Lint.RuleWalker {
this.skipParameterDeclaration = false;
}

// skip exported variables
// skip exported and declared variables
public visitVariableStatement(node: ts.VariableStatement): void {
if (this.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
if (this.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)
|| this.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) {
this.skipVariableDeclaration = true;
}

Expand Down
2 changes: 2 additions & 0 deletions test/files/rules/nounusedvariable-var.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ try {
} catch (e) {
// e is unused but that's still ok
}

declare var tmp: any;

0 comments on commit 5ed5eb6

Please sign in to comment.