Skip to content

Latest commit

 

History

History
70 lines (57 loc) · 1.75 KB

race-first-with-sleep-to-timeout.md

File metadata and controls

70 lines (57 loc) · 1.75 KB

raceFirstWithSleepToTimeout

Suggests Effect.timeoutOrElse when Effect.raceFirst has exactly one sleep- or delay-based timer arm

Property Value
Category Style
Default severity suggestion
Fixable No
Effect versions v4
Diagnostic codes TS377121
Language Service name raceFirstWithSleepToTimeout
Oxlint name effecttsgo/race-first-with-sleep-to-timeout

Preview

import { Effect } from "effect"

declare const request: Effect.Effect<string, Error>

export const result = Effect.raceFirst(
/**
                      ^^^^^^^^^^^^^^^^ effecttsgo(race-first-with-sleep-to-timeout): This Effect first-completion race has exactly one sleep- or delay-based timer arm. `Effect.timeoutOrElse` expresses the timeout and fallback directly.
*/
  request,
  Effect.sleep("5 seconds").pipe(
    Effect.andThen(Effect.fail(new Error("request timed out")))
  )
)

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": {
          "raceFirstWithSleepToTimeout": "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/race-first-with-sleep-to-timeout": "warn"
  }
}