no-equal-nested-conditions
preset: recommended
Warns when an if statement contains another if statement with the same condition.
Example
❌ Bad:
if (value == 1) {
// LINT: Avoid duplicate conditions in nested 'if/else if'. Try replacing the duplicate condition or removing it.
if (value == 1) {
...
}
}
if (value == 1) {
...
// LINT: Avoid duplicate conditions in nested 'if/else if'. Try replacing the duplicate condition or removing it.
if (value == 1) {
...
}
}
✅ Good:
if (value != 1) {
if (value == 1) { // Correct, different condition
...
}
}
if (value != 1) {
...
if (value == 1) {
...
}
}