Skip to content

No Increment Decrement

SuggestionAuto-fixable
small-rules/no-increment-decrement

Disallow standalone `++` and `--` statements and for-loop update clauses.

Diagnostic Messages

noDecrement
Do not use standalone `--`. Use `-= 1` instead.
noIncrement
Do not use standalone `++`. Use `+= 1` instead.

Configuration

This rule accepts one options object after the severity.

allowAutofixOptional

Allow the fixer to replace standalone ++ and -- statements and for-loop updates.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-increment-decrement": [
"error",
{
"allowAutofix": false
}
]
}
}

Examples

Post-increment compound assignment fix
size++;

After auto-fix

size += 1;
Compound assignment is allowed
size += 1;