Suggests using Layer.scoped instead of Layer.effect when Scope is in requirements
| Property | Value |
|---|---|
| Category | Anti-pattern |
| Default severity | warning |
| Fixable | Yes |
| Effect versions | v3 |
| Diagnostic codes | TS377031 |
| Language Service name | scopeInLayerEffect |
| Oxlint name | effecttsgo/scope-in-layer-effect |
import * as Context from "effect/Context"
import * as Effect from "effect/Effect"
import * as Layer from "effect/Layer"
class Cache extends Context.Tag("Cache")<Cache, { ok: true }>() {}
export const preview = Layer.effect(Cache, Effect.gen(function*() {
/**
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ effecttsgo(scope-in-layer-effect): This layer construction leaves `Scope` in the requirement set. The scoped API removes `Scope` from the resulting requirements.
*/
yield* Effect.addFinalizer(() => Effect.void)
/**
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
return { ok: true as const }
/**
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
}))
/**
^^^
*/See the Language Service setup guide for installation instructions.
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/scope-in-layer-effect": "warn"
}
}
{ "$schema": "./node_modules/@effect/tsgo/schema.json", "compilerOptions": { "plugins": [ { "name": "@effect/language-service", "diagnosticSeverity": { "scopeInLayerEffect": "warning" } } ] } }