Skip to content

Commit b188778

Browse files
committed
fix(linter/eslint): fix require-await false positives in ForOfStatement. (#3457)
closes #3456
1 parent 0a61843 commit b188778

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/oxc_linter/src/rules/eslint/require_await.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use oxc_ast::{
22
ast::{ArrowFunctionExpression, AwaitExpression, ForOfStatement, Function, PropertyKey},
3+
visit::walk::walk_for_of_statement,
34
AstKind, Visit,
45
};
56
use oxc_diagnostics::OxcDiagnostic;
@@ -96,6 +97,8 @@ impl<'a> Visit<'a> for AwaitFinder {
9697
fn visit_for_of_statement(&mut self, stmt: &ForOfStatement) {
9798
if stmt.r#await {
9899
self.found = true;
100+
} else {
101+
walk_for_of_statement(self, stmt);
99102
}
100103
}
101104

@@ -144,6 +147,14 @@ fn test() {
144147
"const foo = async function *(){}",
145148
r#"const foo = async function *(){ console.log("bar") }"#,
146149
r#"async function* run() { console.log("bar") }"#,
150+
"
151+
const foo = async (
152+
): Promise<string> => {
153+
for (const bar of baz) {
154+
x(await y(z));
155+
}
156+
};
157+
",
147158
];
148159

149160
let fail = vec![

0 commit comments

Comments
 (0)