{"record":{"id":"e5ea916bf53b689e","repo":"oxc-project/oxc","slug":"promise-prop-name-requires-1-or-2-arguments","errorCode":null,"errorMessage":"`Promise.{prop_name}()` requires 1 or 2 arguments, but received {args_len}.","messagePattern":"`Promise\\.(.+?)\\(\\)` requires 1 or 2 arguments, but received (.+?)\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/promise/valid_params.rs","lineNumber":24,"sourceCode":"use 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!(\n        \"`Promise.{prop_name}()` requires 1 argument, but received {args_len}.\"\n    ))\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ValidParams;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/promise/valid_params.rs#L6-L42","documentation":"Diagnostic from the oxlint rule `promise/valid-params` (plugin `promise`, category `correctness`). It fires when `.then(...)` is called with an argument count other than 1 or 2 (0 callbacks, or 3+). `then` takes an optional fulfillment handler and an optional rejection handler - a third argument does nothing, and zero arguments means the call is a pure no-op that still allocates a new promise.","triggerScenarios":"`somePromise().then()` (0 args); `somePromise().then(a, b, c)` (3+ args); `promiseReference.then(() => {}, () => {}, () => {})`.","commonSituations":"Passing a third callback intended as a finally-style handler; refactoring that deleted the callback but left `.then()`; spreading arrays of handlers into `then`.","solutions":["Pass exactly one or two handler functions to `then`","Move cleanup logic to `.finally(fn)` instead of a third `then` argument","Delete empty `.then()` links from the chain","Add `tsc --noEmit` to CI so arity errors surface at compile time"],"exampleFix":"// before\np.then(onSuccess, onFailure, onFinally)\n\n// after\np.then(onSuccess, onFailure).finally(onFinally)","handlingStrategy":"type-guard","validationCode":"npx oxlint --promise/valid-params src/\ntsc --noEmit  # flags then() with 0 or 3+ args via ts(2554)","typeGuard":"// lib signature: then<TResult1, TResult2>(\n//   onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,\n//   onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null\n// ): PromiseLike<TResult1 | TResult2>;  // exactly 2 optional params - a 3rd arg fails tsc","tryCatchPattern":null,"preventionTips":["Give `then` one or two handlers only; use `.finally()` for cleanup","Delete empty `.then()` no-ops left by refactors","Keep `tsc --noEmit` in CI to catch arity drift at compile time"],"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"}