MCPcopy Create free account
hub / github.com/angular/dev-infra / visitNode

Function visitNode

lint-rules/tslint/validateImportForEsmCjsInteropRule.ts:64–84  ·  view source on GitHub ↗
(node: ts.Node, ctx: WalkContext, options: RuleOptions)

Source from the content-addressed store, hash-verified

62}
63
64function visitNode(node: ts.Node, ctx: WalkContext, options: RuleOptions) {
65 if (options.incompatibleModules && ts.isImportDeclaration(node)) {
66 const specifier = node.moduleSpecifier as ts.StringLiteral;
67 const failureMsg = options.incompatibleModules[specifier.text];
68
69 if (failureMsg !== undefined) {
70 ctx.addFailureAtNode(node, failureMsg);
71 return;
72 }
73 }
74
75 if (options.noNamedExports && isNamedImportToDisallowedModule(node, options.noNamedExports)) {
76 ctx.addFailureAtNode(node, noNamedExportsError);
77 }
78
79 if (options.noDefaultExport && isDefaultImportToDisallowedModule(node, options.noDefaultExport)) {
80 ctx.addFailureAtNode(node, noDefaultExportError);
81 }
82
83 ts.forEachChild(node, (n) => visitNode(n, ctx, options));
84}
85
86function isNamedImportToDisallowedModule(node: ts.Node, disallowed: string[]): boolean {
87 if (!ts.isImportDeclaration(node) || node.importClause === undefined) {

Callers 1

applyMethod · 0.70

Tested by

no test coverage detected