question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add "allowStandalone" option to rule "no-plusplus".

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Jan 9, 2017

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!

0reactions
rkirslingcommented, Jan 9, 2017

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. 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-plusplus - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
How do you disable no-plusplus when using eslint?
You can just override it in your .eslintrc.js file as follows: 'no-plusplus': 'off'. or if you don't want to disable it completely but...
Read more >
Adding code quality checks with ESLint - Packt Subscription
See https://eslint.org/docs/rules/no-empty for a specific example with the no-empty rule, which disallows empty blocks of code but has an extra option to allow...
Read more >
no-plusplus with 'allowForLoopAfterthoughts': true fails if the ...
In my opinion, this should be treated as a bug. "allowForLoopAfterthoughts": true allows unary operators ++ and -- in the afterthought (final ...
Read more >
disallow the unary operators ++ and -- (no-plusplus) - ESLint
This rule has an object option. "allowForLoopAfterthoughts": true allows unary operators ++ and -- in the afterthought (final expression) of a for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found