globalRandomInEffect

August 4, 2026 ยท View on GitHub

Warns when using Math.random() inside Effect generators instead of the Random service

PropertyValue
CategoryEffect-native
Default severityoff
FixableNo
Effect versionsv3, v4
Diagnostic codesTS377071
Language Service nameglobalRandomInEffect
Oxlint nameeffecttsgo/global-random-in-effect

Preview

import { Effect } from "effect"

export const preview = Effect.gen(function*() {
  const r = Math.random()
/**
            ^^^^^^^^^^^^^ effecttsgo(global-random-in-effect): This Effect code uses `Math.random()`, randomness is represented through the Effect `Random` service.
*/
  return r
})

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": {
          "globalRandomInEffect": "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-random-in-effect": "warn"
  }
}