leakingRequirements
August 4, 2026 ยท View on GitHub
Detects implementation services leaked in service methods
| Property | Value |
|---|---|
| Category | Anti-pattern |
| Default severity | suggestion |
| Fixable | No |
| Effect versions | v3, v4 |
| Diagnostic codes | TS377041 |
| Language Service name | leakingRequirements |
| Oxlint name | effecttsgo/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"
}
}