=+, =- or =! is written where +=, -= or != was likely meant

tx0/ts:swapped-assign-operatordefaultwarningbug

What it finds

x =+ 1: an assignment whose sign is written against the = and apart from its operand reads like x += 1, but assigns +1. The same holds for =- and -=, and for =!, which assigns a negation where != was meant.

Only that spacing is reported: x = -1 and x =-1 say what they do.

From the rule's source, swapped_assign_operator.rs.

Example from the rule's tests
function f(n: number, ok: boolean) {  n =+ 1;tx0 reports: =+ assigns +1; += may have been meant  n =- 2;tx0 reports: =- assigns -2; -= may have been meant  ok =! ok;tx0 reports: =! assigns !ok; != may have been meant  if ((ok =! ok)) {tx0 reports: != may have been meant  }  n = -1;  n = +1;  n =-1;  n += 1;  ok = !ok;  let m =- 1;  return n + m;}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:swapped-assign-operator" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:swapped-assign-operator] reason="..."

tx0 explain tx0/ts:swapped-assign-operator shows the same in the terminal. Found a false positive? Report it.