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-plusplus
with 'allowForLoopAfterthoughts': true
fails if the afterthought contains multiple ++
or --
statements
#13005
Comments
Hi @erhsparks, thanks for the issue! In my opinion, this should be treated as a bug.
It already sounds like |
We could also fix these false negatives: /* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
for (i++; j++;); |
Agreed, seems like a bug. |
I agree with treating it as a bug. 👍 |
Marking as accepted because 3 team members agree this is a bug. I'm working on this. |
Thanks, all! |
…nt#13005) (eslint#13024) * Fix: no-plusplus allow comma operands in for afterthought (fixes eslint#13005) * Allow deep sequence operands
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
babel-eslint
Please show your full configuration:
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.
What did you expect to happen?
Expected eslint not to error on
i++
andj++
because{ 'allowForLoopAfterthoughts': true }
is specifiedWhat actually happened? Please include the actual, raw output from ESLint.
I was able to fix the warning by changing
i++, j++
->i += 1, j += 1
, but this is something of an antipattern.Yes, there are other ways to write this, i.e.
work just fine, but:
a) I'm updating eslint on a large codebase, so I'd prefer to make as few changes as possible.
b) refactors for this simple example aside, this feels like a bug to me.
If this is the intended behaviour because as touched on in the no-plusplus docs there are unintended consequences, then I'd suggest updating that doc to specifically call out that you can only override this rule if the for loop afterthought consists only of one single
++
or--
. (for example, changing the for loop to the hideous...; i += 1, j++)
as an experiment still errors onj++
because the afterthought is a larger expression)The text was updated successfully, but these errors were encountered: