@effect/language-service 0.78.0 → 0.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,6 +10,7 @@ This package implements a TypeScript language service plugin that allows additio
10
10
  2. Inside your tsconfig.json, you should add the plugin configuration as follows:
11
11
  ```jsonc
12
12
  {
13
+ "$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json",
13
14
  "compilerOptions": {
14
15
  "plugins": [
15
16
  // ... other LSPs (if any) and as last
@@ -39,6 +40,68 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
39
40
 
40
41
  ## Provided functionalities
41
42
 
43
+ ### Diagnostics
44
+
45
+ <!-- diagnostics-table:start -->
46
+ | Diagnostic | Sev | Fix | Description | v3 | v4 |
47
+ | --- | --- | --- | --- | --- | --- |
48
+ | `anyUnknownInErrorContext` | ➖ | | Detects 'any' or 'unknown' types in Effect error or requirements channels | ✓ | ✓ |
49
+ | `catchAllToMapError` | 💡 | 🔧 | Suggests using Effect.mapError instead of Effect.catchAll when the callback only wraps the error with Effect.fail | ✓ | ✓ |
50
+ | `catchUnfailableEffect` | 💡 | | Warns when using error handling on Effects that never fail (error type is 'never') | ✓ | ✓ |
51
+ | `classSelfMismatch` | ❌ | 🔧 | Ensures Self type parameter matches the class name in Service/Tag/Schema classes | ✓ | ✓ |
52
+ | `deterministicKeys` | ➖ | 🔧 | Enforces deterministic naming for service/tag/error identifiers based on class names | ✓ | ✓ |
53
+ | `duplicatePackage` | ⚠️ | | Detects when multiple versions of the same Effect package are loaded | ✓ | ✓ |
54
+ | `effectFnIife` | ⚠️ | 🔧 | Effect.fn or Effect.fnUntraced is called as an IIFE (Immediately Invoked Function Expression). Use Effect.gen instead. | ✓ | ✓ |
55
+ | `effectFnOpportunity` | 💡 | 🔧 | Suggests using Effect.fn for functions that returns an Effect | ✓ | ✓ |
56
+ | `effectGenUsesAdapter` | ⚠️ | | Warns when using the deprecated adapter parameter in Effect.gen | ✓ | ✓ |
57
+ | `effectInFailure` | ⚠️ | | Warns when an Effect is used inside an Effect failure channel | ✓ | ✓ |
58
+ | `effectInVoidSuccess` | ⚠️ | | Detects nested Effects in void success channels that may cause unexecuted effects | ✓ | ✓ |
59
+ | `effectMapVoid` | 💡 | 🔧 | Suggests using Effect.asVoid instead of Effect.map(() => void 0), Effect.map(() => undefined), or Effect.map(() => {}) | ✓ | ✓ |
60
+ | `effectSucceedWithVoid` | 💡 | 🔧 | Suggests using Effect.void instead of Effect.succeed(undefined) or Effect.succeed(void 0) | ✓ | ✓ |
61
+ | `extendsNativeError` | ➖ | | Warns when a class directly extends the native Error class | ✓ | ✓ |
62
+ | `floatingEffect` | ❌ | | Ensures Effects are yielded or assigned to variables, not left floating | ✓ | ✓ |
63
+ | `genericEffectServices` | ⚠️ | | Prevents services with type parameters that cannot be discriminated at runtime | ✓ | ✓ |
64
+ | `globalErrorInEffectCatch` | ⚠️ | | Warns when catch callbacks return global Error type instead of typed errors | ✓ | ✓ |
65
+ | `globalErrorInEffectFailure` | ⚠️ | | Warns when the global Error type is used in an Effect failure channel | ✓ | ✓ |
66
+ | `importFromBarrel` | ➖ | 🔧 | Suggests importing from specific module paths instead of barrel exports | ✓ | ✓ |
67
+ | `instanceOfSchema` | ➖ | 🔧 | Suggests using Schema.is instead of instanceof for Effect Schema types | ✓ | ✓ |
68
+ | `layerMergeAllWithDependencies` | ⚠️ | 🔧 | Detects interdependencies in Layer.mergeAll calls where one layer provides a service that another layer requires | ✓ | ✓ |
69
+ | `leakingRequirements` | 💡 | | Detects implementation services leaked in service methods | ✓ | ✓ |
70
+ | `missedPipeableOpportunity` | ➖ | 🔧 | Enforces the use of pipeable style for nested function calls | ✓ | ✓ |
71
+ | `missingEffectContext` | ❌ | | Reports missing service requirements in Effect context channel | ✓ | ✓ |
72
+ | `missingEffectError` | ❌ | 🔧 | Reports missing error types in Effect error channel | ✓ | ✓ |
73
+ | `missingEffectServiceDependency` | ➖ | | Checks that Effect.Service dependencies satisfy all required layer inputs | ✓ | |
74
+ | `missingLayerContext` | ❌ | | Reports missing service requirements in Layer context channel | ✓ | ✓ |
75
+ | `missingReturnYieldStar` | ❌ | 🔧 | Suggests using 'return yield*' for Effects with never success for better type narrowing | ✓ | ✓ |
76
+ | `missingStarInYieldEffectGen` | ❌ | 🔧 | Enforces using 'yield*' instead of 'yield' when yielding Effects in generators | ✓ | ✓ |
77
+ | `multipleEffectProvide` | ⚠️ | 🔧 | Warns against chaining Effect.provide calls which can cause service lifecycle issues | ✓ | ✓ |
78
+ | `nodeBuiltinImport` | ➖ | | Warns when importing Node.js built-in modules that have Effect-native counterparts | ✓ | ✓ |
79
+ | `nonObjectEffectServiceType` | ❌ | | Ensures Effect.Service types are objects, not primitives | ✓ | |
80
+ | `outdatedApi` | ⚠️ | | Detects usage of APIs that have been removed or renamed in Effect v4 | | ✓ |
81
+ | `outdatedEffectCodegen` | ⚠️ | 🔧 | Detects when generated code is outdated and needs to be regenerated | ✓ | ✓ |
82
+ | `overriddenSchemaConstructor` | ❌ | 🔧 | Prevents overriding constructors in Schema classes which breaks decoding behavior | ✓ | ✓ |
83
+ | `preferSchemaOverJson` | 💡 | | Suggests using Effect Schema for JSON operations instead of JSON.parse/JSON.stringify which may throw | ✓ | ✓ |
84
+ | `redundantSchemaTagIdentifier` | 💡 | 🔧 | Suggests removing redundant identifier argument when it equals the tag value in Schema.TaggedClass/TaggedError/TaggedRequest | ✓ | ✓ |
85
+ | `returnEffectInGen` | 💡 | 🔧 | Warns when returning an Effect in a generator causes nested Effect<Effect<...>> | ✓ | ✓ |
86
+ | `runEffectInsideEffect` | 💡 | 🔧 | Suggests using Runtime methods instead of Effect.run* inside Effect contexts | ✓ | |
87
+ | `schemaStructWithTag` | 💡 | 🔧 | Suggests using Schema.TaggedStruct instead of Schema.Struct with _tag field | ✓ | ✓ |
88
+ | `schemaSyncInEffect` | 💡 | | Suggests using Effect-based Schema methods instead of sync methods inside Effect generators | ✓ | ✓ |
89
+ | `schemaUnionOfLiterals` | ➖ | 🔧 | Simplifies Schema.Union of multiple Schema.Literal calls into single Schema.Literal | ✓ | |
90
+ | `scopeInLayerEffect` | ⚠️ | 🔧 | Suggests using Layer.scoped instead of Layer.effect when Scope is in requirements | ✓ | |
91
+ | `serviceNotAsClass` | ➖ | 🔧 | Warns when ServiceMap.Service is used as a variable instead of a class declaration | | ✓ |
92
+ | `strictBooleanExpressions` | ➖ | | Enforces boolean types in conditional expressions for type safety | ✓ | ✓ |
93
+ | `strictEffectProvide` | ➖ | | Warns when using Effect.provide with layers outside of application entry points | ✓ | ✓ |
94
+ | `tryCatchInEffectGen` | 💡 | | Discourages try/catch in Effect generators in favor of Effect error handling | ✓ | ✓ |
95
+ | `unknownInEffectCatch` | ⚠️ | | Warns when catch callbacks return unknown instead of typed errors | ✓ | ✓ |
96
+ | `unnecessaryEffectGen` | 💡 | 🔧 | Suggests removing Effect.gen when it contains only a single return statement | ✓ | ✓ |
97
+ | `unnecessaryFailYieldableError` | 💡 | 🔧 | Suggests yielding yieldable errors directly instead of wrapping with Effect.fail | ✓ | ✓ |
98
+ | `unnecessaryPipe` | 💡 | 🔧 | Removes pipe calls with no arguments | ✓ | ✓ |
99
+ | `unnecessaryPipeChain` | 💡 | 🔧 | Simplifies chained pipe calls into a single pipe call | ✓ | ✓ |
100
+ | `unsupportedServiceAccessors` | ⚠️ | 🔧 | Warns about service accessors that need codegen due to generic/complex signatures | ✓ | ✓ |
101
+
102
+ `➖` off by default, `❌` error, `⚠️` warning, `💬` message, `💡` suggestion, `🔧` quick fix available
103
+ <!-- diagnostics-table:end -->
104
+
42
105
  ### Quickinfo
43
106
 
44
107
  - Show the extended type of the current Effect
@@ -46,48 +109,6 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
46
109
  - Hovering a variable assignment of a type Layer, will show info on how each service got involved
47
110
  - Hovering a layer, will attempt to produce a graph
48
111
 
49
- ### Diagnostics
50
-
51
- - Better error readability when you're missing errors or service types in your Effect definitions
52
- - Better error readability when you're missing service requirements in your Layer definitions
53
- - Floating Effects that are not yielded or run
54
- - Wrong usage of yield inside `Effect.gen`
55
- - Multiple versions of Effect in your project
56
- - Warn on leaking requirements in Effect services
57
- - Warn on Scope as requirement of a Layer
58
- - Warn on subsequent `Effect.provide` anti-pattern
59
- - Warn when using `Effect.provide` with Layer outside of application entry points
60
- - Detect wrong `Self` type parameter for APIs like `Effect.Service` or `Schema.TaggedError` and similar 
61
- - Unnecessary usages of `Effect.gen` or `pipe()`
62
- - Warn when using `Effect.gen` with the old generator adapter pattern
63
- - Warn when importing from a barrel file instead of from the module directly
64
- - Warn on usage of try/catch inside `Effect.gen` and family
65
- - Detect unnecessary pipe chains like `X.pipe(Y).pipe(Z)`
66
- - Warn when using `Effect.Service` with `accessors: true` but methods have generics or multiple signatures
67
- - Warn on missing service dependencies in `Effect.Service` declarations
68
- - Warn when `Effect.Service` is used with a primitive type instead of an object type
69
- - Warn when schema classes override the default constructor behavior
70
- - Warn when `@effect-diagnostics-next-line` comments have no effect (i.e., they don't suppress any diagnostic)
71
- - Detect nested function calls that can be converted to pipeable style for better readability
72
- - Warn when using catch functions (`catchAll`, `catch`, `catchIf`, `catchSome`, `catchTag`, `catchTags`) on effects that never fail
73
- - Warn when catch callbacks in `Effect.tryPromise`, `Effect.tryMap`, or `Effect.tryMapPromise` return `unknown` or `any` types
74
- - Warn when catch callbacks in `Effect.tryPromise`, `Effect.try`, `Effect.tryMap`, or `Effect.tryMapPromise` return the global `Error` type instead of typed errors
75
- - Warn when using `Effect.runSync`, `Effect.runPromise`, `Effect.runFork`, or `Effect.runCallback` inside an Effect
76
- - Warn when using `Schema.decodeSync`, `Schema.decodeUnknownSync`, `Schema.encodeSync`, or `Schema.encodeUnknownSync` inside Effect generators, suggesting Effect-based alternatives
77
- - Suggest using Effect Schema for JSON operations instead of `JSON.parse`/`JSON.stringify` inside Effect contexts
78
- - Warn when using `Schema.Union` with multiple `Schema.Literal` calls that can be simplified to a single `Schema.Literal` call
79
- - Suggest using `Schema.TaggedStruct` instead of `Schema.Struct` when a `_tag` field with `Schema.Literal` is present to make the tag optional in the constructor
80
- - Warn when using `yield* Effect.fail()` with yieldable error types that can be yielded directly
81
- - Warn when the global `Error` type is used in an Effect failure channel, recommending tagged errors
82
- - Warn when an `Effect` computation is placed in an Effect failure channel, since failure channels should contain only failure types
83
- - Warn when `Layer.mergeAll` contains layers with interdependencies (where one layer provides a service that another layer in the same call requires)
84
- - Suggest using `Effect.fn` for functions that return `Effect.gen` for better tracing and concise syntax
85
- - Warn when `Effect.fn` or `Effect.fnUntraced` is used as an IIFE (Immediately Invoked Function Expression), suggesting `Effect.gen` instead
86
- - Suggest removing redundant identifier argument when it equals the tag value in `Schema.TaggedClass`, `Schema.TaggedError`, or `Schema.TaggedRequest`
87
- - Suggest using `Schema.is` instead of `instanceof` for Effect Schema types
88
- - Suggest using `Effect.void` instead of `Effect.succeed(undefined)` or `Effect.succeed(void 0)`
89
- - Warn when using outdated Effect v3 APIs in an Effect v4 project, with guidance on the correct v4 replacement (renamed, changed, or removed APIs)
90
-
91
112
  ### Completions
92
113
 
93
114
  - Autocomplete 'Self' in `Effect.Service`, `Context.Tag`, `Schema.TaggedClass`, `Schema.TaggedRequest`, `ServiceMap.Service`, `Model.Class` and family
@@ -145,7 +166,9 @@ Few options can be provided alongside the initialization of the Language Service
145
166
  "missingDiagnosticNextLine": "warning", // controls the severity of warnings for unused @effect-diagnostics-next-line comments (default: "warning", allowed values: off,error,warning,message,suggestion)
146
167
  "includeSuggestionsInTsc": true, // when enabled with effect-language-service patch enabled, diagnostics with "suggestion" severity will be reported as "message" in TSC with "[suggestion]" prefix; useful to help steer LLM output (default: true)
147
168
  "ignoreEffectWarningsInTscExitCode": false, // if set to true, effect-related warnings won't change the exit code of tsc, meaning that tsc will compile fine even if effect warnings are emitted (default: false)
169
+ "ignoreEffectErrorsInTscExitCode": false, // if set to true, effect-related errors won't change the exit code of tsc (default: false)
148
170
  "ignoreEffectSuggestionsInTscExitCode": true, // if set to true, effect-related suggestions won't change the exit code of tsc (default: true)
171
+ "skipDisabledOptimization": false, // if set to true, disabled diagnostics are still processed so per-line or per-section overrides can be honored in patched tsc runs (default: false)
149
172
  "quickinfo": true, // controls Effect quickinfo (default: true)
150
173
  "quickinfoEffectParameters": "whenTruncated", // (default: "whenTruncated") controls when to display effect type parameters always,never,whenTruncated
151
174
  "quickinfoMaximumLength": -1, // controls how long can be the types in the quickinfo hover (helps with very long type to improve perfs, defaults to -1 for no truncation, can be any number eg. 1000 and TS will try to fit as much as possible in that budget, higher number means more info.)
@@ -209,13 +232,13 @@ so that across updates the patch will be re-applied again.
209
232
  The effect language service plugin comes with a builtin CLI tool that can be used to perform various utilities, checks and setups. Since it relies on typescript, we recommend to install it locally and run it locally to ensure it loads the same typescript version of your project rather than a global installation that may resolve to use a different TS version from the one of your project.
210
233
 
211
234
  ### `effect-language-service setup`
212
- Runs through a wizard to setup/update some basic functionalities of the LSP in an interactive way.
235
+ Runs through a wizard to setup/update some basic functionalities of the LSP in an interactive way. This also keeps the `tsconfig.json` `$schema` aligned with the published Effect Language Service schema.
213
236
 
214
237
  ### `effect-language-service codegen`
215
238
  Automatically updates Effect codegens in your TypeScript files. This command scans files for `@effect-codegens` directives and applies the necessary code transformations. Use `--file` to update a specific file, or `--project` with a tsconfig file to update an entire project. The `--verbose` flag provides detailed output about which files are being processed and updated.
216
239
 
217
240
  ### `effect-language-service diagnostics`
218
- Provides a way to get through a CLI the list of Effect specific diagnostics; without patching your typescript installation. A --file option may be used to get diagnostics for a specific file, or --project with a tsconfig file to get an entire project.
241
+ Provides a way to get through a CLI the list of Effect specific diagnostics; without patching your typescript installation. A `--file` option may be used to get diagnostics for a specific file, or `--project` with a tsconfig file to get an entire project. You can also pass `--lspconfig '{ "effectFn": ["untraced"] }'` to override the project plugin configuration inline for that diagnostics run.
219
242
 
220
243
  ### `effect-language-service quickfixes`
221
244
  Shows diagnostics that have available quick fixes along with their proposed code changes. This is useful for previewing what fixes the language service can apply to your code. Use `--file` to check a specific file, or `--project` with a tsconfig file to check an entire project. The output displays each diagnostic with its location and the diff of proposed changes.