Rules

no-opaque-instance-fields

Keep Schema.Opaque classes free of instance members.

Purpose and behavior

Keep Schema.Opaque classes free of instance members.

Official Effect rule. Tracks Schema/Opaque named imports from effect or effect/Schema and namespace imports from effect/Schema, including aliases. Detects classes extending the two-call Opaque construction pattern. Reports non-static properties and methods, including constructors, but allows static members and empty classes. It does not recognize arbitrary wrappers or inherited aliases.

Options

No configurable options. Enable with "rules/no-opaque-instance-fields": "error".

Invalid example

import * as Schema from 'effect/Schema'
class User extends Schema.Opaque('User')(Schema.String) { value = 1 }

Valid example

import * as Schema from 'effect/Schema'
class User extends Schema.Opaque('User')(Schema.String) { static label = 'User' }

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-opaque-instance-fields -- reason comment. Examples illustrate this rule alone and may omit imports and declarations.

Source and tests

Enabled by the Effect preset.

no-opaque-instance-fields.ts · Tests