Skip to content

Commit fbfff97

Browse files
committed
refactor: remove duplicate util
1 parent 9180320 commit fbfff97

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

lib/rules/await-async-events.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,6 @@ export default createTestingLibraryRule<Options, MessageIds>({
129129
);
130130
}
131131

132-
function findFunctionName(node: TSESTree.Node): string | null {
133-
let current: TSESTree.Node | undefined = node;
134-
while (current) {
135-
if (
136-
current.type === AST_NODE_TYPES.FunctionDeclaration ||
137-
current.type === AST_NODE_TYPES.FunctionExpression ||
138-
current.type === AST_NODE_TYPES.ArrowFunctionExpression
139-
) {
140-
return getFunctionName(current);
141-
}
142-
current = current.parent;
143-
}
144-
return null;
145-
}
146-
147132
const eventModules =
148133
typeof options.eventModule === 'string'
149134
? [options.eventModule]
@@ -221,8 +206,9 @@ export default createTestingLibraryRule<Options, MessageIds>({
221206
}
222207

223208
if (setupProps.size > 0) {
224-
const functionName = findFunctionName(node);
225-
if (functionName) {
209+
const functionNode = findClosestFunctionExpressionNode(node);
210+
if (functionNode) {
211+
const functionName = getFunctionName(functionNode);
226212
setupFunctions.set(functionName, setupProps);
227213
}
228214
}

0 commit comments

Comments
 (0)