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

Commit

Permalink
Convert 'no-reference' to use WalkContext (#2340)
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-hanson authored and nchen63 committed Mar 14, 2017
1 parent 718b63e commit d76eb67
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/rules/noReferenceRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = "<reference> is not allowed, use imports";

public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(new NoReferenceWalker(sourceFile, this.getOptions()));
return this.applyWithFunction(sourceFile, walk);
}
}

class NoReferenceWalker extends Lint.RuleWalker {
public visitSourceFile(node: ts.SourceFile) {
for (const ref of node.referencedFiles) {
this.addFailureFromStartToEnd(ref.pos, ref.end, Rule.FAILURE_STRING);
}
function walk(ctx: Lint.WalkContext<void>): void {
for (const ref of ctx.sourceFile.referencedFiles) {
ctx.addFailure(ref.pos, ref.end, Rule.FAILURE_STRING);
}
}

0 comments on commit d76eb67

Please sign in to comment.