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

babel-plugin-react-docgen

Package Overview
Dependencies
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-react-docgen - npm Package Compare versions

Comparing version 4.2.0 to 4.2.1

8

CHANGELOG.md
# ChangeLog
### v4.2.1
13-10-2020
Bug fixes:
- Fixed support for optional chaining #92
### v4.2.0

@@ -4,0 +12,0 @@

21

lib/actualNameHandler.js

@@ -10,6 +10,4 @@ "use strict";

var _recast = _interopRequireDefault(require("recast"));
var _astTypes = require("ast-types");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/*

@@ -34,3 +32,2 @@ * Copyright (c) 2015, Facebook, Inc.

resolveToValue = _reactDocgen.utils.resolveToValue;
var types = _recast["default"].types.namedTypes;

@@ -40,13 +37,13 @@ function actualNameHandler(documentation, path) {

// function / class is the displayName
if (types.ClassDeclaration.check(path.node) || types.FunctionDeclaration.check(path.node)) {
if (_astTypes.namedTypes.ClassDeclaration.check(path.node) || _astTypes.namedTypes.FunctionDeclaration.check(path.node)) {
documentation.set('actualName', getNameOrValue(path.get('id')));
} else if (types.ArrowFunctionExpression.check(path.node) || types.FunctionExpression.check(path.node) || // React.forwardRef
types.CallExpression.check(path.node)) {
if (types.VariableDeclarator.check(path.parentPath.node)) {
} else if (_astTypes.namedTypes.ArrowFunctionExpression.check(path.node) || _astTypes.namedTypes.FunctionExpression.check(path.node) || // React.forwardRef
_astTypes.namedTypes.CallExpression.check(path.node)) {
if (_astTypes.namedTypes.VariableDeclarator.check(path.parentPath.node)) {
documentation.set('actualName', getNameOrValue(path.parentPath.get('id')));
} else if (types.AssignmentExpression.check(path.parentPath.node)) {
} else if (_astTypes.namedTypes.AssignmentExpression.check(path.parentPath.node)) {
documentation.set('actualName', getNameOrValue(path.parentPath.get('left')));
}
} else if ( // React.createClass() or createReactClass()
types.CallExpression.check(path.parentPath.node) && types.VariableDeclarator.check(path.parentPath.parentPath.parentPath.node)) {
_astTypes.namedTypes.CallExpression.check(path.parentPath.node) && _astTypes.namedTypes.VariableDeclarator.check(path.parentPath.parentPath.parentPath.node)) {
documentation.set('actualName', getNameOrValue(path.parentPath.parentPath.parentPath.get('id')));

@@ -62,7 +59,7 @@ } else {

if (types.FunctionExpression.check(displayNamePath.node)) {
if (_astTypes.namedTypes.FunctionExpression.check(displayNamePath.node)) {
displayNamePath = resolveFunctionDefinitionToReturnValue(displayNamePath);
}
if (!displayNamePath || !types.Literal.check(displayNamePath.node)) {
if (!displayNamePath || !_astTypes.namedTypes.Literal.check(displayNamePath.node)) {
return;

@@ -69,0 +66,0 @@ }

{
"version": "4.2.0",
"version": "4.2.1",
"name": "babel-plugin-react-docgen",

@@ -19,2 +19,3 @@ "description": "Babel plugin to add react-docgen info into your code",

"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
"@babel/preset-env": "^7.6.3",

@@ -41,7 +42,7 @@ "@babel/preset-flow": "^7.0.0",

"dependencies": {
"ast-types": "^0.14.2",
"lodash": "^4.17.15",
"react-docgen": "^5.0.0",
"recast": "^0.14.7"
"react-docgen": "^5.0.0"
},
"license": "MIT"
}
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