{"record":{"id":"3cd2f7ab69605a88","repo":"oxc-project/oxc","slug":"async-is-not-allowed","errorCode":null,"errorMessage":"async is not allowed","messagePattern":"async is not allowed","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/oxc/no_async_await.rs","lineNumber":9,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_async_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"async is not allowed\")\n        .with_help(\"Remove the `async` keyword\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoAsyncAwait;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallows the use of `async`/`await`.\n    ///\n    /// This rule should generally not be used in modern JavaScript/TypeScript\n    /// codebases without good reason.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// This rule is useful for environments that don't support `async`/`await` syntax,","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/oxc/no_async_await.rs#L1-L27","documentation":"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.","triggerScenarios":"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`).","commonSituations":"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.","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"],"exampleFix":"// before\nasync function load(url) {\n  const res = await fetch(url);\n  return res.json();\n}\n\n// after\nfunction load(url) {\n  return fetch(url).then((res) => res.json());\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["oxlint","async-await","restriction","syntax","style-rule"],"backgroundTag":"disallow-async-await-syntax","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}