react-magnetic-di
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -21,2 +21,8 @@ "use strict"; | ||
var isDefaultProp = function isDefaultProp(node, diStatement) { | ||
// we assume order rule is enabled, so if the variable is used in an assignment | ||
// defined before our di() statements, then it's probably default props | ||
return node.parent.type === 'AssignmentPattern' && node.range[0] < diStatement.range[0]; | ||
}; | ||
module.exports = { | ||
@@ -104,3 +110,3 @@ meta: { | ||
var isInjectable = isHookName(varNode); | ||
if (!isInjectable || isInjected(diVars, varNode) || isReactIgnored(varNode) || isOptionsIgnored(varNode)) return; | ||
if (!isInjectable || isInjected(diVars, varNode) || isReactIgnored(varNode) || isOptionsIgnored(varNode) || isDefaultProp(varNode, diStatements[0])) return; | ||
report(varNode, diStatements[diStatements.length - 1]); | ||
@@ -112,3 +118,8 @@ }); | ||
'JSXOpeningElement:exit': function JSXOpeningElementExit(node) { | ||
if (!diIdentifier) return; | ||
if (!diIdentifier) return; // ignore if the component is declared locally | ||
var localVars = context.getScope().variables.map(function (v) { | ||
return v.name; | ||
}); | ||
if (localVars.includes(node.name.name)) return; | ||
var varNode; | ||
@@ -115,0 +126,0 @@ |
@@ -19,2 +19,8 @@ var _require = require('../utils'), | ||
var isDefaultProp = function isDefaultProp(node, diStatement) { | ||
// we assume order rule is enabled, so if the variable is used in an assignment | ||
// defined before our di() statements, then it's probably default props | ||
return node.parent.type === 'AssignmentPattern' && node.range[0] < diStatement.range[0]; | ||
}; | ||
module.exports = { | ||
@@ -102,3 +108,3 @@ meta: { | ||
var isInjectable = isHookName(varNode); | ||
if (!isInjectable || isInjected(diVars, varNode) || isReactIgnored(varNode) || isOptionsIgnored(varNode)) return; | ||
if (!isInjectable || isInjected(diVars, varNode) || isReactIgnored(varNode) || isOptionsIgnored(varNode) || isDefaultProp(varNode, diStatements[0])) return; | ||
report(varNode, diStatements[diStatements.length - 1]); | ||
@@ -110,3 +116,8 @@ }); | ||
'JSXOpeningElement:exit': function JSXOpeningElementExit(node) { | ||
if (!diIdentifier) return; | ||
if (!diIdentifier) return; // ignore if the component is declared locally | ||
var localVars = context.getScope().variables.map(function (v) { | ||
return v.name; | ||
}); | ||
if (localVars.includes(node.name.name)) return; | ||
var varNode; | ||
@@ -113,0 +124,0 @@ |
{ | ||
"name": "react-magnetic-di", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Context driven dependency injection", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
74185
1485