Skip to content

Latest commit

 

History

History
65 lines (52 loc) · 1.7 KB

flat-map-identity-to-flatten.md

File metadata and controls

65 lines (52 loc) · 1.7 KB

flatMapIdentityToFlatten

Suggests Effect.flatten instead of Effect.flatMap when the callback is Effect's identity export referenced directly or an unannotated function returning its parameter

Property Value
Category Style
Default severity suggestion
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377151
Language Service name flatMapIdentityToFlatten
Oxlint name effecttsgo/flat-map-identity-to-flatten

Preview

import { Effect } from "effect"

declare const loadTask: Effect.Effect<Effect.Effect<string>>

export const program = loadTask.pipe(Effect.flatMap((inner) => inner))
/**
                                     ^^^^^^^^^^^^^^ effecttsgo(flat-map-identity-to-flatten): `Effect.flatten` expresses this unwrapping more directly than `Effect.flatMap` with an identity callback.
*/

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": {
          "flatMapIdentityToFlatten": "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-identity-to-flatten": "warn"
  }
}