(path, parentClassName)
| 101 | // --------------------------------------------------------------------------- |
| 102 | // Finds alias for React.Component if used as named import. |
| 103 | const findReactComponentNameByParent = (path, parentClassName) => { |
| 104 | const reactImportDeclaration = path |
| 105 | .find(j.ImportDeclaration, { |
| 106 | type: 'ImportDeclaration', |
| 107 | source: { |
| 108 | type: 'Literal', |
| 109 | }, |
| 110 | }) |
| 111 | .filter(importDeclaration => hasReact(path)); |
| 112 | |
| 113 | const componentImportSpecifier = reactImportDeclaration |
| 114 | .find(j.ImportSpecifier, { |
| 115 | type: 'ImportSpecifier', |
| 116 | imported: { |
| 117 | type: 'Identifier', |
| 118 | name: parentClassName, |
| 119 | }, |
| 120 | }).at(0); |
| 121 | |
| 122 | const paths = componentImportSpecifier.paths(); |
| 123 | return paths.length |
| 124 | ? paths[0].value.local.name |
| 125 | : undefined; |
| 126 | }; |
| 127 | |
| 128 | |
| 129 | const findReactES6ClassDeclarationByParent = (path, parentClassName) => { |
no test coverage detected