Rules

force-array-empty

Use Effect Array predicates for empty and non-empty checks.

Purpose and behavior

Use Effect Array predicates for empty and non-empty checks.

Reports recognized .length comparisons against 0 or 1, including reversed operands. Arbitrary thresholds, impossible negative checks and tautologies are ignored. This syntax-only rule does not prove the receiver is an array.

Options

No configurable options. Enable with "rules/force-array-empty": "error".

Invalid example

if (arr.length === 0) {}

Valid example

if (Array.isEmpty(arr)) {}

Fixes and exceptions

This rule reports diagnostics without an automatic fix. Rewrite the code deliberately rather than guessing its intended semantics.

For a genuine boundary exception, use an oxlint-disable-next-line rules/force-array-empty -- reason comment. Examples illustrate this rule alone and may omit imports and declarations.

Source and tests

Enabled by the Effect preset.

force-array-empty.ts · Tests