Skip to content

Commit c068394

Browse files
committed
Fix hook detection for known test hooks
1 parent 794d6bd commit c068394

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

eslint-plugin-epic-web.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,18 @@ function getHookName(node) {
8686
const callPath = getCallPath(node)
8787
if (!callPath || callPath.length === 0) return null
8888
const lastSegment = callPath.at(-1)
89-
return HOOK_NAMES.has(lastSegment) ? lastSegment : null
89+
if (!HOOK_NAMES.has(lastSegment)) return null
90+
91+
if (callPath.length === 1) return lastSegment
92+
93+
if (
94+
callPath.length === 2 &&
95+
(TEST_CALL_ROOTS.has(callPath[0]) || SUITE_CALL_ROOTS.has(callPath[0]))
96+
) {
97+
return lastSegment
98+
}
99+
100+
return null
90101
}
91102

92103
function isFunctionNode(node) {

0 commit comments

Comments
 (0)