Rules
no-instanceof-error
Avoid normalizing caught values using instanceof Error.
Purpose and behavior
Avoid normalizing caught values using instanceof Error.
The rule reports instanceof when its right operand is the Error identifier. The rule ignores other constructors, including TypeError. Store unknown caught values unchanged in a structured error field.
Options
No configurable options. Enable with "rules/no-instanceof-error": "error".
Invalid example
const isError = error instanceof ErrorValid example
new ConfigFileError({ error })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/no-instanceof-error -- reason. Examples cover this rule only and may omit imports or declarations.
Source and tests
Enabled by the Effect preset.