Skip to content

Latest commit

 

History

History
67 lines (54 loc) · 1.55 KB

all-of-map-to-for-each.md

File metadata and controls

67 lines (54 loc) · 1.55 KB

allOfMapToForEach

Suggests using Effect.forEach instead of Effect.all over an effectful Array#map

Property Value
Category Style
Default severity suggestion
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377113
Language Service name allOfMapToForEach
Oxlint name effecttsgo/all-of-map-to-for-each

Preview

import { Effect } from "effect"

declare const values: ReadonlyArray<number>

export const program = Effect.all(
/**
                       ^^^^^^^^^^ effecttsgo(all-of-map-to-for-each): `Effect.forEach` expresses this effectful array mapping more directly than `Effect.all` over `Array#map`.
*/
  values.map((value) => Effect.succeed(value + 1))
)

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": {
          "allOfMapToForEach": "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/all-of-map-to-for-each": "warn"
  }
}