hooks.macro
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -47,2 +47,20 @@ "use strict"; | ||
function getExpressionIdentifierPath(t, expressionPath) { | ||
if (t.isIdentifier(expressionPath)) { | ||
return expressionPath; | ||
} else if (t.isJSXElement(expressionPath)) { | ||
var tagNamePath = expressionPath.get('openingElement.name'); | ||
while (t.isJSXMemberExpression(tagNamePath)) { | ||
tagNamePath = tagNamePath.get('object'); | ||
} | ||
if (t.isJSXIdentifier(tagNamePath)) { | ||
return tagNamePath; | ||
} | ||
} | ||
return null; | ||
} | ||
function isStaticKnownHookValue(t, path, binding) { | ||
@@ -193,4 +211,6 @@ var bindingPath = binding.path; | ||
entryPath.traverse({ | ||
Expression: function Expression(path) { | ||
if (!t.isIdentifier(path)) { | ||
Expression: function Expression(expressionPath) { | ||
var path = getExpressionIdentifierPath(t, expressionPath); | ||
if (path == null) { | ||
return; | ||
@@ -245,3 +265,3 @@ } | ||
})) { | ||
references.push(node); | ||
references.push(t.isIdentifier(node) ? node : t.identifier(node.name)); | ||
} | ||
@@ -248,0 +268,0 @@ }); |
{ | ||
"name": "hooks.macro", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"author": "Pier Paolo Ramon <ramonpierre@gmail.com>", | ||
@@ -31,2 +31,4 @@ "main": "build/hooks.macro.js", | ||
"@babel/core": "^7.9.0", | ||
"@babel/plugin-syntax-do-expressions": "^7.8.3", | ||
"@babel/plugin-syntax-jsx": "^7.8.3", | ||
"@babel/preset-env": "^7.9.0", | ||
@@ -33,0 +35,0 @@ "babel-core": "7.0.0-bridge.0", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22625
248
0
10