Rules
force-iterable-empty
Use Iterable.isEmpty rather than size-based emptiness checks.
Purpose and behavior
Use Iterable.isEmpty rather than size-based emptiness checks.
Checks non-computed Iterable.size calls compared with 0 or 1, using the same classification as force-array-empty. Other namespaces and arbitrary size thresholds are ignored. Negate Iterable.isEmpty for non-empty checks.
Options
No configurable options. Enable with "rules/force-iterable-empty": "error".
Invalid example
if (Iterable.size(xs) === 0) {}Valid example
if (Iterable.isEmpty(xs)) {}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-iterable-empty -- reason comment. Examples illustrate this rule alone and may omit imports and declarations.
Source and tests
Enabled by the Effect preset.