(node: ts.Node, ctx: WalkContext, options: RuleOptions)
| 62 | } |
| 63 | |
| 64 | function 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 | |
| 86 | function isNamedImportToDisallowedModule(node: ts.Node, disallowed: string[]): boolean { |
| 87 | if (!ts.isImportDeclaration(node) || node.importClause === undefined) { |
no test coverage detected