Files
hive/frontend/node_modules/react-docgen/dist/utils/isReactComponentClass.js
anthonyrawlins e89f2f4b7b Add comprehensive development roadmap via GitHub Issues
Created 10 detailed GitHub issues covering:
- Project activation and management UI (#1-2)
- Worker node coordination and visualization (#3-4)
- Automated GitHub repository scanning (#5)
- Intelligent model-to-issue matching (#6)
- Multi-model task execution system (#7)
- N8N workflow integration (#8)
- Hive-Bzzz P2P bridge (#9)
- Peer assistance protocol (#10)

Each issue includes detailed specifications, acceptance criteria,
technical implementation notes, and dependency mapping.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-12 19:41:01 +10:00

67 lines
2.1 KiB
JavaScript

import isReactModuleName from './isReactModuleName.js';
import resolveToModule from './resolveToModule.js';
import resolveToValue from './resolveToValue.js';
import isDestructuringAssignment from './isDestructuringAssignment.js';
import isImportSpecifier from './isImportSpecifier.js';
function isRenderMethod(path) {
if ((!path.isClassMethod() || path.node.kind !== 'method') &&
!path.isClassProperty()) {
return false;
}
if (path.node.computed || path.node.static) {
return false;
}
const key = path.get('key');
if (!key.isIdentifier() || key.node.name !== 'render') {
return false;
}
return true;
}
function classExtendsReactComponent(path) {
if (path.isMemberExpression()) {
const property = path.get('property');
if (property.isIdentifier({ name: 'Component' }) ||
property.isIdentifier({ name: 'PureComponent' })) {
return true;
}
}
else if (isImportSpecifier(path, 'Component') ||
isImportSpecifier(path, 'PureComponent')) {
return true;
}
else if (isDestructuringAssignment(path, 'Component') ||
isDestructuringAssignment(path, 'PureComponent')) {
return true;
}
return false;
}
/**
* Returns `true` of the path represents a class definition which either extends
* `React.Component` or has a superclass and implements a `render()` method.
*/
export default function isReactComponentClass(path) {
if (!path.isClass()) {
return false;
}
// React.Component or React.PureComponent
const superClass = path.get('superClass');
if (superClass.hasNode()) {
const resolvedSuperClass = resolveToValue(superClass);
if (classExtendsReactComponent(resolvedSuperClass)) {
const module = resolveToModule(resolvedSuperClass);
if (module && isReactModuleName(module)) {
return true;
}
}
}
else {
// does not extend anything
return false;
}
// render method
if (path.get('body').get('body').some(isRenderMethod)) {
return true;
}
return false;
}