noDecrementDo not use standalone `--`. Use `-= 1` instead.small-rules/no-increment-decrementDisallow standalone `++` and `--` statements and for-loop update clauses.
My reasoning for this rule are pretty much identical to why Swift removed them back in Swift 3.
Low utility relative to the readability loss: these operators only save a few characters compared to
value += 1 or value -= 1. Almost never worth it.
Prefix vs postfix confusion: having both ++value and value++ is confusing. It can also lead to
fun subtle bugs, especially when you nest them inside larger expressions where evaluation order matters.
Redundancy: the increment and decrement operators are redundant with += and -=, which are more
general and therefore more useful. You can increment or decrement by any value, not just 1.
Clarity over brevity: we like to prioritize explicit and readable code. Writing value += 1 makes
the intent immediately clear without requiring anyone to puzzle over operator precedence.
Now, where I differ on Swift is instead of banning it entirely, I allow it for array[size++] = value
expressions. I already prefer doing this over array.push(value) when possible for performance reasons, and
I think the increment operator is a nice shorthand for this specific use case. That is why this rule exists
when the native Oxlint version also does.
noDecrementDo not use standalone `--`. Use `-= 1` instead.noIncrementDo not use standalone `++`. Use `+= 1` instead.This rule accepts one options object after the severity.
size++;After auto-fix
size += 1;size += 1;