From d76eb6782501ba4a1e704751fb01df4203ac3031 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 14 Mar 2017 09:33:59 -0700 Subject: [PATCH] Convert 'no-reference' to use WalkContext (#2340) --- src/rules/noReferenceRule.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/rules/noReferenceRule.ts b/src/rules/noReferenceRule.ts index c23c0952cc0..52828010d99 100644 --- a/src/rules/noReferenceRule.ts +++ b/src/rules/noReferenceRule.ts @@ -38,14 +38,12 @@ export class Rule extends Lint.Rules.AbstractRule { public static FAILURE_STRING = " 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 { + for (const ref of ctx.sourceFile.referencedFiles) { + ctx.addFailure(ref.pos, ref.end, Rule.FAILURE_STRING); } }