babel-plugin-react-docgen
Advanced tools
Comparing version 1.3.2 to 1.4.0
# 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 |
@@ -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
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
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
135074
3
30
1267
5
- Removedbabel-preset-react@6.x.x
- Removedbabel-helper-builder-react-jsx@6.26.0(transitive)
- Removedbabel-plugin-syntax-flow@6.18.0(transitive)
- Removedbabel-plugin-syntax-jsx@6.18.0(transitive)
- Removedbabel-plugin-transform-flow-strip-types@6.22.0(transitive)
- Removedbabel-plugin-transform-react-display-name@6.25.0(transitive)
- Removedbabel-plugin-transform-react-jsx@6.24.1(transitive)
- Removedbabel-plugin-transform-react-jsx-self@6.22.0(transitive)
- Removedbabel-plugin-transform-react-jsx-source@6.22.0(transitive)
- Removedbabel-preset-flow@6.23.0(transitive)
- Removedbabel-preset-react@6.24.1(transitive)