{"record":{"id":"afa74784d54a8897","repo":"oxc-project/oxc","slug":"promise-in-promise-method-name-should-not-be","errorCode":null,"errorMessage":"Promise in `Promise.{method_name}()` should not be awaited.","messagePattern":"Promise in `Promise\\.(.+?)\\(\\)` should not be awaited\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/unicorn/no_await_in_promise_methods.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::Expression};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, ast_util::is_method_call, context::LintContext, rule::Rule};\n\nfn no_await_in_promise_methods_diagnostic(span: Span, method_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Promise in `Promise.{method_name}()` should not be awaited.\"))\n        .with_help(\"Remove the `await`\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoAwaitInPromiseMethods;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow using `await` in `Promise` method parameters.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Using `await` on promises passed as arguments to `Promise.all()`,\n    /// `Promise.allSettled()`, `Promise.any()`, or `Promise.race()` is likely a\n    /// mistake.\n    ///","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_await_in_promise_methods.rs#L1-L27","documentation":"Diagnostic from the oxlint rule `unicorn/no-await-in-promise-methods` (category: correctness). It fires when an element of the array passed to `Promise.all()`, `Promise.allSettled()`, `Promise.any()`, or `Promise.race()` is itself an `await` expression. That inner await is usually a mistake: array elements are evaluated sequentially, so later elements (and their promise creation) wait on the awaited one, destroying the concurrency the combinator exists for. The rule ships an auto-fix that deletes the inner `await`.","triggerScenarios":"A call to `Promise.all`/`allSettled`/`any`/`race` with exactly one array-literal argument, where an element is an await expression: `Promise.all([await promise, anotherPromise])`, `Promise.race([await a])`, `Promise.all([...foo, await p1, await p2])`. Sequence elements like `[(await p, 0)]` are not flagged.","commonSituations":"Refactoring sequential awaits into Promise.all and leaving the awaits inside the array; copy-pasting an awaited call into a combinator; enabling the unicorn preset and seeing correctness-category failures on existing async code.","solutions":["Delete the inner await so the promises are created concurrently: `Promise.all([fetchA(), fetchB()])` — `oxlint --fix` applies this automatically","If the calls genuinely must run sequentially, drop the combinator and await them one by one","For a deliberate case, suppress with `// oxlint-disable-next-line unicorn/no-await-in-promise-methods`"],"exampleFix":"// before\nPromise.all([await getUser(), getPosts()]);\n\n// after\nPromise.all([getUser(), getPosts()]);","handlingStrategy":"validation","validationCode":"# find offenders before enabling the rule\nrg -n 'Promise\\.(all|allSettled|any|race)\\([^)]*await' src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write combinator arrays with promises or promise factories, never awaits; keep exactly one outer `await`","Run `oxlint --fix` once when adopting the rule to auto-strip inner awaits","Add oxlint to pre-commit so offenders are caught at author time"],"tags":["async-await","promise","concurrency","oxlint"],"backgroundTag":"redundant-await","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"}