{"record":{"id":"37113acf8bb4e068","repo":"oxc-project/oxc","slug":"async-function-has-no-await-expression","errorCode":null,"errorMessage":"Async function has no `await` expression.","messagePattern":"Async function has no `await` expression\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/require_await.rs","lineNumber":20,"sourceCode":"    AstKind,\n    ast::{\n        ArrowFunctionExpression, AwaitExpression, ForOfStatement, Function, FunctionBody,\n        FunctionType, MethodDefinition, ObjectProperty, PropertyKey,\n    },\n};\nuse oxc_ast_visit::{VisitJs, walk_js::walk_for_of_statement};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::ScopeFlags;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\n#[derive(Debug, Default, Clone)]\npub struct RequireAwait;\n\nfn require_await_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Async function has no `await` expression.\")\n        .with_help(\"Consider removing the `async` keyword.\")\n        .with_label(span)\n}\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow async functions which have no `await` expression.\n    ///\n    /// ::: warning NOTE\n    /// This rule is inferior to the accuracy of the type-aware\n    /// `typescript/require-await` rule. If using type-aware\n    /// rules, always prefer that rule over this one.\n    /// :::\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Asynchronous functions in JavaScript behave differently than other","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/require_await.rs#L2-L38","documentation":"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.","triggerScenarios":"`async function f() { return 1; }`, `const f = async () => 42;`, or an async method whose body (excluding nested functions, tracked via ScopeFlags) contains no `await`.","commonSituations":"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).","solutions":["Remove the `async` keyword if no await is needed; callers can still `await` the returned value if it is a promise.","If an await was intended but lost, restore it (e.g. `return await maybePromise()` when you rely on try/catch semantics).","For interface-mandated async signatures or empty stubs, suppress with `// oxlint-disable-next-line require-await`.","If false positives from promise-returning helpers are common, switch to type-aware `typescript/require-await`."],"exampleFix":"// before\nasync function getUser(id) {\n  return { id };\n}\n\n// after\nfunction getUser(id) {\n  return { id };\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only mark a function `async` when its body awaits something.","Returning a promise from a non-async function is fine — callers can still `await` it.","For nuanced cases (conditionally awaited helpers), prefer the type-aware `typescript/require-await`."],"tags":["eslint","oxlint","async-await","lint"],"backgroundTag":"async-function-without-await","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}