Skip to content

Commit

Permalink
Fixes palantir#372 -- remove additonal false positives
Browse files Browse the repository at this point in the history
Skip method signatures and catch clause variable declarations
  • Loading branch information
gscshoyru committed Apr 21, 2015
1 parent 4201cb6 commit e363b02
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/rules/noDuplicateVariableRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class NoDuplicateVariableWalker extends Lint.ScopeAwareRuleWalker<ScopeInfo> {
// don't call super, we don't want to walk the inside of type nodes
}

public visitMethodSignature(node: ts.SignatureDeclaration): void {
// don't call super, we don't want to walk method signatures either
}

public visitCatchClause(node: ts.CatchClause): void {
// don't visit the catch clause variable declaration, just visit the block
// the catch clause variable declaration has its own special scoping rules
this.visitBlock(node.block);
}

public visitVariableDeclaration(node: ts.VariableDeclaration): void {
var propertyName = <ts.Identifier> node.name;
var variableName = propertyName.text;
Expand Down
20 changes: 20 additions & 0 deletions test/files/rules/duplicate-variable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,23 @@ var dependents: {[vertex: string]: any};

function blah(arg1: {[key: string]: any, arg2: {[key:string]: any}) {
}

export interface IClipboard {
copy(key: string, state: any): void;
paste(key: string): any;
findMaxOrMin(values: any[], defaultValue: number, operation: (...values: any[]) => number)
}

try {
//
} catch (e) {
e.blah();
//
}

try {
//
} catch (e) {
e.blah();
//
}

0 comments on commit e363b02

Please sign in to comment.