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 ba29087b8f813..2fc7e063bc715 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 @@ -93,7 +93,12 @@ impl Rule for PreferAwaitToThen { } } - ctx.diagnostic(prefer_wait_to_then_diagnostic(call_expr.span)); + let span = call_expr + .callee + .as_member_expression() + .and_then(oxc_ast::ast::MemberExpression::static_property_info) + .map_or(call_expr.span, |(span, _)| span); + ctx.diagnostic(prefer_wait_to_then_diagnostic(span)); } } diff --git a/crates/oxc_linter/src/snapshots/promise_prefer_await_to_then.snap b/crates/oxc_linter/src/snapshots/promise_prefer_await_to_then.snap index a9d51f61115b5..ce2038209bb44 100644 --- a/crates/oxc_linter/src/snapshots/promise_prefer_await_to_then.snap +++ b/crates/oxc_linter/src/snapshots/promise_prefer_await_to_then.snap @@ -2,79 +2,79 @@ source: crates/oxc_linter/src/tester.rs --- ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:18] + ╭─[prefer_await_to_then.tsx:1:22] 1 │ function foo() { hey.then(x => {}) } - · ───────────────── + · ──── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:18] + ╭─[prefer_await_to_then.tsx:1:43] 1 │ function foo() { hey.then(function() { }).then() } - · ─────────────────────────────── + · ──── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:18] + ╭─[prefer_await_to_then.tsx:1:22] 1 │ function foo() { hey.then(function() { }).then() } - · ──────────────────────── + · ──── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:18] + ╭─[prefer_await_to_then.tsx:1:51] 1 │ function foo() { hey.then(function() { }).then(x).catch() } - · ──────────────────────────────────────── + · ───── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:18] + ╭─[prefer_await_to_then.tsx:1:43] 1 │ function foo() { hey.then(function() { }).then(x).catch() } - · ──────────────────────────────── + · ──── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:18] + ╭─[prefer_await_to_then.tsx:1:22] 1 │ function foo() { hey.then(function() { }).then(x).catch() } - · ──────────────────────── + · ──── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:22] + ╭─[prefer_await_to_then.tsx:1:47] 1 │ async function a() { hey.then(function() { }).then(function() { }) } - · ───────────────────────────────────────────── + · ──── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:22] + ╭─[prefer_await_to_then.tsx:1:26] 1 │ async function a() { hey.then(function() { }).then(function() { }) } - · ──────────────────────── + · ──── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:18] + ╭─[prefer_await_to_then.tsx:1:22] 1 │ function foo() { hey.catch(x => {}) } - · ────────────────── + · ───── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:18] + ╭─[prefer_await_to_then.tsx:1:22] 1 │ function foo() { hey.finally(x => {}) } - · ──────────────────── + · ─────── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:1] + ╭─[prefer_await_to_then.tsx:1:13] 1 │ something().then(async () => await somethingElse()) - · ─────────────────────────────────────────────────── + · ──── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:30] + ╭─[prefer_await_to_then.tsx:1:38] 1 │ async function foo() { await thing().then() } - · ────────────── + · ──── ╰──── ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() - ╭─[prefer_await_to_then.tsx:1:24] + ╭─[prefer_await_to_then.tsx:1:32] 1 │ async function foo() { thing().then() } - · ────────────── + · ──── ╰────