Skip to content

Latest commit

 

History

History
71 lines (58 loc) · 1.61 KB

on-exit-failure-to-on-error.md

File metadata and controls

71 lines (58 loc) · 1.61 KB

onExitFailureToOnError

Suggests Effect.onError when an Effect.onExit callback only acts on failure

Property Value
Category Style
Default severity suggestion
Fixable No
Effect versions v3, v4
Diagnostic codes TS377184
Language Service name onExitFailureToOnError
Oxlint name effecttsgo/on-exit-failure-to-on-error

Preview

import { Effect, Exit } from "effect"

declare const program: Effect.Effect<number, string>

program.pipe(
  Effect.onExit((exit) =>
/**
  ^^^^^^^^^^^^^ effecttsgo(on-exit-failure-to-on-error): Effect.onError expresses this failure-only Effect.onExit callback more directly.
*/
    Exit.isFailure(exit)
      ? Effect.logError("failed", { cause: exit.cause })
      : Effect.void
  )
)

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": {
          "onExitFailureToOnError": "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/on-exit-failure-to-on-error": "warn"
  }
}