oxc-project/oxc · warning · OxcDiagnostic

Arrow function has too many parameters ({}). Maximum allowed

Error message

Arrow function has too many parameters ({}). Maximum allowed is {}.

What it means

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.

Source

Thrown at crates/oxc_linter/src/rules/eslint/max_params.rs:19

use oxc_ast::{
    AstKind,
    ast::{TSFunctionType, TSType},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use schemars::JsonSchema;
use serde::Deserialize;
use serde_json::Value;

use crate::{
    AstNode,
    context::LintContext,
    rule::{DefaultRuleConfig, Rule},
};

fn max_params_diagnostic(message: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(message.to_string())
        .with_help(
            "This rule enforces a maximum number of parameters allowed in function definitions.",
        )
        .with_label(span)
}

#[derive(Debug, Default, Clone, Deserialize)]
pub struct MaxParams(Box<MaxParamsConfig>);

#[derive(Debug, Clone, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct MaxParamsConfig {
    /// Maximum number of parameters allowed in function definitions.
    #[serde(alias = "maximum")]
    max: u32,
    /// This option controls when to count a `this` parameter.
    ///
    /// - "always": always count `this`

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Destructure parameters into an object: `({ acc, value, index }) => ...` reduces the count to one and improves readability.
  2. Raise `max` to 4 (the natural reduce signature) in `.oxlintrc.json` if array-callback style is common.
  3. Extract the arrow body into a named function with an options-object signature.

Example fix

// before
const merge = (target, source, overwrite, deep, trackChanges) => { /* ... */ };

// after
const merge = (target, { source, overwrite = false, deep = true, trackChanges = null }) => {
  /* ... */
};
Defensive patterns

Strategy: validation

Validate before calling

// Prefer single destructured-object params for arrows:
const handler = ({ user, order, retry }) => { /* ... */ }; // 1 param
// CI: oxlint --rule max-params=4 src/

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/459d37bbb2caa686. Report an issue: GitHub.