react-diagram-schema
Version:
Parses React components from a file entry point and generates/writes a complete schema to a file
19 lines (17 loc) • 547 B
JavaScript
function handleProviders(declarators, filepath) {
const providers = [];
const inits = declarators.map((decl) => decl.get("init"));
inits.forEach((init) => {
if (init.isMemberExpression() && init.node.property?.name === "Provider") {
providers.push({
name: init.node.property.name,
provider: true,
context: init.node.object.name,
location: { line: init.node.loc.start.line, filepath },
unresolvedDescendants: [],
});
}
});
return providers;
}
module.exports = handleProviders;