Skip to content

Latest commit

 

History

History
69 lines (56 loc) · 1.71 KB

yield-in-call-argument.md

File metadata and controls

69 lines (56 loc) · 1.71 KB

yieldInCallArgument

Suggests yielding into a const before a call instead of passing a yield* directly as a call or new argument in Effect generators

Property Value
Category Style
Default severity off
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377171
Language Service name yieldInCallArgument
Oxlint name effecttsgo/yield-in-call-argument

Preview

import { Effect } from "effect"

declare const load: Effect.Effect<number>
declare function transform(n: number): string

export const preview = Effect.gen(function*() {
  const result = transform(yield* load)
/**
                           ^^^^^ effecttsgo(yield-in-call-argument): This `yield*` is used as a call argument; yield it into a const first, or map the effect, so running the effect and building the call stay separate steps.
*/
  return result
})

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": {
          "yieldInCallArgument": "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/yield-in-call-argument": "warn"
  }
}