Skip to content

Commit

Permalink
fix(linter/eslint): fix require-await false positives in `ForOfStat…
Browse files Browse the repository at this point in the history
…ement`. (#3457)

closes #3456
  • Loading branch information
rzvxa committed May 28, 2024
1 parent 0a61843 commit b188778
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/oxc_linter/src/rules/eslint/require_await.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use oxc_ast::{
ast::{ArrowFunctionExpression, AwaitExpression, ForOfStatement, Function, PropertyKey},
visit::walk::walk_for_of_statement,
AstKind, Visit,
};
use oxc_diagnostics::OxcDiagnostic;
Expand Down Expand Up @@ -96,6 +97,8 @@ impl<'a> Visit<'a> for AwaitFinder {
fn visit_for_of_statement(&mut self, stmt: &ForOfStatement) {
if stmt.r#await {
self.found = true;
} else {
walk_for_of_statement(self, stmt);
}
}

Expand Down Expand Up @@ -144,6 +147,14 @@ fn test() {
"const foo = async function *(){}",
r#"const foo = async function *(){ console.log("bar") }"#,
r#"async function* run() { console.log("bar") }"#,
"
const foo = async (
): Promise<string> => {
for (const bar of baz) {
x(await y(z));
}
};
",
];

let fail = vec![
Expand Down

0 comments on commit b188778

Please sign in to comment.