{"record":{"id":"ef3d90ca300b231e","repo":"oxc-project/oxc","slug":"promise-prop-name-requires-0-or-1-arguments","errorCode":null,"errorMessage":"`Promise.{prop_name}()` requires 0 or 1 arguments, but received {args_len}.","messagePattern":"`Promise\\.(.+?)\\(\\)` requires 0 or 1 arguments, but received (.+?)\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/promise/valid_params.rs","lineNumber":13,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule, utils::is_promise_with_context};\n\nfn zero_or_one_argument_required_diagnostic(\n    span: Span,\n    prop_name: &str,\n    args_len: usize,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"`Promise.{prop_name}()` requires 0 or 1 arguments, but received {args_len}.\"\n    ))\n    .with_label(span)\n}\n\nfn one_or_two_argument_required_diagnostic(\n    span: Span,\n    prop_name: &str,\n    args_len: usize,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"`Promise.{prop_name}()` requires 1 or 2 arguments, but received {args_len}.\"\n    ))\n    .with_label(span)\n}\n\nfn one_argument_required_diagnostic(span: Span, prop_name: &str, args_len: usize) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/promise/valid_params.rs#L1-L31","documentation":"Diagnostic from the oxlint rule `promise/valid-params` (plugin `promise`, category `correctness`). It fires when `Promise.resolve(...)` or `Promise.reject(...)` is called with more than one argument (`args_len > 1`). Both statics accept at most one value; extra arguments are silently ignored at runtime, so a multi-argument call almost always means the author expected behavior that does not exist. The rule's own doc notes it is generally unnecessary under TypeScript, where signatures reject extra args at compile time.","triggerScenarios":"`Promise.resolve(1, 2)`; `Promise.resolve({}, function () {}, 1, 2, 3)`; `Promise.reject(1, 2, 3)`.","commonSituations":"Copy-paste argument lists from call sites into a resolution; intending to pass multiple values and forgetting an array; assuming promise/deferred semantics from other languages or Q/Bluebird.","solutions":["Pass a single value: wrap multiples in a structure (`Promise.resolve([a, b])` or `Promise.resolve({ a, b })`)","If the arguments are multiple promises, use `Promise.all([...])`","Add `tsc --noEmit` to CI - TS reports ts(2554) 'Expected 0-1 arguments, but got 2'"],"exampleFix":"// before\nPromise.resolve(user, settings)\n\n// after\nPromise.resolve({ user, settings })","handlingStrategy":"type-guard","validationCode":"npx oxlint --promise/valid-params src/\n# plus compile-time arity checking:\ntsc --noEmit  # ts(2554): Expected 0-1 arguments, but got 2","typeGuard":"// TypeScript's lib signature `Promise.resolve<T>(value: T): Promise<Awaited<T>>`\n// accepts at most one argument, so extra args are a compile error.\n// Guard: keep files in a tsconfig project and run `tsc --noEmit`.","tryCatchPattern":null,"preventionTips":["Pass one value; wrap multiples in an array or object","Use `Promise.all([...])` for multiple promises","Run `tsc --noEmit` and oxlint in CI so arity mistakes never land"],"tags":["promise","async","lint","arguments","oxlint"],"backgroundTag":"wrong-function-arity","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"}