menu

no-useless-length-check

Disallow length checks duplicated by the guarded array operation

every returns true for an empty array, and some returns false. Separate length guards duplicate these results. Instead, you SHOULD use the array operation directly.

Reported

1function allPositive(values: int32[]): boolean {2    return values.length === 0 || values.every((value) => value > 0);3}

Accepted

1function allPositive(values: int32[]): boolean {2    return values.every((value) => value > 0);3}