Skip to content

Latest commit

 

History

History
66 lines (54 loc) · 1.53 KB

global-date-in-effect.md

File metadata and controls

66 lines (54 loc) · 1.53 KB

globalDateInEffect

Warns when using Date.now() or new Date() inside Effect generators instead of Clock/DateTime

Property Value
Category Effect-native
Default severity off
Fixable No
Effect versions v3, v4
Diagnostic codes TS377067, TS377069
Language Service name globalDateInEffect
Oxlint name effecttsgo/global-date-in-effect

Preview

import { Effect } from "effect"

export const preview = Effect.gen(function*() {
  const now = Date.now()
/**
              ^^^^^^^^^^ effecttsgo(global-date-in-effect): This Effect code uses `Date.now()`, time access in Effect code is represented through `Clock` from Effect.
*/
  return now
})

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": {
          "globalDateInEffect": "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-date-in-effect": "warn"
  }
}