react-magnetic-di
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -59,2 +59,6 @@ "use strict"; | ||
var reactVars; | ||
var currentComponentStack = []; | ||
var isRecursiveComponent = function isRecursiveComponent(node) { | ||
return currentComponentStack.includes(node.name); | ||
}; | ||
var userOptions = Object.assign({ | ||
@@ -102,2 +106,14 @@ ignore: [] | ||
}, | ||
FunctionDeclaration: function FunctionDeclaration(node) { | ||
if (node.id && node.id.name) currentComponentStack.push(node.id.name); | ||
}, | ||
'FunctionDeclaration:exit': function FunctionDeclarationExit(node) { | ||
if (node.id && node.id.name) currentComponentStack.pop(); | ||
}, | ||
VariableDeclarator: function VariableDeclarator(node) { | ||
if (node.id && node.id.name) currentComponentStack.push(node.id.name); | ||
}, | ||
'VariableDeclarator:exit': function VariableDeclaratorExit(node) { | ||
if (node.id && node.id.name) currentComponentStack.pop(); | ||
}, | ||
// this is to handle hooks and components recognised as used variables | ||
@@ -118,3 +134,3 @@ // it does not cover JSX variables | ||
var isInjectable = isHookName(varNode); | ||
if (!isInjectable || isInjected(diVars, varNode) || isReactIgnored(varNode) || isOptionsIgnored(varNode) || isLocalVariable(varNode, context.getScope()) || isDefaultProp(varNode, diStatements[0])) return; | ||
if (!isInjectable || isInjected(diVars, varNode) || isReactIgnored(varNode) || isOptionsIgnored(varNode) || isLocalVariable(varNode, context.getScope()) || isDefaultProp(varNode, diStatements[0]) || isRecursiveComponent(varNode)) return; | ||
report(varNode, diStatements[diStatements.length - 1]); | ||
@@ -136,3 +152,3 @@ }); | ||
var isInjectable = isComponentName(varNode); | ||
if (!isInjectable || isReactIgnored(varNode) || isOptionsIgnored(varNode)) return; | ||
if (!isInjectable || isReactIgnored(varNode) || isOptionsIgnored(varNode) || isRecursiveComponent(varNode)) return; | ||
break; | ||
@@ -139,0 +155,0 @@ } |
@@ -48,2 +48,4 @@ const { | ||
let reactVars; | ||
let currentComponentStack = []; | ||
const isRecursiveComponent = node => currentComponentStack.includes(node.name); | ||
const userOptions = Object.assign({ | ||
@@ -79,2 +81,14 @@ ignore: [] | ||
}, | ||
FunctionDeclaration(node) { | ||
if (node.id && node.id.name) currentComponentStack.push(node.id.name); | ||
}, | ||
'FunctionDeclaration:exit'(node) { | ||
if (node.id && node.id.name) currentComponentStack.pop(); | ||
}, | ||
VariableDeclarator(node) { | ||
if (node.id && node.id.name) currentComponentStack.push(node.id.name); | ||
}, | ||
'VariableDeclarator:exit'(node) { | ||
if (node.id && node.id.name) currentComponentStack.pop(); | ||
}, | ||
// this is to handle hooks and components recognised as used variables | ||
@@ -91,3 +105,3 @@ // it does not cover JSX variables | ||
const isInjectable = isHookName(varNode); | ||
if (!isInjectable || isInjected(diVars, varNode) || isReactIgnored(varNode) || isOptionsIgnored(varNode) || isLocalVariable(varNode, context.getScope()) || isDefaultProp(varNode, diStatements[0])) return; | ||
if (!isInjectable || isInjected(diVars, varNode) || isReactIgnored(varNode) || isOptionsIgnored(varNode) || isLocalVariable(varNode, context.getScope()) || isDefaultProp(varNode, diStatements[0]) || isRecursiveComponent(varNode)) return; | ||
report(varNode, diStatements[diStatements.length - 1]); | ||
@@ -109,3 +123,3 @@ }); | ||
const isInjectable = isComponentName(varNode); | ||
if (!isInjectable || isReactIgnored(varNode) || isOptionsIgnored(varNode)) return; | ||
if (!isInjectable || isReactIgnored(varNode) || isOptionsIgnored(varNode) || isRecursiveComponent(varNode)) return; | ||
break; | ||
@@ -112,0 +126,0 @@ } |
{ | ||
"name": "react-magnetic-di", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"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
101791
2112