menu

no-invalid-clamp

Disallow clamp calls with invalid constant bounds

A clamp traps when its lower bound exceeds its upper bound or either bound is NaN. Instead, you MUST pass ordered bounds that are not NaN.

Reported

1function bounded(value: int32): int32 {2    return value.clamp(10, 0);3}

Accepted

1function bounded(value: int32): int32 {2    return value.clamp(0, 10);3}