(code: string)
| 184 | |
| 185 | /** The first hook called inside any loop body, or `undefined`. */ |
| 186 | const hookCalledInLoop = (code: string): string | undefined => { |
| 187 | const scannable = withLiteralsBlanked(code); |
| 188 | for (const match of scannable.matchAll(LOOP_HEAD)) { |
| 189 | const keyword = match[1] ?? ""; |
| 190 | if (keyword === "do" && !startsStatement(scannable, match.index)) continue; |
| 191 | const body = loopBody(scannable, keyword, match.index + match[0].length); |
| 192 | const hook = body === null ? undefined : HOOK_CALL.exec(body)?.[1]; |
| 193 | if (hook) return hook; |
| 194 | } |
| 195 | return undefined; |
| 196 | }; |
| 197 | |
| 198 | /** Hooks whose in-loop use is almost always hand-rolled cursor pagination. */ |
| 199 | const PAGINATION_HOOKS = new Set(["useQuery", "useInfiniteQuery", "useSuspenseQuery"]); |
no test coverage detected