{"record":{"id":"459d37bbb2caa686","repo":"oxc-project/oxc","slug":"arrow-function-has-too-many-parameters-maxim","errorCode":null,"errorMessage":"Arrow function has too many parameters ({}). Maximum allowed is {}.","messagePattern":"Arrow 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 arrow-function variant of `max-params`. When an arrow function declares more parameters than the configured `max` (default 3, from MaxParamsConfig default), this message is emitted with the \"Arrow function\" prefix. The differentiation lets the diagnostic read naturally at the call site (e.g. inside `.reduce(...)`). Same helper as the other variants: crates/oxc_linter/src/rules/eslint/max_params.rs:19.","triggerScenarios":"Arrow functions with 4+ parameters: `const f = (a, b, c, d) => {}`, `.reduce((acc, cur, idx, arr) => ...)` with default max 3, or React render props taking many arguments. Rest parameters (`...args`) count as one parameter.","commonSituations":"Reduce/filter callbacks (4 spec parameters) against the default max of 3; event-handler lambdas accreting flags; switching a function expression to an arrow function and suddenly seeing the message wording change; strict configs lowering max to 2.","solutions":["Destructure parameters into an object: `({ acc, value, index }) => ...` reduces the count to one and improves readability.","Raise `max` to 4 (the natural reduce signature) in `.oxlintrc.json` if array-callback style is common.","Extract the arrow body into a named function with an options-object signature."],"exampleFix":"// before\nconst merge = (target, source, overwrite, deep, trackChanges) => { /* ... */ };\n\n// after\nconst merge = (target, { source, overwrite = false, deep = true, trackChanges = null }) => {\n  /* ... */\n};","handlingStrategy":"validation","validationCode":"// Prefer single destructured-object params for arrows:\nconst handler = ({ user, order, retry }) => { /* ... */ }; // 1 param\n// CI: oxlint --rule max-params=4 src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Destructure at the parameter list — one object parameter is both lint-clean and self-documenting.","For reduce, either configure max=4 or use only the leading parameters you need.","Watch curried arrow chains ((a) => (b) => (c)): each arrow is counted separately, which is fine — do not inline them all into one multi-param arrow to 'save' calls."],"tags":["eslint","oxlint","complexity","arrow-function","parameters"],"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-14T00:17:10.932Z"}