@eslint-react/var
Advanced tools
Comparing version 1.24.0-next.0 to 1.24.0-next.1
@@ -32,3 +32,3 @@ 'use strict'; | ||
var findVariable2 = eff.dual(2, (nameOrNode, initialScope) => { | ||
if (nameOrNode === eff._) return eff._; | ||
if (nameOrNode == null) return eff._; | ||
return ASTUtils__namespace.findVariable(initialScope, nameOrNode) ?? eff._; | ||
@@ -46,3 +46,3 @@ }); | ||
function getVariableDeclaratorId(node, prev) { | ||
if (node === eff._) return eff._; | ||
if (node == null) return eff._; | ||
switch (true) { | ||
@@ -60,5 +60,5 @@ case (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init === prev): | ||
function getVariableNode(variable, at) { | ||
if (variable === eff._) return eff._; | ||
if (variable == null) return eff._; | ||
const def = variable.defs.at(at); | ||
if (def === eff._) return eff._; | ||
if (def == null) return eff._; | ||
switch (true) { | ||
@@ -88,3 +88,3 @@ case (def.type === scopeManager.DefinitionType.FunctionName && def.node.type === types.AST_NODE_TYPES.FunctionDeclaration): | ||
const latestDef = findVariable2(name, initialScope)?.defs.at(-1); | ||
if (latestDef === eff._) return false; | ||
if (latestDef == null) return false; | ||
const { node, parent } = latestDef; | ||
@@ -126,3 +126,3 @@ if (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init != null) { | ||
} | ||
const resolvedValue = initialScope === eff._ ? ASTUtils.getStaticValue(node) : ASTUtils.getStaticValue(node, initialScope); | ||
const resolvedValue = initialScope == null ? ASTUtils.getStaticValue(node) : ASTUtils.getStaticValue(node, initialScope); | ||
return resolvedValue == null ? { kind: "none", node, initialScope } : { kind: "some", node, initialScope, value: resolvedValue.value }; | ||
@@ -183,3 +183,3 @@ } | ||
default: { | ||
return aVar !== eff._ && bVar !== eff._ && aVar === bVar; | ||
return aVar != null && bVar != null && aVar === bVar; | ||
} | ||
@@ -211,3 +211,3 @@ } | ||
function getValueConstruction(node, initialScope, hint = ValueConstructionHint.None) { | ||
if (node === eff._) return eff._; | ||
if (node == null) return eff._; | ||
switch (node.type) { | ||
@@ -251,3 +251,3 @@ case types.AST_NODE_TYPES.JSXElement: | ||
const lvc = getValueConstruction(node.left, initialScope, hint); | ||
if (lvc === eff._) return eff._; | ||
if (lvc == null) return eff._; | ||
return getValueConstruction(node.right, initialScope, hint); | ||
@@ -257,3 +257,3 @@ } | ||
const cvc = getValueConstruction(node.consequent, initialScope, hint); | ||
if (cvc === eff._) return eff._; | ||
if (cvc == null) return eff._; | ||
return getValueConstruction(node.alternate, initialScope, hint); | ||
@@ -260,0 +260,0 @@ } |
{ | ||
"name": "@eslint-react/var", | ||
"version": "1.24.0-next.0", | ||
"version": "1.24.0-next.1", | ||
"description": "ESLint React's TSESTree AST utility module for static analysis of variables", | ||
@@ -41,5 +41,5 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
"ts-pattern": "^5.6.0", | ||
"@eslint-react/ast": "1.24.0-next.0", | ||
"@eslint-react/types": "1.24.0-next.0", | ||
"@eslint-react/eff": "1.24.0-next.0" | ||
"@eslint-react/ast": "1.24.0-next.1", | ||
"@eslint-react/eff": "1.24.0-next.1", | ||
"@eslint-react/types": "1.24.0-next.1" | ||
}, | ||
@@ -46,0 +46,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
+ Added@eslint-react/ast@1.24.0-next.1(transitive)
+ Added@eslint-react/eff@1.24.0-next.1(transitive)
+ Added@eslint-react/types@1.24.0-next.1(transitive)
- Removed@eslint-react/ast@1.24.0-next.0(transitive)
- Removed@eslint-react/eff@1.24.0-next.0(transitive)
- Removed@eslint-react/types@1.24.0-next.0(transitive)