Skip to content

Commit

Permalink
unused variable rule shouldn't error on abstract methods with parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
DickvdBrink committed Sep 16, 2015
1 parent b86e310 commit e636eb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rules/noUnusedVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,13 @@ class NoUnusedVariablesWalker extends Lint.RuleWalker {
}
}

// skip checking parameter declarations for abstract methods
// They can't have a body so parameters are always unused
if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.AbstractKeyword)) {
this.skipParameterDeclaration = true;
}
super.visitMethodDeclaration(node);
this.skipParameterDeclaration = false;
}

private validateReferencesForVariable(name: string, position: number) {
Expand Down
4 changes: 4 additions & 0 deletions test/files/rules/nounusedvariable-parameter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ export class DestructuringTests {
return;
}
}

abstract class AbstractTest {
abstract foo(x);
}

0 comments on commit e636eb1

Please sign in to comment.