{"record":{"id":"32233e9a3b64d82c","repo":"oxc-project/oxc","slug":"function-has-too-many-parameters-maximu","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 named-function variant of the `max-params` diagnostic. The rule counts a function's parameters (including default/rest parameters) and reports when the count exceeds `max`, defaulting to 3 with optional `countThis`/`countVoidThis` semantics (crates/oxc_linter/src/rules/eslint/max_params.rs:68-71). This message template includes the function's name (e.g. `Function 'createUser' has too many parameters (5). Maximum allowed is 3.`). The diagnostic is built at crates/oxc_linter/src/rules/eslint/max_params.rs:19.","triggerScenarios":"Declare a named function, method, or function declaration with more parameters than `max`: `function transform(input, options, logger, cache, flags) {}` (5 > 3 default). `this` parameters are ignored unless `countThis` is enabled; a lone `void this` marker is never counted.","commonSituations":"Functions that grew one flag at a time during feature work; positional configuration APIs predating an options-object refactor; test factories with many optional arguments; enabling the rule with default max 3 across a mature codebase produces many reports at once.","solutions":["Group related parameters into an options object: `function transform(input, { options, logger, cache, flags })` — keeps call sites self-documenting.","Raise the limit via config `{ \"max-params\": [\"error\", 5] }` if the team accepts wider signatures.","Use a builder or config-carrying struct/class when many parameters are genuinely independent."],"exampleFix":"// before\nfunction createUser(name, email, role, team, sendWelcome, audit) { /* ... */ }\n\n// after\nfunction createUser(\n  name,\n  { email, role = 'member', team, sendWelcome = true, audit } = {},\n) { /* ... */ }","handlingStrategy":"validation","validationCode":"// CI gate: oxlint --rule max-params=3 src/\n// Signature check before review: count positional params; >3 -> switch to an options object.","typeGuard":"// Narrowing-style guard for config-style calls (TypeScript):\ntype CreateUserOptions = { email: string; role?: string; team?: string };\nfunction createUser(name: string, opts: CreateUserOptions) { /* ... */ }","tryCatchPattern":null,"preventionTips":["Default to (subject, options-object) signatures for anything with more than two inputs.","When a parameter must be added, ask whether it belongs to a config object instead of position four-plus.","Rest params count as one — but do not abuse `...args` to dodge the rule; it hides the real signature."],"tags":["eslint","oxlint","complexity","function-signature","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-14T05:17:10.506Z"}