Skip to content

build: make cross entrypoint rule an AbstractRule #18156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions tools/tslint-rules/noCrossEntryPointRelativeImportsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const BUILD_BAZEL_FILE = 'BUILD.bazel';
* unintentionally and could break module resolution since the folder structure
* changes in the Angular Package release output.
*/
export class Rule extends Lint.Rules.TypedRule {
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] {
export class Rule extends Lint.Rules.AbstractRule {
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithFunction(sourceFile, checkSourceFile, this.getOptions().ruleArguments);
}
}
Expand All @@ -31,7 +31,7 @@ function checkSourceFile(ctx: Lint.WalkContext<string[]>) {
return;
}

const visitNode = (node: ts.Node) => {
(function visitNode(node: ts.Node) {
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
if (!node.moduleSpecifier || !ts.isStringLiteralLike(node.moduleSpecifier) ||
!node.moduleSpecifier.text.startsWith('.')) {
Expand All @@ -54,9 +54,7 @@ function checkSourceFile(ctx: Lint.WalkContext<string[]>) {
return;
}
ts.forEachChild(node, visitNode);
};

ts.forEachChild(ctx.sourceFile, visitNode);
})(ctx.sourceFile);
}

/** Finds the closest Bazel build package for the given path. */
Expand Down