MCPcopy Index your code
hub / github.com/reactjs/react-codemod / hasModule

Function hasModule

transforms/utils/ReactUtils.js:26–39  ·  view source on GitHub ↗
(path, module)

Source from the content-addressed store, hash-verified

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') ||

Callers 1

hasReactFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected