oxc-project/oxc · error · OxcDiagnostic

Do not use chained assignment

Error message

Do not use chained assignment

What it means

Lint diagnostic from eslint/no-multi-assign: an assignment expression is chained (a = b = c). Chained assignment makes the intermediate value flow hard to follow and frequently hides unintended sharing of references.

Solutions

  1. Split the chain into separate assignment statements
  2. Initialize each variable with its own expression
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/eslint/no_multi_assign.rs:15 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/cb1c675a7c37a666. Report an issue: GitHub.

Appendix: source

Thrown at crates/oxc_linter/src/rules/eslint/no_multi_assign.rs:15

use oxc_ast::{AstKind, ast::Expression};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use schemars::JsonSchema;
use serde::Deserialize;

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

fn no_multi_assign_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Do not use chained assignment")
        .with_help("Separate each assignment into its own statement")
        .with_label(span)
}

#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct NoMultiAssign {
    /// When set to `true`, the rule allows chains that don't include initializing a variable in a declaration or initializing a class field.
    ///
    /// Examples of **correct** code for this option set to `true`:
    /// ```js
    /// let a;
    /// let b;
    /// a = b = "baz";
    ///
    /// const x = {};
    /// const y = {};
    /// x.one = y.one = 1;

View on GitHub (pinned to e1e7af627c)