Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion crates/oxc_linter/src/rules/promise/prefer_await_to_then.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ impl Rule for PreferAwaitToThen {
return;
};

if is_promise_with_context(call_expr, ctx).is_none_or(|v| v == "withResolvers") {
let Some(method_name) = is_promise_with_context(call_expr, ctx) else {
return;
};

if !matches!(method_name.as_str(), "then" | "catch" | "finally") {
return;
}

Expand Down Expand Up @@ -114,6 +118,12 @@ fn test() {
("async function hi() { await thing() }", None),
("async function hi() { await thing().then() }", None),
("async function hi() { await thing().catch() }", None),
("const x = Promise.resolve(42)", None),
("const x = Promise.reject(error)", None),
("const x = Promise.all(values)", None),
("const x = Promise.allSettled(values)", None),
("const x = Promise.any(values)", None),
("const x = Promise.race(values)", None),
("a = async () => (await something())", None),
(
"a = async () => {
Expand Down
Loading