Rules

require-top-level-decoder

Construct and cache schema decoders at module scope.

Purpose and behavior

Construct and cache schema decoders at module scope.

The rule reports Schema.decode* and HttpClientResponse.schema* calls inside tracked functions. The rule matches names and prefixes, not types, and ignores bracket calls. Construct the decoder at module scope. Call the cached decoder inside the workflow.

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 provides no automatic fix. Rewrite the code to preserve its intended behavior.

For a boundary exception, use oxlint-disable-next-line rules/require-top-level-decoder -- reason. Examples cover this rule only and may omit imports or declarations.

Source and tests

Enabled by the Effect preset.

require-top-level-decoder.ts · Tests