Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

react-docgen

Package Overview
Dependencies
Maintainers
3
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-docgen - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

6

dist/handlers/flowTypeHandler.js

@@ -41,8 +41,4 @@ "use strict";

if (types.ObjectTypeSpreadProperty.check(path.node)) {
let argument = path.get('argument');
const argument = (0, _flowUtilityTypes.unwrapUtilityType)(path.get('argument'));
while ((0, _flowUtilityTypes.isSupportedUtilityType)(argument)) {
argument = (0, _flowUtilityTypes.unwrapUtilityType)(argument);
}
if (types.ObjectTypeAnnotation.check(argument.node)) {

@@ -49,0 +45,0 @@ (0, _getFlowTypeFromReactComponent.applyToFlowTypeProperties)(argument, propertyPath => {

8

dist/utils/flowUtilityTypes.js

@@ -34,3 +34,3 @@ "use strict";

const idPath = path.get('id');
return Boolean(idPath) && supportedUtilityTypes.has(idPath.node.name);
return !!idPath && supportedUtilityTypes.has(idPath.node.name);
}

@@ -48,3 +48,7 @@

function unwrapUtilityType(path) {
return path.get('typeParameters', 'params', 0);
while (isSupportedUtilityType(path)) {
path = path.get('typeParameters', 'params', 0);
}
return path;
}

@@ -31,3 +31,3 @@ "use strict";

// "key" and a "value"
return classDefinition.get('body', 'body').filter(memberPath => (!memberPath.node.computed || types.Literal.check(memberPath.node.key)) && (0, _getNameOrValue.default)(memberPath.get('key')) === memberName && memberPath.node.kind !== 'set').map(memberPath => memberPath.get('value'))[0];
return classDefinition.get('body', 'body').filter(memberPath => (!memberPath.node.computed || types.Literal.check(memberPath.node.key)) && !types.PrivateName.check(memberPath.node.key) && (0, _getNameOrValue.default)(memberPath.get('key')) === memberName && memberPath.node.kind !== 'set').map(memberPath => memberPath.get('value'))[0];
}

@@ -169,6 +169,8 @@ "use strict";

path.get('properties').each(param => {
type.signature.properties.push({
key: (0, _getPropertyName.default)(param),
value: getFlowTypeWithRequirements(param.get('value'))
});
if (types.ObjectTypeProperty.check(param.node)) {
type.signature.properties.push({
key: (0, _getPropertyName.default)(param),
value: getFlowTypeWithRequirements(param.get('value'))
});
}
});

@@ -175,0 +177,0 @@ return type;

@@ -19,10 +19,2 @@ "use strict";

var _isUnreachableFlowType = _interopRequireDefault(require("../utils/isUnreachableFlowType"));
var _recast = _interopRequireDefault(require("recast"));
var _resolveToValue = _interopRequireDefault(require("../utils/resolveToValue"));
var _flowUtilityTypes = require("../utils/flowUtilityTypes");
var _resolveGenericTypeAnnotation = _interopRequireDefault(require("../utils/resolveGenericTypeAnnotation"));

@@ -41,3 +33,3 @@

*/
const types = _recast.default.types.namedTypes;
/**

@@ -48,3 +40,2 @@ * Given an React component (stateless or class) tries to find the

*/
var _default = path => {

@@ -78,14 +69,2 @@ let typePath;

if (typePath && (0, _flowUtilityTypes.isSupportedUtilityType)(typePath)) {
typePath = (0, _flowUtilityTypes.unwrapUtilityType)(typePath);
} else if (typePath && types.GenericTypeAnnotation.check(typePath.node)) {
typePath = (0, _resolveToValue.default)(typePath.get('id'));
if (!typePath || types.Identifier.check(typePath.node) || (0, _isUnreachableFlowType.default)(typePath)) {
return;
}
typePath = typePath.get('right');
}
return typePath;

@@ -92,0 +71,0 @@ };

@@ -25,3 +25,3 @@ "use strict";

const types = _recast.default.types.namedTypes;
const componentMethods = ['componentDidMount', 'componentDidReceiveProps', 'componentDidUpdate', 'componentWillMount', 'componentWillReceiveProps', 'componentWillUnmount', 'componentWillUpdate', 'getChildContext', 'getDefaultProps', 'getInitialState', 'render', 'shouldComponentUpdate'];
const componentMethods = ['componentDidMount', 'componentDidReceiveProps', 'componentDidUpdate', 'componentWillMount', 'UNSAFE_componentWillMount', 'componentWillReceiveProps', 'UNSAFE_componentWillReceiveProps', 'componentWillUnmount', 'componentWillUpdate', 'UNSAFE_componentWillUpdate', 'getChildContext', 'getDefaultProps', 'getInitialState', 'render', 'shouldComponentUpdate', 'getDerivedStateFromProps', 'getDerivedStateFromError', 'getSnapshotBeforeUpdate', 'componentDidCatch'];
/**

@@ -28,0 +28,0 @@ * Returns if the method path is a Component method.

@@ -30,16 +30,8 @@ "use strict";

const types = _recast.default.types.namedTypes;
/**
* Given an React component (stateless or class) tries to find the
* flow type for the props. If not found or not one of the supported
* component types returns null.
*/
function resolveGenericTypeAnnotation(path) {
// If the node doesn't have types or properties, try to get the type.
let typePath;
function tryResolveGenericTypeAnnotation(path) {
let typePath = (0, _flowUtilityTypes.unwrapUtilityType)(path);
if (path && (0, _flowUtilityTypes.isSupportedUtilityType)(path)) {
typePath = (0, _flowUtilityTypes.unwrapUtilityType)(path);
} else if (path && types.GenericTypeAnnotation.check(path.node)) {
typePath = (0, _resolveToValue.default)(path.get('id'));
if (types.GenericTypeAnnotation.check(typePath.node)) {
typePath = (0, _resolveToValue.default)(typePath.get('id'));

@@ -50,6 +42,19 @@ if ((0, _isUnreachableFlowType.default)(typePath)) {

typePath = typePath.get('right');
return tryResolveGenericTypeAnnotation(typePath.get('right'));
}
return typePath;
}
/**
* Given an React component (stateless or class) tries to find the
* flow type for the props. If not found or not one of the supported
* component types returns undefined.
*/
function resolveGenericTypeAnnotation(path) {
if (!path) return;
const typePath = tryResolveGenericTypeAnnotation(path);
if (!typePath || typePath === path) return;
return typePath;
}
{
"name": "react-docgen",
"version": "4.1.0",
"version": "4.1.1",
"description": "A CLI and toolkit to extract information from React components for documentation generation.",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc