Skip to content

Latest commit

 

History

History
73 lines (59 loc) · 1.85 KB

map-map-error-to-map-both.md

File metadata and controls

73 lines (59 loc) · 1.85 KB

mapMapErrorToMapBoth

Suggests Effect.mapBoth when Effect.map and Effect.mapError are adjacent steps of a piping flow

Property Value
Category Style
Default severity off
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377153
Language Service name mapMapErrorToMapBoth
Oxlint name effecttsgo/map-map-error-to-map-both

Preview

import { Data, Effect } from "effect"

class TaskError extends Data.TaggedError("TaskError")<{
  readonly message: string
}> {}

declare const fetchCount: Effect.Effect<number, string>

// MUST TRIGGER: adjacent Effect.map + Effect.mapError is a single Effect.mapBoth
export const isPositive = fetchCount.pipe(
  Effect.map((n) => n > 0),
  Effect.mapError((message) => new TaskError({ message }))
/**
  ^^^^^^^^^^^^^^^ effecttsgo(map-map-error-to-map-both): `Effect.map` + `Effect.mapError` transform the success and failure channels one step at a time; `Effect.mapBoth` expresses both transformations in a single step.
*/
)

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": {
          "mapMapErrorToMapBoth": "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/map-map-error-to-map-both": "warn"
  }
}