{"record":{"id":"aadec5a02d62abe2","repo":"oxc-project/oxc","slug":"function-has-too-many-parameters-maximum-all","errorCode":null,"errorMessage":"Function has too many parameters ({}). Maximum allowed is {}.","messagePattern":"Function has too many parameters \\((.+?)\\)\\. Maximum allowed is (.+?)\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/max_params.rs","lineNumber":19,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{TSFunctionType, TSType},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\nuse serde_json::Value;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn max_params_diagnostic(message: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(message.to_string())\n        .with_help(\n            \"This rule enforces a maximum number of parameters allowed in function definitions.\",\n        )\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct MaxParams(Box<MaxParamsConfig>);\n\n#[derive(Debug, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct MaxParamsConfig {\n    /// Maximum number of parameters allowed in function definitions.\n    #[serde(alias = \"maximum\")]\n    max: u32,\n    /// This option controls when to count a `this` parameter.\n    ///\n    /// - \"always\": always count `this`","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/max_params.rs#L1-L37","documentation":"The anonymous-function variant of `max-params`. Identical semantics to the named variant — parameter count exceeds `max` (default 3) — but the message template says \"Function has too many parameters\" because the diagnostic cannot anchor a name (anonymous function expression or IIFE). Produced by the same `max_params_diagnostic` helper at crates/oxc_linter/src/rules/eslint/max_params.rs:19.","triggerScenarios":"Anonymous function expressions passed as callbacks with 4+ parameters: `array.reduce((acc, item, idx, arr, extra) => ...)` under a max of 3 (note reduce's own callback takes up to 4 by spec), `request('/x', function (err, res, body, next) {})`, or multi-arg IIFEs. Counting includes rest/default params.","commonSituations":"Array method callbacks whose spec-defined signatures already consume the budget (reduce has 4 params: accumulator, value, index, array); jQuery-style multi-argument callbacks; strict max configs (2) combined with reduce/map callbacks; anonymous middleware functions in Express-style stacks.","solutions":["Wrap multi-arg callbacks in a named helper that takes an options/aggregate argument, or destructure: `.reduce((acc, { value, index }) => ...)`.","Increase `max` to 4 in config to accommodate standard array-callback signatures like reduce's.","Convert the anonymous function into a named function with an options object so the signature is explicit and greppable."],"exampleFix":"// before\nconst total = items.reduce(function (acc, item, index, array) {\n  return acc + item.price * (index < array.length - 1 ? 1 : 0.9);\n}, 0);\n\n// after\nconst total = items.reduce((acc, item, index, array) =>\n  acc + item.price * (index < array.length - 1 ? 1 : 0.9), 0);","handlingStrategy":"validation","validationCode":"// Validate callback arity before passing it, especially for reduce (4 spec params):\n// config: { \"max-params\": [\"error\", 4] } accommodates standard array callbacks.\n// oxlint src/ gates the PR.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Know each array method's callback signature: reduce takes 4 (acc, value, index, array) — configure max >= 4 if you use the full form.","Omit unused trailing callback parameters instead of declaring them.","Prefer destructuring in the callback parameter to keep the count low and the intent explicit."],"tags":["eslint","oxlint","complexity","function-signature","parameters","anonymous-function"],"backgroundTag":"too-many-parameters","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"}