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 |
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.
*/
)See the Language Service setup guide for installation instructions.
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"
}
}
{ "$schema": "./node_modules/@effect/tsgo/schema.json", "compilerOptions": { "plugins": [ { "name": "@effect/language-service", "diagnosticSeverity": { "catchChainToFirstSuccessOf": "warning" } } ] } }