Skip to content

noMultiAssign

  • Rule available since: v2.3.11
  • Diagnostic Category: lint/style/noMultiAssign
  • This rule isn’t recommended, so you need to enable it.
  • This rule doesn’t have a fix.
  • The default severity of this rule is information.
  • Sources:
biome.json
{
"linter": {
"rules": {
"style": {
"noMultiAssign": "error"
}
}
}
}

Disallow use of chained assignment expressions

Chaining the assignment of variables can lead to unexpected results and be difficult to read.

const foo = bar = "baz";
code-block.js:1:7 lint/style/noMultiAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unexpected chained assignment.

> 1 │ const foo = bar = “baz”;
^^^^^^^^^^^^^^^^^
2 │

Variables with chained assignments in declarations may cause unintended implicit globals or unexpected scoping.

Split into separate assignments.

const foo = "baz";
const bar = "baz";