babel-plugin-react-display-name
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -29,2 +29,21 @@ "use strict"; | ||
var isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass"); | ||
function isCreateClass(node) { | ||
if (!node || !t.isCallExpression(node)) return false; | ||
// not React.createClass call member object | ||
if (!isCreateClassCallExpression(node.callee)) return false; | ||
// no call arguments | ||
var args = node.arguments; | ||
if (args.length !== 1) return false; | ||
// first node arg is not an object | ||
var first = args[0]; | ||
if (!t.isObjectExpression(first)) return false; | ||
return true; | ||
} | ||
return new Plugin("react-display-name", { | ||
@@ -37,3 +56,3 @@ metadata: { | ||
ExportDefaultDeclaration: function ExportDefaultDeclaration(node, parent, scope, file) { | ||
if (react.isCreateClass(node.declaration)) { | ||
if (isCreateClass(node.declaration)) { | ||
addDisplayName(file.opts.basename, node.declaration); | ||
@@ -61,3 +80,3 @@ } | ||
if (t.isIdentifier(left) && react.isCreateClass(right)) { | ||
if (t.isIdentifier(left) && isCreateClass(right)) { | ||
addDisplayName(left.name, right); | ||
@@ -64,0 +83,0 @@ } |
{ | ||
"name": "babel-plugin-react-display-name", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Add displayName to React.createClass calls", | ||
@@ -5,0 +5,0 @@ "repository": "babel-plugins/babel-plugin-react-display-name", |
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
3132
67