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
4
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 1.4.2 to 1.5.0

test/fixtures/createReactClass/actual.js

8

CHANGELOG.md
# ChangeLog
### v1.5.0
06-June-2017
Uses docgen 2.15.0 and babel-types 6.24.1
Add support for components created with React.createClass or createReactClass
### v1.4.2

@@ -45,2 +51,2 @@ 03-January-2017

* Global object with all the component docs
* `__docgenInfo` is now an actual object insted of a JSON string
* `__docgenInfo` is now an actual object instead of a JSON string

38

lib/index.js

@@ -7,4 +7,2 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.default = function (_ref) {

@@ -29,2 +27,22 @@ var t = _ref.types;

},
'CallExpression': function CallExpression(path, state) {
var callee = path.node.callee;
var objectName = _.get(callee, 'object.name') ? callee.object.name.toLowerCase() : null;
var propertyName = _.get(callee, 'property.name') ? callee.property.name.toLowerCase() : null;
var calleeName = _.get(callee, 'name') ? callee.name.toLowerCase() : null;
// Detect `React.createClass()`
var hasReactCreateClass = objectName === 'react' && propertyName === 'createclass';
// Detect `createReactClass()`
var hasCreateReactClass = calleeName === 'createreactclass';
// Get React class name from variable declaration
var className = _.get(path, 'parentPath.parent.declarations[0].id.name');
if (className && (hasReactCreateClass || hasCreateReactClass)) {
injectReactDocgenInfo(className, path, state, this.file.code, t);
}
},
'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression': function FunctionDeclarationFunctionExpressionArrowFunctionExpression(path, state) {

@@ -156,13 +174,7 @@ if (!(0, _isStatelessComponent2.default)(path)) {

} else if (_.isArray(obj)) {
var _ret = function () {
var children = [];
obj.forEach(function (val) {
children.push(buildObjectExpression(val, t));
});
return {
v: t.ArrayExpression(children)
};
}();
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
var _children = [];
obj.forEach(function (val) {
_children.push(buildObjectExpression(val, t));
});
return t.ArrayExpression(_children);
} else if (_.isNull(obj)) {

@@ -169,0 +181,0 @@ return t.nullLiteral();

{
"version": "1.4.2",
"version": "1.5.0",
"name": "babel-plugin-react-docgen",

@@ -29,7 +29,7 @@ "description": "Babel plugin to add react-docgen info into your code",

"dependencies": {
"babel-types": "^6.16.0",
"babel-types": "^6.24.1",
"lodash": "4.x.x",
"react-docgen": "^2.12.1"
"react-docgen": "^2.15.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