Closed jattasNI closed 2 years ago
This is the original discussion from the airbnb PR: https://ni.visualstudio.com/Users/_git/abarreto-misc/pullrequest/83582
My concern was never really the semicolon insertion discussion, that seems a bit contrived. My concern is the subtleties of the prefix/postfix ++ behavior in expressions that do more than modify a value. ie result = var++
is a tricky pattern where you need to remember the difference between prefix/postfix compared to result = var +=1
where the ambiguity does not exist.
The old school Crockford jslint description is why I'd prefer to avoid it (despite the usual cantankerous tone lol): https://www.jslint.com/help.html
The ++ increment and -- decrement operators have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling to viruses and other security menaces. Also, preincrement/postincrement confusion can produce off-by-one errors that are extremely difficult to diagnose. Fortunately, they are also complete unnecessary. There are better ways to add 1 to a variable.
It is best to avoid these operators entirely and rely on += and -= instead.
They are second only to faulty architecture in enabling to viruses and other security menaces lol indeed!
I should have mentioned it up front but the reason I opened this issue is because (as @mure predicted in the original thread) we got pushback against the rule. Just one more data point, not saying we have to acquiesce to every complaint we hear.
Closing from lack of activity, if there is additional feedback we can re-open
We currently enable
no-plusplus
which bans++
and--
(except as the last clause infor
loops). The rationale in the rule description is that automatic semicolon insertion can make these operators ambiguous:However, we currently require semicolons via
semi
and@typescript-eslint/semi
, so that case shouldn't be possible.If we allow increment and decrement again are there any other issues that could arise?