(n: Node)
| 2480 | |
| 2481 | // A hook nested inside another function is only callable in there. |
| 2482 | const nested = (n: Node): boolean => |
| 2483 | context.getNodesInFile(n.filePath).some((f) => |
| 2484 | f.id !== n.id && (f.kind === 'function' || f.kind === 'method') && f.startLine <= n.startLine && f.endLine >= n.endLine && |
| 2485 | (f.startLine < n.startLine || f.endLine > n.endLine)); |
| 2486 | const hooks = candidates.filter((n) => n.kind === 'function' && n.name.startsWith('use') && !nested(n)); |
| 2487 | if (hooks.length === 0) return null; |
| 2488 | const sameFile = hooks.find((n) => n.filePath === fromFile); |
no test coverage detected