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

Commit

Permalink
Skip checking declared functions for no-unused-variable (fixes #434)
Browse files Browse the repository at this point in the history
- also update tsconfig project files
  • Loading branch information
adidahiya committed Jun 16, 2015
1 parent 2c95a8b commit b03e959
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rules/noUnusedVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ class NoUnusedVariablesWalker extends Lint.RuleWalker {
this.skipParameterDeclaration = false;
}

// check function declarations (skipping exports)
// skip exported and declared functions
public visitFunctionDeclaration(node: ts.FunctionDeclaration): void {
var variableName = node.name.text;

if (!Lint.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
if (!Lint.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword, ts.SyntaxKind.DeclareKeyword)) {
this.validateReferencesForVariable(variableName, node.name.getStart());
}

Expand Down
1 change: 1 addition & 0 deletions src/rules/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"./quotemarkRule.ts",
"./radixRule.ts",
"./semicolonRule.ts",
"./sortObjectLiteralKeysRule.ts",
"./switchDefaultRule.ts",
"./tripleEqualsRule.ts",
"./typedefRule.ts",
Expand Down
2 changes: 2 additions & 0 deletions test/files/rules/nounusedvariable-function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ function func3() {
export function func4() {
return func1(2, 3);
}

declare function func5(): any;
2 changes: 2 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@
"./rules/noUnusedExpressionRuleTests.ts",
"./rules/noUnusedVariableRuleTests.ts",
"./rules/noUseBeforeDeclareRuleTests.ts",
"./rules/noVarKeywordRuleTests.ts",
"./rules/noVarRequiresRuleTests.ts",
"./rules/oneLineRuleTests.ts",
"./rules/quotemarkRuleTests.ts",
"./rules/radixRuleTests.ts",
"./rules/semicolonRuleTests.ts",
"./rules/sortObjectLiteralKeysRuleTests.ts",
"./rules/switchDefaultRuleTests.ts",
"./rules/tripleEqualsRuleTests.ts",
"./rules/typedefRuleTests.ts",
Expand Down

0 comments on commit b03e959

Please sign in to comment.