Skip to content

Latest commit

 

History

History
79 lines (64 loc) · 1.73 KB

map-some-to-as-some.md

File metadata and controls

79 lines (64 loc) · 1.73 KB

mapSomeToAsSome

Suggests using Effect.asSome instead of Effect.map when the mapper only wraps the success value with Option.some

Property Value
Category Style
Default severity suggestion
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377114
Language Service name mapSomeToAsSome
Oxlint name effecttsgo/map-some-to-as-some

Preview

import { Effect, Option } from "effect"

const numberEffect = Effect.succeed(1)

export const pipeable = numberEffect.pipe(
  Effect.map(Option.some)
/**
  ^^^^^^^^^^ effecttsgo(map-some-to-as-some): `Effect.asSome` expresses wrapping the success value in `Option.some` directly.
*/
)

export const etaExpanded = numberEffect.pipe(
  Effect.map((value) => Option.some(value))
/**
  ^^^^^^^^^^
*/
)

export const dataFirst = Effect.map(numberEffect, Option.some)
/**
                         ^^^^^^^^^^
*/

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": {
          "mapSomeToAsSome": "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-some-to-as-some": "warn"
  }
}