Skip to content

Commit 8cf41e0

Browse files
committed
feat: add support for handling 'forEach' in async event method detection
1 parent bef5e4b commit 8cf41e0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/rules/await-async-events.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createTestingLibraryRule } from '../create-testing-library-rule';
44
import {
55
findClosestCallExpressionNode,
66
findClosestFunctionExpressionNode,
7+
getDeepestIdentifierNode,
78
getFunctionName,
89
getInnermostReturningFunction,
910
getVariableReferences,
@@ -153,6 +154,13 @@ export default createTestingLibraryRule<Options, MessageIds>({
153154
findClosestFunctionExpressionNode(node);
154155

155156
if (functionExpression) {
157+
const deepestCalleeIdentifier = getDeepestIdentifierNode(
158+
functionExpression.parent
159+
);
160+
if (deepestCalleeIdentifier?.name === 'forEach') {
161+
return null;
162+
}
163+
156164
const memberExpressionFixer = fixer.insertTextBefore(
157165
node.parent,
158166
'await '

0 commit comments

Comments
 (0)