Skip to content

Latest commit

 

History

History
61 lines (50 loc) · 1.39 KB

global-random.md

File metadata and controls

61 lines (50 loc) · 1.39 KB

globalRandom

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

Property Value
Category Effect-native
Default severity off
Fixable No
Effect versions v3, v4
Diagnostic codes TS377070
Language Service name globalRandom
Oxlint name effecttsgo/global-random

Preview

export const preview = Math.random()
/**
                       ^^^^^^^^^^^^^ effecttsgo(global-random): This code uses `Math.random()`, randomness is represented through the Effect `Random` service.
*/

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": {
          "globalRandom": "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": "warn"
  }
}