Rules

no-option-tag-comparison

Use Option.isSome and Option.isNone instead of comparing _tag.

Purpose and behavior

Use Option.isSome and Option.isNone instead of comparing _tag.

Recognizes comparisons against Some and None and supplies a predicate replacement. This is syntax-based, not a type check proving the object is an Option. Ensure the Option identifier is available when accepting the fix.

Options

No configurable options. Enable with "rules/no-option-tag-comparison": "error".

Invalid example

if (opt._tag === 'Some') {}

Valid example

if (Option.isSome(opt)) {}

Fixes and exceptions

This rule supplies an automatic code fix. Review the resulting import bindings and runtime resolution before applying it.

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

Source and tests

Enabled by the Effect preset.

no-option-tag-comparison.ts · Tests