| 24 | // --------------------------------------------------------------------------- |
| 25 | // Checks if the file requires a certain module |
| 26 | const hasModule = (path, module) => |
| 27 | path |
| 28 | .findVariableDeclarators() |
| 29 | .filter(j.filters.VariableDeclarator.requiresModule(module)) |
| 30 | .size() === 1 || |
| 31 | path |
| 32 | .find(j.ImportDeclaration, { |
| 33 | type: 'ImportDeclaration', |
| 34 | source: { |
| 35 | type: 'Literal', |
| 36 | }, |
| 37 | }) |
| 38 | .filter(declarator => declarator.value.source.value === module) |
| 39 | .size() === 1; |
| 40 | |
| 41 | const hasReact = path => ( |
| 42 | hasModule(path, 'React') || |