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.
The rule reports .length comparisons with 0 or 1 that test emptiness, including reversed operands. The rule ignores other thresholds, impossible negative checks and always-true checks. It checks syntax, not whether 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.isArrayEmpty(arr)) {}Fixes and exceptions
This rule provides no automatic fix. Rewrite the code to preserve its intended behavior.
For a boundary exception, use oxlint-disable-next-line rules/force-array-empty -- reason. Examples cover this rule only and may omit imports or declarations.
Source and tests
Enabled by the Effect preset.