menu

prefer-equality-over-pattern

Prefer equality over matching one complete scalar constant

A two-arm match that maps one scalar constant and a wildcard to opposite booleans only performs an equality test. Instead, you SHOULD compare the scrutinee with the constant directly.

Reported

1function isZero(value: int32): boolean {2    return match (value) {3        0 => true4        _ => false5    };6}

Accepted

1function isZero(value: int32): boolean {2    return value === 0;3}