oxc-project/oxc · warning · OxcDiagnostic

Async function has no `await` expression.

Error message

Async function has no `await` expression.

What it means

oxlint `eslint/require-await`: an `async` function contains no `await` expression, so the `async` keyword only adds promise wrapping and microtask overhead. `require_await_diagnostic` (require_await.rs:20) labels the function and suggests removing `async`. The rule doc notes it is less accurate than type-aware `typescript/require-await`, so results may differ when a value is awaited indirectly.

Source

Thrown at crates/oxc_linter/src/rules/eslint/require_await.rs:20

    AstKind,
    ast::{
        ArrowFunctionExpression, AwaitExpression, ForOfStatement, Function, FunctionBody,
        FunctionType, MethodDefinition, ObjectProperty, PropertyKey,
    },
};
use oxc_ast_visit::{VisitJs, walk_js::walk_for_of_statement};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::ScopeFlags;
use oxc_span::{GetSpan, Span};

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

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

fn require_await_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Async function has no `await` expression.")
        .with_help("Consider removing the `async` keyword.")
        .with_label(span)
}

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Disallow async functions which have no `await` expression.
    ///
    /// ::: warning NOTE
    /// This rule is inferior to the accuracy of the type-aware
    /// `typescript/require-await` rule. If using type-aware
    /// rules, always prefer that rule over this one.
    /// :::
    ///
    /// ### Why is this bad?
    ///
    /// Asynchronous functions in JavaScript behave differently than other

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the `async` keyword if no await is needed; callers can still `await` the returned value if it is a promise.
  2. If an await was intended but lost, restore it (e.g. `return await maybePromise()` when you rely on try/catch semantics).
  3. For interface-mandated async signatures or empty stubs, suppress with `// oxlint-disable-next-line require-await`.
  4. If false positives from promise-returning helpers are common, switch to type-aware `typescript/require-await`.

Example fix

// before
async function getUser(id) {
  return { id };
}

// after
function getUser(id) {
  return { id };
}
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: `async function f() { return 1; }`, `const f = async () => 42;`, or an async method whose body (excluding nested functions, tracked via ScopeFlags) contains no `await`.

Common situations: Refactoring that removed the last await; stub/mock handlers declared async for symmetry; functions that only `return promise` without awaiting it (which some teams intend).

Related errors


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