Skip to content

Commit

Permalink
fix(unbound): Validate only functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Jul 1, 2018
1 parent 804ad3c commit 251a075
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions source/rules/rxjsNoUnboundMethodsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ class Walker extends Lint.ProgramAwareRuleWalker {
}

private validateArgs(args: ts.NodeArray<ts.Expression>): void {

const typeChecker = this.getTypeChecker();

args.forEach(arg => {
if (tsutils.isPropertyAccessExpression(arg)) {
const thisKeywords = tsquery(arg, `ThisKeyword`);
if (thisKeywords.length) {
this.addFailureAtNode(arg, Rule.FAILURE_STRING);
const type = typeChecker.getTypeAtLocation(arg);
if (type.getCallSignatures().length > 0) {
const thisKeywords = tsquery(arg, `ThisKeyword`);
if (thisKeywords.length > 0) {
this.addFailureAtNode(arg, Rule.FAILURE_STRING);
}
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/v6/fixtures/no-unbound-methods/static/fixture.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Something {
static error(error: any): void {}
static map<T>(t: T): T { return t; }
static next<T>(t: T): void {}
tearDown(): void {}
static tearDown(): void {}
}

[no-unbound-methods]: Unbound methods are forbidden

0 comments on commit 251a075

Please sign in to comment.