oxc-project/oxc · warning · OxcDiagnostic

Do not access a member directly from an await expression.

Error message

Do not access a member directly from an await expression.

What it means

Diagnostic from the oxlint rule `unicorn/no-await-expression-member` (crates/oxc_linter/src/rules/unicorn/no_await_expression_member.rs). It fires when a property is accessed directly on an `await` expression, such as `(await getUser()).name`. The code runs correctly at runtime; the rule is stylistic: reading members off an inline await is easy to misread and hard to extend, so it asks you to bind the awaited result to a variable first.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/no_await_expression_member.rs:12

use oxc_ast::{
    AstKind, MemberExpressionKind,
    ast::{BindingPattern, Expression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};

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

fn no_await_expression_member_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Do not access a member directly from an await expression.")
        .with_help("Assign the result of the await expression to a variable, then access the member from that variable.")
        .with_label(span)
}

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

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Disallows member access from `await` expressions.
    ///
    /// ### Why is this bad?
    ///
    /// When accessing a member from an `await` expression,
    /// the `await` expression has to be parenthesized, which is not readable.
    ///
    /// ### Examples

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Assign the awaited value first, then access the member: `const user = await getUser(); user.name`
  2. If the inline form is deliberate, suppress once with `// oxlint-disable-next-line unicorn/no-await-expression-member`
  3. If the team prefers inline awaits overall, turn the rule off in the rules section of .oxlintrc.json

Example fix

// before
console.log((await getUser()).name);

// after
const user = await getUser();
console.log(user.name);
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Any static or computed member access whose object is an AwaitExpression: `(await loadConfig()).retries`, `console.log((await getStats()).total)`, `(await readBlock())[0]`. The flagged shape is `(await x).y`, not the chained call `await x.y()`.

Common situations: One-off field reads in async functions; developers inlining awaits to save a line; teams enabling oxlint's unicorn preset (or raising lint severity from warn to error in CI) and hitting style failures on existing code.

Related errors


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