Skip to content

Latest commit

 

History

History
65 lines (53 loc) · 1.57 KB

return-effect-in-gen.md

File metadata and controls

65 lines (53 loc) · 1.57 KB

returnEffectInGen

Warns when returning an Effect in a generator causes nested Effect<Effect<...>>

Property Value
Category Anti-pattern
Default severity suggestion
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377014
Language Service name returnEffectInGen
Oxlint name effecttsgo/return-effect-in-gen

Preview

import * as Effect from "effect/Effect"

export const preview = Effect.gen(function*() {
  return Effect.succeed(1)
/**
  ^^^^^^ effecttsgo(return-effect-in-gen): This generator returns an Effect-able value directly, which produces a nested `Effect<Effect<...>>`. If the intended result is the inner Effect value, `return yield*` represents that form.
*/
})

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": {
          "returnEffectInGen": "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/return-effect-in-gen": "warn"
  }
}