-
Notifications
You must be signed in to change notification settings - Fork 885
What does ban-comma-operator do? #3380
Comments
It bans this thing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator It catches not so obvious bugs like: switch (foo) {
case 1, 2: // equals `case 2` - probably intended `case 1: case2:`
return true;
case 3:
return false;
}
foo((bar, baz)); // evaluates to `foo(baz)` because of the extra parens |
Gotcha, ok I was not even aware some of that was even possible, good to know! This seems like a good rule that just needs some "PR help". Below are my suggestions based on my current understanding, please feel free to improve upon them. Rule failure message
Rule Description
Rule Rational
|
I like it. Thanks for the suggestions |
Fixed by #3384 |
I saw the new rule
ban-comma-operator
was added, but the documentation literally just repeats the name of the rule and add the word "the" which is not helpful.It's like a dictionary definition referencing the word you are trying to understand.
Looking at the source wasn't helpful since the failure message just says "don't do this" without any reasoning as to why. The test file sheds a little bit of light on this, but not enough for me to understand what problem this rule solves.
I believe @calebegg is the author for this rule - could you possibly shed some light on this and add a more descriptive rule description, and the rationale behind it?
The text was updated successfully, but these errors were encountered: