oxc-project/oxc · error · OxcDiagnostic

Assignment to function parameter '{name}'.

Error message

Assignment to function parameter '{name}'.

What it means

Lint diagnostic from eslint/no-param-reassign: a value is assigned directly to a function parameter. Reassignment obscures the original argument, breaks reliance on arguments, and can unintentionally mutate caller-visible state for object semantics in some engines/toolchains.

Source

Thrown at crates/oxc_linter/src/rules/eslint/no_param_reassign.rs:20

use rustc_hash::FxHashSet;
use schemars::JsonSchema;
use serde::Deserialize;

use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_ecmascript::BoundNames;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::{AstNode, NodeId};
use oxc_span::Span;

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

fn assignment_to_param_diagnostic(name: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Assignment to function parameter '{name}'."))
        .with_help("Consider using a different variable to avoid unintended side effects on the parameter.")
        .with_label(span)
}

fn assignment_to_param_property_diagnostic(name: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Assignment to property of function parameter '{name}'."))
        .with_help("Consider using a different variable to avoid unintended side effects on the parameter's properties.")
        .with_label(span)
}

#[derive(Debug, Default, Clone, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
struct NoParamReassignConfig {
    /// When true, also check for modifications to properties of parameters.
    props: bool,
    /// An array of parameter names whose property modifications should be ignored.
    ignore_property_modifications_for: FxHashSet<String>,
    /// An array of regex patterns (as strings) for parameter names whose property modifications should be ignored.

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Copy the parameter into a local variable and mutate that
  2. Use a propsObject/option-preserving pattern for options objects
  3. Configure props/ignorePropertyModificationsFor if parameter mutation is intentional
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/eslint/no_param_reassign.rs:20 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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