From ada4e8464c73c3de98e966a3e1d2ef125f09c118 Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Mon, 18 Aug 2025 22:25:44 +0000 Subject: [PATCH] fix(linter/prefer-await-to-then): false positive with Promise call as return arg (#13189) fixes #13167 --- .../oxc_linter/src/rules/promise/prefer_await_to_then.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/oxc_linter/src/rules/promise/prefer_await_to_then.rs b/crates/oxc_linter/src/rules/promise/prefer_await_to_then.rs index 806a44f233d8c..064558c550eca 100644 --- a/crates/oxc_linter/src/rules/promise/prefer_await_to_then.rs +++ b/crates/oxc_linter/src/rules/promise/prefer_await_to_then.rs @@ -82,6 +82,10 @@ impl Rule for PreferAwaitToThen { return; } + if matches!(ctx.nodes().parent_kind(node.id()), AstKind::ReturnStatement(_)) { + return; + } + if !self.strict { // Already inside a yield or await if ctx.nodes().ancestors(node.id()).any(is_inside_yield_or_await) { @@ -134,6 +138,9 @@ fn test() { Some(serde_json::json!({ "strict": false })), ), ("const { promise, resolve } = Promise.withResolvers()", None), + ("function x () { return Promise.all() } ", None), + ("function foo() { return hey.then(x => x) }", None), + ("async function foo() { return thing().then(x => x) }", None), ]; let fail = vec![