babel-plugin-react-docgen
Advanced tools
Comparing version 1.4.2 to 1.5.0
# 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 |
@@ -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" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143490
36
1509
1
Updatedbabel-types@^6.24.1
Updatedreact-docgen@^2.15.0