mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(linter/eslint): fix require-await false positives in ForOfStatement. (#3457)
closes #3456
This commit is contained in:
parent
0a61843ea8
commit
b1887782ac
1 changed files with 11 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
use oxc_ast::{
|
use oxc_ast::{
|
||||||
ast::{ArrowFunctionExpression, AwaitExpression, ForOfStatement, Function, PropertyKey},
|
ast::{ArrowFunctionExpression, AwaitExpression, ForOfStatement, Function, PropertyKey},
|
||||||
|
visit::walk::walk_for_of_statement,
|
||||||
AstKind, Visit,
|
AstKind, Visit,
|
||||||
};
|
};
|
||||||
use oxc_diagnostics::OxcDiagnostic;
|
use oxc_diagnostics::OxcDiagnostic;
|
||||||
|
|
@ -96,6 +97,8 @@ impl<'a> Visit<'a> for AwaitFinder {
|
||||||
fn visit_for_of_statement(&mut self, stmt: &ForOfStatement) {
|
fn visit_for_of_statement(&mut self, stmt: &ForOfStatement) {
|
||||||
if stmt.r#await {
|
if stmt.r#await {
|
||||||
self.found = true;
|
self.found = true;
|
||||||
|
} else {
|
||||||
|
walk_for_of_statement(self, stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,6 +147,14 @@ fn test() {
|
||||||
"const foo = async function *(){}",
|
"const foo = async function *(){}",
|
||||||
r#"const foo = async function *(){ console.log("bar") }"#,
|
r#"const foo = async function *(){ console.log("bar") }"#,
|
||||||
r#"async function* run() { 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![
|
let fail = vec![
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue