Skip to content

Commit 1d9033e

Browse files
crisbetoandrewseguin
authored andcommitted
build: make cross entrypoint rule an AbstractRule (#18156)
Currently the cross entrypoint import rule us a `TypedRule` which means that it might use the type checker and it won't work in vscode. Since it doesn't actually use the type checker, these changes turn it into an `AbstractRule`.
1 parent 203c8d6 commit 1d9033e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tools/tslint-rules/noCrossEntryPointRelativeImportsRule.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const BUILD_BAZEL_FILE = 'BUILD.bazel';
1313
* unintentionally and could break module resolution since the folder structure
1414
* changes in the Angular Package release output.
1515
*/
16-
export class Rule extends Lint.Rules.TypedRule {
17-
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] {
16+
export class Rule extends Lint.Rules.AbstractRule {
17+
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
1818
return this.applyWithFunction(sourceFile, checkSourceFile, this.getOptions().ruleArguments);
1919
}
2020
}
@@ -31,7 +31,7 @@ function checkSourceFile(ctx: Lint.WalkContext<string[]>) {
3131
return;
3232
}
3333

34-
const visitNode = (node: ts.Node) => {
34+
(function visitNode(node: ts.Node) {
3535
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
3636
if (!node.moduleSpecifier || !ts.isStringLiteralLike(node.moduleSpecifier) ||
3737
!node.moduleSpecifier.text.startsWith('.')) {
@@ -54,9 +54,7 @@ function checkSourceFile(ctx: Lint.WalkContext<string[]>) {
5454
return;
5555
}
5656
ts.forEachChild(node, visitNode);
57-
};
58-
59-
ts.forEachChild(ctx.sourceFile, visitNode);
57+
})(ctx.sourceFile);
6058
}
6159

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

0 commit comments

Comments
 (0)