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
2
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.3.2 to 1.4.0

test/fixtures/case5/actual.js

5

CHANGELOG.md
# ChangeLog
### v1.4.0
01-November-2016
Handle multiple components in the same file by checking with exported classes. [PR17](https://github.com/kadirahq/babel-plugin-react-docgen/pull/17)
### v1.3.1

@@ -4,0 +9,0 @@ 23-October-2016

50

lib/index.js

@@ -15,17 +15,25 @@ 'use strict';

Class: function Class(path, state) {
if ((0, _isReactComponentClass2.default)(path)) {
var className = path.node.id.name;
injectReactDocgenInfo(className, path, state, this.file.code, t);
if (!(0, _isReactComponentClass2.default)(path)) {
return;
}
var className = path.node.id.name;
if (!isExported(path, className, t)) {
return;
}
injectReactDocgenInfo(className, path, state, this.file.code, t);
},
'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression': function FunctionDeclarationFunctionExpressionArrowFunctionExpression(path, state) {
if ((0, _isStatelessComponent2.default)(path)) {
var className = '';
if (path.parentPath.node.id) {
className = path.parentPath.node.id.name;
} else {
return;
}
injectReactDocgenInfo(className, path, state, this.file.code, t);
if (!(0, _isStatelessComponent2.default)(path)) {
return;
}
if (!path.parentPath.node.id) {
return;
}
var className = path.parentPath.node.id.name;
if (!isExported(path, className, t)) {
return;
}
injectReactDocgenInfo(className, path, state, this.file.code, t);
}

@@ -60,2 +68,22 @@ }

function isExported(path, className, t) {
var types = ['ExportDefaultDeclaration', 'ExportNamedDeclaration'];
if (path.parentPath.node && types.some(function (type) {
return path.parentPath.node.type === type;
})) {
return true;
}
var program = path.scope.getProgramParent().path;
return program.get('body').some(function (path) {
if (path.node.type === 'ExportNamedDeclaration' && path.node.specifiers && path.node.specifiers.length) {
return className === path.node.specifiers[0].exported.name;
} else if (path.node.type === 'ExportDefaultDeclaration') {
return className === path.node.declaration.name;
}
return false;
});
}
function alreadyVisited(program, t) {

@@ -62,0 +90,0 @@ return program.node.body.some(function (node) {

@@ -11,4 +11,4 @@ 'use strict';

function isJSXElementOrReactCreateElement(node) {
var type = node.type;
var callee = node.callee;
var type = node.type,
callee = node.callee;

@@ -15,0 +15,0 @@

{
"version": "1.3.2",
"version": "1.4.0",
"name": "babel-plugin-react-docgen",

@@ -10,4 +10,5 @@ "description": "Babel plugin to add react-docgen info into your code",

"babel-cli": "6.x.x",
"babel-preset-es2015": "6.x.x",
"babel-preset-stage-0": "6.x.x",
"babel-preset-es2015": "6.18.0",
"babel-preset-stage-0": "6.16.0",
"babel-preset-react": "6.16.0",
"mocha": "2.x.x"

@@ -29,3 +30,2 @@ },

"dependencies": {
"babel-preset-react": "6.x.x",
"babel-types": "^6.16.0",

@@ -32,0 +32,0 @@ "lodash": "4.x.x",

@@ -136,5 +136,5 @@ 'use strict';

var _props = this.props;
var day = _props.day;
var modifiers = _props.modifiers;
var _props = this.props,
day = _props.day,
modifiers = _props.modifiers;

@@ -141,0 +141,0 @@

@@ -14,6 +14,6 @@ 'use strict';

var Button = function Button(_ref) {
var children = _ref.children;
var onClick = _ref.onClick;
var _ref$style = _ref.style;
var style = _ref$style === undefined ? {} : _ref$style;
var children = _ref.children,
onClick = _ref.onClick,
_ref$style = _ref.style,
style = _ref$style === undefined ? {} : _ref$style;
return _react2.default.createElement(

@@ -20,0 +20,0 @@ 'button',

@@ -14,6 +14,6 @@ 'use strict';

var Button = function Button(_ref) {
var children = _ref.children;
var onClick = _ref.onClick;
var _ref$style = _ref.style;
var style = _ref$style === undefined ? {} : _ref$style;
var children = _ref.children,
onClick = _ref.onClick,
_ref$style = _ref.style,
style = _ref$style === undefined ? {} : _ref$style;

@@ -20,0 +20,0 @@ return _react2.default.createElement(

Sorry, the diff of this file is not supported yet

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