oxc-project/oxc · error · OxcDiagnostic

Unexpected `await` on a non-Promise value

Error message

Unexpected `await` on a non-Promise value

What it means

Raised by unicorn/no-unnecessary-await when `await` is applied to an expression the rule determines is not thenable (a plain value, non-promise variable, etc.). The faulting input is the redundant await expression at the labeled span; removing it is the intended fix.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/no_unnecessary_await.rs:14

use oxc_ast::{
    AstKind,
    ast::{AwaitExpression, Expression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::AstNodes;
use oxc_span::Span;
use oxc_syntax::operator::{UnaryOperator, UpdateOperator};

use crate::{AstNode, context::LintContext, rule::Rule};

fn no_unnecessary_await_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected `await` on a non-Promise value")
        .with_help("Consider removing the `await`")
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct NoUnnecessaryAwait;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Disallow awaiting on non-promise values.
    ///
    /// ### Why is this bad?
    ///
    /// The `await` operator should only be used on `Promise` values.
    ///
    /// ### Examples
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the `await` keyword from the non-promise expression
  2. If the value can be a promise, keep `await` and disable the rule for that line
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/no_unnecessary_await.rs:14 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/058f0ab90951d917. Report an issue: GitHub.