Skip to content

feat: add catchChainToFirstSuccessOf diagnostic - #456

Merged
mattiamanzati merged 1 commit into
mainfrom
feat/catch-chain-to-first-success-of
Jul 27, 2026
Merged

feat: add catchChainToFirstSuccessOf diagnostic#456
mattiamanzati merged 1 commit into
mainfrom
feat/catch-chain-to-first-success-of

Conversation

@mattiamanzati

Copy link
Copy Markdown
Contributor

Summary

  • add the catchChainToFirstSuccessOf style diagnostic for consecutive error-independent Effect.catch fallbacks
  • support pipeable, free-pipe, and nested data-first chains and report the outermost catch
  • require the inferred Effect.firstSuccessOf error channel to match the chained catch result, including guards for any and annotated handler returns
  • recommend Effect.suspend around fallbacks to preserve lazy Effect construction
  • add Effect v4 fixtures, generated baselines, metadata, schema, README documentation, and a minor changeset

Example

const program = primary.pipe(
  Effect.catch(() => secondary),
  Effect.catch(() => tertiary)
)

The diagnostic recommends expressing the prioritized fallback with Effect.firstSuccessOf, while preserving callback laziness with Effect.suspend. Chains are not reported when firstSuccessOf would widen the final error channel.

Validation

  • pnpm setup-repo
  • pnpm lint
  • pnpm check
  • pnpm test

Closes #439

@mattiamanzati
mattiamanzati merged commit bb09f28 into main Jul 27, 2026
4 checks passed
@mattiamanzati
mattiamanzati deleted the feat/catch-chain-to-first-success-of branch July 27, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rule proposal: chained Effect.catch fallbacks instead of firstSuccessOf, and empty firstSuccessOf collections

1 participant