Skip to content

eslint/no-setter-return Correctness

This rule is turned on by default.

What it does

Setters cannot return values.

Why is this bad?

While returning a value from a setter does not produce an error, the returned value is being ignored. Therefore, returning a value from a setter is either unnecessary or a possible error, since the returned value cannot be used.

Example

javascript
class URL {
  set origin() {
    return true;
  }
}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-setter-return
json
{
  "rules": {
    "no-setter-return": "error"
  }
}

References

Released under the MIT License.