A value returned from a setter is discarded by every assignment

tx0/ts:setter-value-discardeddefaultwarningbug

What it finds

set name(value) { return this._name = value; }: whatever a setter returns is thrown away, since an assignment evaluates to the value assigned. A return with a value in a setter suggests the author expected it to be used.

From the rule's source, setter_value_discarded.rs.

Example from the rule's tests
class Box {  private v = 0;  set value(v: number) {    if (v < 0) {      return;    }    return (this.v = v);tx0 reports: the value returned from a setter is ignored  }  set other(v: number) {    const check = () => {      return v > 0;    };    this.v = v;  }}
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:setter-value-discarded" = "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:setter-value-discarded] reason="..."

tx0 explain tx0/ts:setter-value-discarded shows the same in the terminal. Found a false positive? Report it.