(n: Node)
| 2458 | |
| 2459 | // A hook nested inside another function is only callable in there. |
| 2460 | const nested = (n: Node): boolean => |
| 2461 | context.getNodesInFile(n.filePath).some((f) => |
| 2462 | f.id !== n.id && (f.kind === 'function' || f.kind === 'method') && f.startLine <= n.startLine && f.endLine >= n.endLine && |
| 2463 | (f.startLine < n.startLine || f.endLine > n.endLine)); |
| 2464 | const hooks = candidates.filter((n) => n.kind === 'function' && n.name.startsWith('use') && !nested(n)); |
| 2465 | if (hooks.length === 0) return null; |
| 2466 | const sameFile = hooks.find((n) => n.filePath === fromFile); |
no test coverage detected