Skip to content

Latest commit

 

History

History
73 lines (59 loc) · 1.7 KB

flat-map-to-tap.md

File metadata and controls

73 lines (59 loc) · 1.7 KB

flatMapToTap

Suggests Effect.tap when a flatMap or andThen callback runs an effect and returns its unchanged parameter

Property Value
Category Style
Default severity suggestion
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377144
Language Service name flatMapToTap
Oxlint name effecttsgo/flat-map-to-tap

Preview

import { Effect } from "effect"

interface User {
  readonly id: string
  readonly name: string
}

declare const findUser: (id: string) => Effect.Effect<User>
declare const auditUser: (user: User) => Effect.Effect<void>

export const loadUser = (id: string) => findUser(id).pipe(
  Effect.flatMap((user) => auditUser(user).pipe(Effect.as(user)))
/**
  ^^^^^^^^^^^^^^ effecttsgo(flat-map-to-tap): `Effect.tap` expresses this observation more directly than `Effect.flatMap` with a manual re-yield.
*/
)

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": {
          "flatMapToTap": "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/flat-map-to-tap": "warn"
  }
}