Files
agency/.pnpm-store/v3/files/76/07a235fcf0f59d1ee84545e189062f637a9aa6f3f506088c7dfd0bec3906a2a24beecd2794cdb0676ae89ff106c586bdf21e9bb100e9dcbf1b38543b73216a
hanzo-agent 5af6960b87 run project
Run: sess_f37640604ae254cb4d11dc6217f7b721
2026-09-30 00:04:56 +00:00

39 lines
944 B
Plaintext

module.exports = ({
jscodeshift,
utils,
root,
packageName = '@tanstack/react-query',
}) => {
const filterUseQueryLikeHookCalls = (node, importIdentifiers, hooks) => {
for (const hook of hooks) {
const selector = utils.getSelectorByImports(importIdentifiers, hook)
if (utils.isFunctionCallOf(node, selector)) {
return true
}
}
return false
}
const findUseQueryLikeHookCalls = (importIdentifiers, hooks) =>
root
// First, we need to find all call expressions.
.find(jscodeshift.CallExpression, {})
// Then we narrow the collection to the `useQuery` like hook calls.
.filter((node) =>
filterUseQueryLikeHookCalls(node.value, importIdentifiers, hooks),
)
const execute = (hooks, replacer) => {
findUseQueryLikeHookCalls(
utils.locateImports(hooks, packageName),
hooks,
).replaceWith(replacer)
}
return {
execute,
}
}