@eslint-react/ast
Advanced tools
Comparing version 1.23.2-next.3 to 1.23.2-next.6
@@ -11,3 +11,33 @@ 'use strict'; | ||
// src/function-init-path.ts | ||
// src/find-parent-node.ts | ||
var findParentNode = eff.F.dual(2, (node, test) => { | ||
let parent = node.parent; | ||
while (parent && parent.type !== types.AST_NODE_TYPES.Program) { | ||
if (test(parent)) { | ||
return eff.O.some(parent); | ||
} | ||
parent = parent.parent; | ||
} | ||
return eff.O.none(); | ||
}); | ||
var findParentNodeGuard = eff.F.dual(2, (node, predicate) => { | ||
let parent = node.parent; | ||
while (parent) { | ||
if (predicate(parent)) { | ||
return eff.O.some(parent); | ||
} | ||
parent = parent.parent; | ||
} | ||
return eff.O.none(); | ||
}); | ||
function findParentNodeStop(node, stopNode, predicate) { | ||
let parent = node.parent; | ||
while (parent && parent !== stopNode && parent.type !== types.AST_NODE_TYPES.Program) { | ||
if (predicate(parent)) { | ||
return eff.O.some(parent); | ||
} | ||
parent = parent.parent; | ||
} | ||
return eff.O.none(); | ||
} | ||
function getFunctionInitPath(node) { | ||
@@ -74,18 +104,2 @@ const { parent } = node; | ||
return nodes.some( | ||
// TODO: Re-evaluate dot notation callName | ||
// callName.includes(".") | ||
// ? n => { | ||
// const [objectName, propertyName] = callName.split("."); | ||
// return "callee" in n | ||
// && n.callee.type === AST_NODE_TYPES.MemberExpression | ||
// && n.callee.object.type === AST_NODE_TYPES.Identifier | ||
// && n.callee.object.name === objectName | ||
// && n.callee.property.type === AST_NODE_TYPES.Identifier | ||
// && n.callee.property.name === propertyName; | ||
// } | ||
// : n => { | ||
// return "callee" in n | ||
// && n.callee.type === AST_NODE_TYPES.Identifier | ||
// && n.callee.name === callName; | ||
// }, | ||
(n) => { | ||
@@ -439,16 +453,9 @@ if (n.type !== types.AST_NODE_TYPES.CallExpression) return false; | ||
var getNestedNewExpressions = getNestedExpressionsOfType(typescriptEstree.AST_NODE_TYPES.NewExpression); | ||
var traverseUpGuard = eff.F.dual(2, (node, predicate) => { | ||
const { parent } = node; | ||
if (!parent || parent.type === types.AST_NODE_TYPES.Program) return eff.O.none(); | ||
return predicate(parent) ? eff.O.some(parent) : traverseUpGuard(parent, predicate); | ||
}); | ||
// src/get-nested-return-statements.ts | ||
function getNestedReturnStatements(node) { | ||
const returnStatements = []; | ||
const functionNode = isFunction(node) ? node : eff.O.getOrNull(traverseUpGuard(node, isFunction)); | ||
const functionNode = isFunction(node) ? node : eff.O.getOrNull(findParentNodeGuard(node, isFunction)); | ||
typescriptEstree.simpleTraverse(node, { | ||
enter(node2) { | ||
if (node2.type !== types.AST_NODE_TYPES.ReturnStatement) return; | ||
const parentFunction = eff.O.getOrNull(traverseUpGuard(node2, isFunction)); | ||
const parentFunction = eff.O.getOrNull(findParentNodeGuard(node2, isFunction)); | ||
if (parentFunction !== functionNode) return; | ||
@@ -592,12 +599,2 @@ returnStatements.push(node2); | ||
} | ||
var traverseUp = eff.F.dual(2, (node, predicate) => { | ||
const { parent } = node; | ||
if (!parent || parent.type === types.AST_NODE_TYPES.Program) return eff.O.none(); | ||
return predicate(parent) ? eff.O.some(parent) : traverseUp(parent, predicate); | ||
}); | ||
function traverseUpStop(node, stopNode, predicate) { | ||
const { parent } = node; | ||
if (!parent || parent === stopNode || parent.type === types.AST_NODE_TYPES.Program) return eff.O.none(); | ||
return predicate(parent) ? eff.O.some(parent) : traverseUpStop(parent, stopNode, predicate); | ||
} | ||
@@ -610,2 +607,5 @@ // src/unwrap-type-expression.ts | ||
exports.findParentNode = findParentNode; | ||
exports.findParentNodeGuard = findParentNodeGuard; | ||
exports.findParentNodeStop = findParentNodeStop; | ||
exports.getClassIdentifier = getClassIdentifier; | ||
@@ -656,5 +656,2 @@ exports.getFunctionIdentifier = getFunctionIdentifier; | ||
exports.toReadableNodeType = toReadableNodeType; | ||
exports.traverseUp = traverseUp; | ||
exports.traverseUpGuard = traverseUpGuard; | ||
exports.traverseUpStop = traverseUpStop; | ||
exports.unwrapTypeExpression = unwrapTypeExpression; |
{ | ||
"name": "@eslint-react/ast", | ||
"version": "1.23.2-next.3", | ||
"version": "1.23.2-next.6", | ||
"description": "ESLint React's TSESTree AST utility module.", | ||
@@ -36,9 +36,9 @@ "homepage": "https://github.com/rEl1cx/eslint-react", | ||
"dependencies": { | ||
"@typescript-eslint/types": "^8.19.0", | ||
"@typescript-eslint/typescript-estree": "^8.19.0", | ||
"@typescript-eslint/utils": "^8.19.0", | ||
"@typescript-eslint/types": "^8.19.1", | ||
"@typescript-eslint/typescript-estree": "^8.19.1", | ||
"@typescript-eslint/utils": "^8.19.1", | ||
"string-ts": "^2.2.0", | ||
"ts-pattern": "^5.6.0", | ||
"@eslint-react/eff": "1.23.2-next.3", | ||
"@eslint-react/types": "1.23.2-next.3" | ||
"@eslint-react/eff": "1.23.2-next.6", | ||
"@eslint-react/types": "1.23.2-next.6" | ||
}, | ||
@@ -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
250784
3707
+ Added@eslint-react/eff@1.23.2-next.6(transitive)
+ Added@eslint-react/types@1.23.2-next.6(transitive)
- Removed@eslint-react/eff@1.23.2-next.3(transitive)
- Removed@eslint-react/types@1.23.2-next.3(transitive)