no-equal-then-else
added in: 1.10.0
warning
Warns when if statement has equal then and else statements or conditional expression has equal then and else expressions.
info
The fix for this rule is available only in "Teams" version.
Example
❌ Bad:
final firstValue = 1;
final secondValue = 2;
...
// LINT
if (condition) {
result = firstValue;
} else {
result = firstValue;
}
...
result = condition ? firstValue : firstValue; // LINT
✅ Good:
final firstValue = 1;
final secondValue = 2;
...
if (condition) {
result = firstValue;
} else {
result = secondValue;
}
...
result = condition ? firstValue : secondValue;