New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[no-sequences] does not trigger if comma is used in parentheses as part of a condition #14184
Comments
it was by design, per the docs:
you can entirely disallow comma operator with the {
"rules": {
"no-restricted-syntax": ["error", "SequenceExpression"]
}
} |
Hi @aladdin-add The code example above is from our real code base, and it took me over an hour to track down the bug, because the faulty behavior is hidden in an short-circuiting AND expression. The improvement I am suggesting would have helped a lot here. OTOH, the mentioned code base makes use of for-loops with multiple initializations, so completely disabling the comma operator is also not desirable... |
agreed it make sense to add an option to support it! |
It seems difficult to define this. What would be examples of a code with comma sequences that should pass? |
just an option to report comma-sequence in parentheses (eslint ignore it atm). IMHO, the option could be enabled by default in next major release. |
Then, if the option is enabled, the rule would report all comma sequences except for those in for-loops? In other words, the option would just skip this check? |
yes! |
Makes sense to me 👍 @danielrentz I marked this issue as "works as intended" since it's indeed the intended behavior. If you agree with the solution to add an option described above, then could you please open a rule change request issue? That way, it would be much easier for the team to evaluate a concrete proposal. |
@mdjermanovic Yes, an option to skip (or enable) the "in-parentheses" exception would be fine for me. |
Thanks! Then, I'm closing this in favor of #14197 |
Tell us about your environment
Node version: v12.16.2
npm version: v6.14.4
Local ESLint version: v7.21.0 (Currently used)
Operating System:
Win10
What parser (default,
@babel/eslint-parser
,@typescript-eslint/parser
, etc.) are you using?default
Please show your full configuration:
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Actual code:
Intended was
What did you expect to happen?
When a comma-sequence in parentheses is part of a longer expression (arithmetic, logical, ...), this rule should not let it pass.
The text was updated successfully, but these errors were encountered: