Reference jsfiddle
var obj = {
set bla(k) {
console.log(k);
}
};
JSHint flags this as "setter is defined without getter". I am sure there is a way to turn this off, but why is this an error at all? Everything I have seen JSHint flag has had a reasonable explanation. I can't come up with a reason for why this is a bad thing.
I don't think JSHint has a good reason to warn about this situation. I don't see anything in the specification (http://www.ecma-international.org/publications/standards/Ecma-262.htm, pages 30-31) that requires there to be a getter if there is a setter or vice versa, and it is easy to imagine a setter that doesn't imply a getter. For example, you might want to set a dirty flag in a setter. There would be no reason to define a getter.
I did not see a justification in the JSHint source, or its history.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With