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 |
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.
*/
)See the Language Service setup guide for installation instructions.
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"
}
}
{ "$schema": "./node_modules/@effect/tsgo/schema.json", "compilerOptions": { "plugins": [ { "name": "@effect/language-service", "diagnosticSeverity": { "mapMapErrorToMapBoth": "warning" } } ] } }