Unused Effect layers
What an unused-effect-layer finding of fallow dead-code means, why it matters and how to fix it.
What it reports
An Effect layer is composed only into layers that nothing uses.
Dead code explains how fallow finds it.
Why it matters
An Effect Layer definition (a module-scope const or a class static property such as static layer = Layer.effect(this, make)) whose every reference sits inside other layer definitions that are themselves unused. The layer never reaches Effect.provide, ManagedRuntime.make, Layer.launch or any other runtime use. fallow builds a layer graph from Layer.* initializers and .pipe(Layer.*) chains. Any value reference outside a layer definition is a root, including references in functions and tests. A layer with zero references is not reported here: unused-export or unused-class-member reports it, so the rule reports the tail of a dead composition and names the unused consumers. Default warn. The check runs only when the project declares effect.
Example
services.ts defines const CacheLive = Cache.layer.pipe(Layer.provide(Db.layer)) and export const OrphanLive = Layer.mergeAll(CacheLive), but nothing provides OrphanLive.
Fix
Remove the unused consumer layers first, then this layer, or compose the layer into a layer that reaches a runtime. If code outside the analyzed project composes it, suppress the line with // fallow-ignore-next-line unused-effect-layer.
Facts
| Fact | Value |
|---|---|
| Issue type | unused-effect-layer |
| Rule id in SARIF output | fallow/unused-effect-layer |
| Command | fallow dead-code |
| Default severity | warn |
Config key in rules | unused-effect-layers |
| Filter option | --unused-effect-layers |
| Suppression comment | // fallow-ignore-next-line unused-effect-layer |
Fixable with fallow fix | No |
| Opt-in | No |