feat(no-unnecessary-await): add no-unnecessary-await rule - #1523
feat(no-unnecessary-await): add no-unnecessary-await rule#1523bartlomieju wants to merge 2 commits into
no-unnecessary-await rule#1523Conversation
|
Verdict: needs changes — false positive on logical expressions due to an oxc→swc AST-dialect difference. Not merging (new rule + bug). Correctness — blocking
The existing valid tests Fix — exclude logical operators: Expr::Bin(bin) => !matches!(
bin.op(),
BinaryOp::LogicalOr | BinaryOp::LogicalAnd | BinaryOp::NullishCoalescing
),and add valid-case tests: Otherwise correct
Perf: trivial (per Housekeeping: Blocker: the |
Ports the
no-unnecessary-awaitrule from oxlint'sunicornplugin as anative deno_lint rule. It flags
awaitapplied to an expression that isdefinitely not a thenable/promise, since awaiting such values has no useful
effect.
The following argument expressions are reported: array, arrow function,
nested
await, binary expression, class expression, function expression,JSX element/fragment, literals (boolean, null, numeric, bigint, regex,
string), template literal, unary expression, and update expression. Sequence
expressions are inspected by their final element, and parenthesized
expressions are unwrapped, both matching the upstream behavior.
The rule is diagnostic-only; oxlint's autofix is intentionally not ported,
in line with the diagnostic-only convention for rules in this repository.
Reference implementation:
https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/unicorn/no_unnecessary_await.rs
Tagged RECOMMENDED (on by default) — flagging for maintainer sign-off.