Rules
force-predicate
Replace direct null, undefined and typeof comparisons with predicates.
Purpose and behavior
Replace direct null, undefined and typeof comparisons with predicates.
The rule reports null/undefined equality checks and supported typeof string comparisons. The rule ignores numeric comparisons. With prefer-is-nullish enabled, use Predicate.isNullish or isNotNullish unless you need to distinguish null from undefined.
Options
No configurable options. Enable with "rules/force-predicate": "error".
Invalid example
if (typeof x === 'string') {}Valid example
if (Predicate.isString(x)) {}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-predicate -- reason. Examples cover this rule only and may omit imports or declarations.
Source and tests
Enabled by the Effect preset.