Skip to content

Latest commit

 

History

History
70 lines (57 loc) · 1.82 KB

catch-chain-to-first-success-of.md

File metadata and controls

70 lines (57 loc) · 1.82 KB

catchChainToFirstSuccessOf

Suggests Effect.firstSuccessOf for consecutive error-independent Effect.catch fallbacks when the error type is preserved

Property Value
Category Style
Default severity suggestion
Fixable No
Effect versions v4
Diagnostic codes TS377107
Language Service name catchChainToFirstSuccessOf
Oxlint name effecttsgo/catch-chain-to-first-success-of

Preview

import { Effect } from "effect"

declare const primary: Effect.Effect<string, Error>
declare const secondary: Effect.Effect<string, Error>
declare const tertiary: Effect.Effect<string, Error>

export const preview = primary.pipe(
  Effect.catch(() => secondary),
  Effect.catch(() => tertiary)
/**
  ^^^^^^^^^^^^ effecttsgo(catch-chain-to-first-success-of): Chained Effect.catch fallbacks that ignore the error can be written with Effect.firstSuccessOf. Wrap each lazy fallback with Effect.suspend to preserve when it is constructed.
*/
)

Language Service Configuration

See the Language Service setup guide for installation instructions.

{
  "$schema": "./node_modules/@effect/tsgo/schema.json",
  "compilerOptions": {
    "plugins": [
      {
        "name": "@effect/language-service",
        "diagnosticSeverity": {
          "catchChainToFirstSuccessOf": "warning"
        }
      }
    ]
  }
}

Oxlint Configuration

See the Oxlint setup guide for installation and patching instructions.

{
  "$schema": "./node_modules/@effect/tsgo/oxlint-schema.json",
  "options": {
    "typeAware": true
  },
  "plugins": ["effecttsgo"],
  "rules": {
    "effecttsgo/catch-chain-to-first-success-of": "warn"
  }
}