Add "allowStandalone" option to rule "no-plusplus".
See original GitHub issueThe stated purpose of no-plusplus
is to prevent errors caused by ASI/whitespace interaction; however, since such errors are already covered by space-unary-ops
, semi
, and semi-spacing
, this rule really just eliminates syntax from the language, which seems to me a little extreme.
The allowForLoopAfterthoughts
option is a step in the right direction, but falls just short of addressing a major concern in languages with ++
/ --
: namely, these operators are confusing to reason about in the presence of other operations.
As such, I’d like to propose an allowStandalone
option, which allows ++
/ --
to be used as the sole operation in a statement, instead of demanding that they be rewritten as += 1
/ -= 1
.
Incorrect
if (++foo > 3) { ... }
const bar = 10 * foo++;
doStuff(--foo);
return foo--;
Correct
++foo;
foo++;
--foo;
foo--;
// ...which should, of course, be taken to include:
foo.bar++;
foo[bar]++;
Whether this option should subsume allowForLoopAfterthoughts
or stand separately is open for discussion. (I was initially assuming the former, but the latter would likely be easier to use.)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Understand the confusion. By “reaching consensus” I mean the process of accepting the issue (which the team has decided requires a champion and three upvotes from the team). Can definitely make that clearer in the future.
We’ve found that issues that get buried in the backlog without getting accepted end up getting lost (as can be evidenced by the lack of discussion here). Keeping our issues backlog manageable is necessary for keeping the project moving forward, both for us maintainers and also for our contributors.
Feel free to open a new issue with your proposal - chances are much higher it’ll get some attention when it’s not 6 pages into our issues list!
I’m not sure if I follow what you mean by “consensus”…? There’s no expressed disagreement here, only silence (and a correction to a simple mistake). My understanding was that the resources would be my own if the rule was deemed acceptable.
I respect the policy to close versus indefinitely defer, but the “evaluating” label seems misleading if the issue is closed without any evidence of evaluation. 😕