Rules
no-error-cause-option
Preserve raw errors using an explicit error field.
Purpose and behavior
Preserve raw errors using an explicit error field.
Reports new Error calls whose second object argument contains cause. Other constructors such as TypeError are outside this rule. Prefer an application error type that carries the original error rather than rebuilding its message.
Options
No configurable options. Enable with "rules/no-error-cause-option": "error".
Invalid example
new Error('boom', { cause: error })Valid example
new ConfigFileError({ error })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/no-error-cause-option -- reason comment. Examples illustrate this rule alone and may omit imports and declarations.
Source and tests
Enabled by the Effect preset.