menu

no-redundant-match-guard

Prefer literal patterns over equivalent equality guards

An equality guard on a newly bound match value repeats a test that the pattern can perform directly. Instead, you SHOULD match the compared literal in the arm pattern.

Reported

1function classify(value: int32): string {2    return match (value) {3        matched if (matched === 0) => "zero"4        _ => "other"5    };6}

Accepted

1function classify(value: int32): string {2    return match (value) {3        0 => "zero"4        _ => "other"5    };6}