import { visitChildren } from './visitChildren' import { CallExpression, Node } from 'estree' export function findCallExpressions(root: Node, calleeName: string): Array { const isTargetCallExpression = (node: Node): node is CallExpression => { if (node.type !== 'CallExpression') { return false } if (node.callee.type !== 'Identifier') { return false } if (node.callee.name !== calleeName) { return false } return true } const foundExpressions: Array = [] const search = (node: Node) => { if (isTargetCallExpression(node)) { foundExpressions.push(node) } visitChildren(node, search) } search(root) return foundExpressions }