1 # Disallow returning values from setters (no-setter-return)
3 Setters cannot return values.
5 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.
9 This rule disallows returning values from setters and reports `return` statements in setter functions.
11 Only `return` without a value is allowed, as it's a control flow statement.
13 This rule checks setters in:
16 * Class declarations and class expressions.
17 * Property descriptors in `Object.create`, `Object.defineProperty`, `Object.defineProperties`, and `Reflect.defineProperty` methods of the global objects.
19 Examples of **incorrect** code for this rule:
22 /*eslint no-setter-return: "error"*/
48 Object.defineProperty(foo, "bar", {
58 Examples of **correct** code for this rule:
61 /*eslint no-setter-return: "error"*/
85 Object.defineProperty(foo, "bar", {
88 throw new Error("Negative value.");
97 * [MDN setter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set)
101 * [getter-return](getter-return.md)