Skip to content

Latest commit

 

History

History
65 lines (53 loc) · 1.54 KB

global-timers-in-effect.md

File metadata and controls

65 lines (53 loc) · 1.54 KB

globalTimersInEffect

Warns when using setTimeout/setInterval inside Effect generators instead of Effect.sleep/Schedule

Property Value
Category Effect-native
Default severity off
Fixable No
Effect versions v3, v4
Diagnostic codes TS377073
Language Service name globalTimersInEffect
Oxlint name effecttsgo/global-timers-in-effect

Preview

import { Effect } from "effect"

export const preview = Effect.gen(function*() {
  setTimeout(() => {}, 100)
/**
  ^^^^^^^^^^^^^^^^^^^^^^^^^ effecttsgo(global-timers-in-effect): This Effect code uses `setTimeout`, the corresponding timer API in this context is `Effect.sleep or Schedule` from Effect.
*/
})

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": {
          "globalTimersInEffect": "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/global-timers-in-effect": "warn"
  }
}