Rules

require-top-level-decoder

Construct and cache schema decoders at module scope.

Purpose and behavior

Construct and cache schema decoders at module scope.

Inside any tracked function, reports calls whose non-computed member is Schema.decode* or HttpClientResponse.schema*. Hoist construction and invoke the cached function inside the workflow. The listener matches prefixes and names, not type information.

Options

No configurable options. Enable with "rules/require-top-level-decoder": "error".

Invalid example

const f = () => Schema.decodeEffect(schema)(input)

Valid example

const decode = Schema.decodeEffect(schema)
const f = () => decode(input)

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/require-top-level-decoder -- reason comment. Examples illustrate this rule alone and may omit imports and declarations.

Source and tests

Enabled by the Effect preset.

require-top-level-decoder.ts · Tests