redundantMapError
August 4, 2026 ยท View on GitHub
Suggests hoisting a repeated trailing Effect.mapError from every yield in an Effect generator
| Property | Value |
|---|---|
| Category | Style |
| Default severity | suggestion |
| Fixable | No |
| Effect versions | v3, v4 |
| Diagnostic codes | TS377088, TS377089 |
| Language Service name | redundantMapError |
| Oxlint name | effecttsgo/redundant-map-error |
Preview
import { Effect } from "effect"
declare const first: Effect.Effect<number, unknown>
declare const second: Effect.Effect<string, unknown>
class RepoError {
constructor(readonly args: { cause: unknown }) {}
}
export const program = Effect.gen(function*() {
/**
^^^^^^^^^ effecttsgo(redundant-map-error): This generator applies the same inline `Effect.mapError(...)` to every yielded effect. Keep that `Effect.mapError(...)` inline and hoist it once to the generator result: `Effect.gen(...).pipe(Effect.mapError(...))`, or `Effect.fn(function*(){ ... }, Effect.mapError(...))`.
*/
yield* first.pipe(
Effect.mapError((cause) => new RepoError({ cause }))
)
return yield* second.pipe(
Effect.mapError((cause) => new RepoError({ cause }))
)
})
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": {
"redundantMapError": "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/redundant-map-error": "warn"
}
}