A condition is an assignment, which may be a mistyped comparison

tx0/ts:cond-assignrecommendedwarningbug

What it finds

if (user = current): an assignment where a condition is expected is often a comparison that lost an =.

The conditions of if, while, do-while and for are checked. Only assignments of a value that reads like the other side of a comparison are reported: a literal, a variable or a property. Assigning the result of a call and testing it, as in while (node = queue.shift()), is a common idiom and left alone, and so is an assignment wrapped in a second pair of parentheses, the usual way to say it is meant. Compound assignments such as += are not mistaken comparisons either.

From the rule's source, cond_assign.rs.

Example from the rule's tests
function find(user: { admin: boolean } | null, current: { admin: boolean }, queue: number[]) {  if (user = current) {tx0 reports: user = current assigns; did you mean to compare?    return 1;  }  let size = 0;  while (size = 0) {tx0 reports: size = 0 assigns    size++;  }  let item;  while (item = queue.shift()) {    size += item;  }  if ((user = current)) {    return 2;  }  for (; size = current.admin ? 1 : 0;) {    break;  }  return size;}
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 from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:cond-assign" = "warning"

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:cond-assign] reason="..."

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