Skip to content

Latest commit

 

History

History
69 lines (57 loc) · 2.01 KB

layer-merge-all-with-dependencies.md

File metadata and controls

69 lines (57 loc) · 2.01 KB

layerMergeAllWithDependencies

Detects interdependencies in Layer.mergeAll calls where one layer provides a service that another layer requires

Property Value
Category Anti-pattern
Default severity warning
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377035
Language Service name layerMergeAllWithDependencies
Oxlint name effecttsgo/layer-merge-all-with-dependencies

Preview

import { Effect, Layer, Context } from "effect"

class A extends Context.Service<A>()("A", { make: Effect.succeed({}) }) {
  static Default = Layer.effect(this, this.make)
}
class B extends Context.Service<B>()("B", { make: Effect.as(A, {}) }) {
  static Default = Layer.effect(this, this.make)
}
export const preview = Layer.mergeAll(A.Default, B.Default)
/**
                                      ^^^^^^^^^ effecttsgo(layer-merge-all-with-dependencies): This layer provides A which is required by another layer in the same Layer.mergeAll call. Layer.mergeAll creates layers in parallel, so dependencies between layers will not be satisfied. Consider moving this layer into a Layer.provideMerge after the Layer.mergeAll.
*/

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": {
          "layerMergeAllWithDependencies": "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/layer-merge-all-with-dependencies": "warn"
  }
}