redundantMapError

August 4, 2026 ยท View on GitHub

Suggests hoisting a repeated trailing Effect.mapError from every yield in an Effect generator

PropertyValue
CategoryStyle
Default severitysuggestion
FixableNo
Effect versionsv3, v4
Diagnostic codesTS377088, TS377089
Language Service nameredundantMapError
Oxlint nameeffecttsgo/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"
  }
}