leakingRequirements

August 4, 2026 ยท View on GitHub

Detects implementation services leaked in service methods

PropertyValue
CategoryAnti-pattern
Default severitysuggestion
FixableNo
Effect versionsv3, v4
Diagnostic codesTS377041
Language Service nameleakingRequirements
Oxlint nameeffecttsgo/leaking-requirements

Preview

import type { Effect } from "effect"
import { Context } from "effect"

class FileSystem extends Context.Service<FileSystem, {
  write: (s: string) => Effect.Effect<void>
}>()("FileSystem") {}

export class Cache extends Context.Service<Cache, {
/**
             ^^^^^ effecttsgo(leaking-requirements): Methods of this Service require `FileSystem` from every caller. The requirement becomes part of the public service surface instead of remaining internal to Layer implementation. Resolve these dependencies at Layer creation and provide them to each method, so the service's type reflects its purpose, not its implementation. To suppress this diagnostic for specific dependency types that are intentionally passed through (e.g., HttpServerRequest), add `@effect-leakable-service` JSDoc to their interface declarations, or to this service by adding a `@effect-expect-leaking FileSystem` JSDoc. More info and examples at https://effect.website/docs/requirements-management/layers/#avoiding-requirement-leakage
*/
  read: Effect.Effect<string, never, FileSystem>
  save: () => Effect.Effect<void, never, FileSystem>
}>()("Cache") {}

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": {
          "leakingRequirements": "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/leaking-requirements": "warn"
  }
}