How to use the react-docgen.utils.resolveToModule function in react-docgen

To help you get started, we’ve selected a few react-docgen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-bootstrap / react-bootstrap / www / resolveHocComponents.js View on Github external
visitCallExpression(path) {
      if (types.ExpressionStatement.check(path.node)) {
        path = path.get('expression');
      }
      if (path.node.type !== 'CallExpression') return false;

      const module = utils.resolveToModule(path);

      if (!module || !module.endsWith('createWithBsPrefix')) return false;
      const [prefixNode, optionsNode] = path.node.arguments;

      const comment = getComment(path);
      let type = '"div"';

      const property =
        optionsNode &&
        optionsNode.properties.find(p => p.key.name === 'Component');

      if (property) {
        type =
          property.value.type === 'Identifier'
            ? property.value.name
            : property.value.raw;
github doczjs / docz / core / docz-core / src / utils / docgen / externalProptypesHandler.ts View on Github external
function isPropTypesExpression(path: string) {
  const moduleName = utils.resolveToModule(path)

  if (moduleName) {
    return (
      utils.isReactModuleName(moduleName) || moduleName === 'ReactPropTypes'
    )
  }

  return false
}
github siddharthkp / react-docgen-external-proptypes-handler / index.js View on Github external
function isPropTypesExpression(path) {
  const moduleName = utils.resolveToModule(path);

  if (moduleName) {
    return (
      utils.isReactModuleName(moduleName) || moduleName === "ReactPropTypes"
    );
  }

  return false;
}