oxc-project/oxc · warning · OxcDiagnostic
async is not allowed
Error message
async is not allowed
What it means
Oxlint restriction rule `oxc/no_async_await` unconditionally disallows `async` functions and `await` expressions. It exists for projects that must ship synchronous-only or Promise-chain-only code (restrictive transpilation targets, embedded/legacy JS engines, or a strict house style). The diagnostic points at the `async` keyword span and the only fix is removing the syntax or disabling the rule.
Source
Thrown at crates/oxc_linter/src/rules/oxc/no_async_await.rs:9
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{AstNode, context::LintContext, rule::Rule};
fn no_async_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("async is not allowed")
.with_help("Remove the `async` keyword")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct NoAsyncAwait;
declare_oxc_lint!(
/// ### What it does
///
/// Disallows the use of `async`/`await`.
///
/// This rule should generally not be used in modern JavaScript/TypeScript
/// codebases without good reason.
///
/// ### Why is this bad?
///
/// This rule is useful for environments that don't support `async`/`await` syntax,View on GitHub (pinned to e1e7af627c)
Solutions
- Rewrite the code with plain promise chains (`.then`/`.catch`) instead of async/await
- If the constraint does not apply, turn the rule off in `.oxlintrc.json`: `"oxc/no_async_await": "off"`
- Keep the rule but scope it with `overrides` to only the directories that genuinely must stay sync
Example fix
// before
async function load(url) {
const res = await fetch(url);
return res.json();
}
// after
function load(url) {
return fetch(url).then((res) => res.json());
} Defensive patterns
Strategy: fallback
Prevention
- Enable the rule only in packages that truly must stay async-free, via `.oxlintrc.json` overrides
- Standardize on .then/.catch chains in those packages so review can enforce the rule mechanically
- Add the rule early in a project's life; retrofitting async-free onto async code is expensive
When it happens
Trigger: Any `async function` declaration, `async` arrow, async method, or `await` expression in a linted file when the `oxc` plugin's `no_async_await` rule is enabled (e.g. `"oxc/no_async_await": "error"` in `.oxlintrc.json`).
Common situations: Enabling the oxc restriction category wholesale; projects targeting ES5-only transpilers or runtimes without async support; porting an internal 'no async' coding standard to oxlint and hitting existing modern code.
Related errors
- Expected error to be handled.
- Prefer `async`/`await` to the callback pattern
- Do not use @ts-{ts_comment_name} because it alters compilati
- `alert`, `confirm` and `prompt` functions are not allowed
- Async function has no `await` expression.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/3cd2f7ab69605a88.
Report an issue: GitHub.