@eslint-react/ast
Advanced tools
Comparing version 1.24.0-beta.1 to 1.24.0-beta.3
@@ -11,3 +11,3 @@ 'use strict'; | ||
// src/find-parent-node.ts | ||
var findParentNode = eff.dual(2, (node, test) => { | ||
function findParentNode(node, test) { | ||
if (node == null) return eff._; | ||
@@ -22,14 +22,3 @@ let parent = node.parent; | ||
return eff._; | ||
}); | ||
var findParentNodeGuard = eff.dual(2, (node, predicate) => { | ||
if (node == null) return eff._; | ||
let parent = node.parent; | ||
while (parent != null) { | ||
if (predicate(parent)) { | ||
return parent; | ||
} | ||
parent = parent.parent; | ||
} | ||
return eff._; | ||
}); | ||
} | ||
function getFunctionInitPath(node) { | ||
@@ -91,18 +80,16 @@ const { parent } = node; | ||
} | ||
function hasCallInFunctionInitPath(callName) { | ||
return (initPath) => { | ||
return initPath.some((n) => { | ||
if (n.type !== types.AST_NODE_TYPES.CallExpression) { | ||
function hasCallInFunctionInitPath(callName, initPath) { | ||
return initPath.some((n) => { | ||
if (n.type !== types.AST_NODE_TYPES.CallExpression) { | ||
return false; | ||
} | ||
switch (n.callee.type) { | ||
case types.AST_NODE_TYPES.Identifier: | ||
return n.callee.name === callName; | ||
case types.AST_NODE_TYPES.MemberExpression: | ||
return "name" in n.callee.property && n.callee.property.name === callName; | ||
default: | ||
return false; | ||
} | ||
switch (n.callee.type) { | ||
case types.AST_NODE_TYPES.Identifier: | ||
return n.callee.name === callName; | ||
case types.AST_NODE_TYPES.MemberExpression: | ||
return "name" in n.callee.property && n.callee.property.name === callName; | ||
default: | ||
return false; | ||
} | ||
}); | ||
}; | ||
} | ||
}); | ||
} | ||
@@ -454,3 +441,3 @@ function getClassIdentifier(node) { | ||
const returnStatements = []; | ||
const functionNode = isFunction(node) ? node : findParentNodeGuard(node, isFunction); | ||
const functionNode = isFunction(node) ? node : findParentNode(node, isFunction); | ||
typescriptEstree.simpleTraverse(node, { | ||
@@ -461,3 +448,3 @@ enter(node2) { | ||
} | ||
const parentFunction = findParentNodeGuard(node2, isFunction); | ||
const parentFunction = findParentNode(node2, isFunction); | ||
if (parentFunction !== functionNode) { | ||
@@ -624,3 +611,2 @@ return; | ||
exports.findParentNode = findParentNode; | ||
exports.findParentNodeGuard = findParentNodeGuard; | ||
exports.getClassIdentifier = getClassIdentifier; | ||
@@ -627,0 +613,0 @@ exports.getFunctionIdentifier = getFunctionIdentifier; |
{ | ||
"name": "@eslint-react/ast", | ||
"version": "1.24.0-beta.1", | ||
"version": "1.24.0-beta.3", | ||
"description": "ESLint React's TSESTree AST utility module.", | ||
@@ -41,4 +41,4 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
"ts-pattern": "^5.6.0", | ||
"@eslint-react/eff": "1.24.0-beta.1", | ||
"@eslint-react/types": "1.24.0-beta.1" | ||
"@eslint-react/types": "1.24.0-beta.3", | ||
"@eslint-react/eff": "1.24.0-beta.3" | ||
}, | ||
@@ -45,0 +45,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
247933
3691
+ Added@eslint-react/eff@1.24.0-beta.3(transitive)
+ Added@eslint-react/types@1.24.0-beta.3(transitive)
- Removed@eslint-react/eff@1.24.0-beta.1(transitive)
- Removed@eslint-react/types@1.24.0-beta.1(transitive)