{"record":{"id":"d6dee1d9a70de64a","repo":"oxc-project/oxc","slug":"wrapping-single-element-array-with-promise-metho","errorCode":null,"errorMessage":"Wrapping single-element array with `Promise.{method_name}()` is unnecessary.","messagePattern":"Wrapping single-element array with `Promise\\.(.+?)\\(\\)` is unnecessary\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_single_promise_in_promise_methods.rs","lineNumber":13,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{CallExpression, Expression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::NodeId;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, ast_util::is_method_call, context::LintContext, rule::Rule};\n\nfn no_single_promise_in_promise_methods_diagnostic(span: Span, method_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Wrapping single-element array with `Promise.{method_name}()` is unnecessary.\"\n    ))\n    .with_help(\"Either use the value directly, or switch to `Promise.resolve(…)`.\")\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoSinglePromiseInPromiseMethods;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow passing single-element arrays to `Promise` methods.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Passing a single-element array to `Promise.all()`, `Promise.any()`, or\n    /// `Promise.race()` is likely a mistake.","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_single_promise_in_promise_methods.rs#L1-L31","documentation":"Raised by unicorn/no-single-promise-in-promise-methods when `Promise.all([x])`, `Promise.allSettled([x])`, etc. is given an array with exactly one element. The method name is interpolated into the message; the faulting input is the single-element array passed to the Promise method at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_single_promise_in_promise_methods.rs:13 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Await the value directly if it is already a promise","Use `Promise.resolve(value)` when a promise is required","Add the other concurrent operations to the array if they were intended"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}