Skip to content
Prev Previous commit
refactor: remove duplicate util
  • Loading branch information
puglyfe committed Sep 22, 2025
commit fbfff97f9d0e20a7a8a59f5bbb0fcd8580c5e7a6
20 changes: 3 additions & 17 deletions lib/rules/await-async-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,6 @@ export default createTestingLibraryRule<Options, MessageIds>({
);
}

function findFunctionName(node: TSESTree.Node): string | null {
let current: TSESTree.Node | undefined = node;
while (current) {
if (
current.type === AST_NODE_TYPES.FunctionDeclaration ||
current.type === AST_NODE_TYPES.FunctionExpression ||
current.type === AST_NODE_TYPES.ArrowFunctionExpression
) {
return getFunctionName(current);
}
current = current.parent;
}
return null;
}

const eventModules =
typeof options.eventModule === 'string'
? [options.eventModule]
Expand Down Expand Up @@ -221,8 +206,9 @@ export default createTestingLibraryRule<Options, MessageIds>({
}

if (setupProps.size > 0) {
const functionName = findFunctionName(node);
if (functionName) {
const functionNode = findClosestFunctionExpressionNode(node);
if (functionNode) {
const functionName = getFunctionName(functionNode);
setupFunctions.set(functionName, setupProps);
}
}
Expand Down