@effect/language-service 0.78.0 → 0.79.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 +64 -42
- package/cli.js +321 -8
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +317 -4
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +334 -12
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +311 -4
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -39,6 +39,68 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
|
|
|
39
39
|
|
|
40
40
|
## Provided functionalities
|
|
41
41
|
|
|
42
|
+
### Diagnostics
|
|
43
|
+
|
|
44
|
+
<!-- diagnostics-table:start -->
|
|
45
|
+
| Diagnostic | Sev | Fix | Description | v3 | v4 |
|
|
46
|
+
| --- | --- | --- | --- | --- | --- |
|
|
47
|
+
| `anyUnknownInErrorContext` | ➖ | | Detects 'any' or 'unknown' types in Effect error or requirements channels | ✓ | ✓ |
|
|
48
|
+
| `catchAllToMapError` | 💡 | 🔧 | Suggests using Effect.mapError instead of Effect.catchAll when the callback only wraps the error with Effect.fail | ✓ | ✓ |
|
|
49
|
+
| `catchUnfailableEffect` | 💡 | | Warns when using error handling on Effects that never fail (error type is 'never') | ✓ | ✓ |
|
|
50
|
+
| `classSelfMismatch` | ❌ | 🔧 | Ensures Self type parameter matches the class name in Service/Tag/Schema classes | ✓ | ✓ |
|
|
51
|
+
| `deterministicKeys` | ➖ | 🔧 | Enforces deterministic naming for service/tag/error identifiers based on class names | ✓ | ✓ |
|
|
52
|
+
| `duplicatePackage` | ⚠️ | | Detects when multiple versions of the same Effect package are loaded | ✓ | ✓ |
|
|
53
|
+
| `effectFnIife` | ⚠️ | 🔧 | Effect.fn or Effect.fnUntraced is called as an IIFE (Immediately Invoked Function Expression). Use Effect.gen instead. | ✓ | ✓ |
|
|
54
|
+
| `effectFnOpportunity` | 💡 | 🔧 | Suggests using Effect.fn for functions that returns an Effect | ✓ | ✓ |
|
|
55
|
+
| `effectGenUsesAdapter` | ⚠️ | | Warns when using the deprecated adapter parameter in Effect.gen | ✓ | ✓ |
|
|
56
|
+
| `effectInFailure` | ⚠️ | | Warns when an Effect is used inside an Effect failure channel | ✓ | ✓ |
|
|
57
|
+
| `effectInVoidSuccess` | ⚠️ | | Detects nested Effects in void success channels that may cause unexecuted effects | ✓ | ✓ |
|
|
58
|
+
| `effectMapVoid` | 💡 | 🔧 | Suggests using Effect.asVoid instead of Effect.map(() => void 0), Effect.map(() => undefined), or Effect.map(() => {}) | ✓ | ✓ |
|
|
59
|
+
| `effectSucceedWithVoid` | 💡 | 🔧 | Suggests using Effect.void instead of Effect.succeed(undefined) or Effect.succeed(void 0) | ✓ | ✓ |
|
|
60
|
+
| `extendsNativeError` | ➖ | | Warns when a class directly extends the native Error class | ✓ | ✓ |
|
|
61
|
+
| `floatingEffect` | ❌ | | Ensures Effects are yielded or assigned to variables, not left floating | ✓ | ✓ |
|
|
62
|
+
| `genericEffectServices` | ⚠️ | | Prevents services with type parameters that cannot be discriminated at runtime | ✓ | ✓ |
|
|
63
|
+
| `globalErrorInEffectCatch` | ⚠️ | | Warns when catch callbacks return global Error type instead of typed errors | ✓ | ✓ |
|
|
64
|
+
| `globalErrorInEffectFailure` | ⚠️ | | Warns when the global Error type is used in an Effect failure channel | ✓ | ✓ |
|
|
65
|
+
| `importFromBarrel` | ➖ | 🔧 | Suggests importing from specific module paths instead of barrel exports | ✓ | ✓ |
|
|
66
|
+
| `instanceOfSchema` | ➖ | 🔧 | Suggests using Schema.is instead of instanceof for Effect Schema types | ✓ | ✓ |
|
|
67
|
+
| `layerMergeAllWithDependencies` | ⚠️ | 🔧 | Detects interdependencies in Layer.mergeAll calls where one layer provides a service that another layer requires | ✓ | ✓ |
|
|
68
|
+
| `leakingRequirements` | 💡 | | Detects implementation services leaked in service methods | ✓ | ✓ |
|
|
69
|
+
| `missedPipeableOpportunity` | ➖ | 🔧 | Enforces the use of pipeable style for nested function calls | ✓ | ✓ |
|
|
70
|
+
| `missingEffectContext` | ❌ | | Reports missing service requirements in Effect context channel | ✓ | ✓ |
|
|
71
|
+
| `missingEffectError` | ❌ | 🔧 | Reports missing error types in Effect error channel | ✓ | ✓ |
|
|
72
|
+
| `missingEffectServiceDependency` | ➖ | | Checks that Effect.Service dependencies satisfy all required layer inputs | ✓ | |
|
|
73
|
+
| `missingLayerContext` | ❌ | | Reports missing service requirements in Layer context channel | ✓ | ✓ |
|
|
74
|
+
| `missingReturnYieldStar` | ❌ | 🔧 | Suggests using 'return yield*' for Effects with never success for better type narrowing | ✓ | ✓ |
|
|
75
|
+
| `missingStarInYieldEffectGen` | ❌ | 🔧 | Enforces using 'yield*' instead of 'yield' when yielding Effects in generators | ✓ | ✓ |
|
|
76
|
+
| `multipleEffectProvide` | ⚠️ | 🔧 | Warns against chaining Effect.provide calls which can cause service lifecycle issues | ✓ | ✓ |
|
|
77
|
+
| `nodeBuiltinImport` | ➖ | | Warns when importing Node.js built-in modules that have Effect-native counterparts | ✓ | ✓ |
|
|
78
|
+
| `nonObjectEffectServiceType` | ❌ | | Ensures Effect.Service types are objects, not primitives | ✓ | |
|
|
79
|
+
| `outdatedApi` | ⚠️ | | Detects usage of APIs that have been removed or renamed in Effect v4 | | ✓ |
|
|
80
|
+
| `outdatedEffectCodegen` | ⚠️ | 🔧 | Detects when generated code is outdated and needs to be regenerated | ✓ | ✓ |
|
|
81
|
+
| `overriddenSchemaConstructor` | ❌ | 🔧 | Prevents overriding constructors in Schema classes which breaks decoding behavior | ✓ | ✓ |
|
|
82
|
+
| `preferSchemaOverJson` | 💡 | | Suggests using Effect Schema for JSON operations instead of JSON.parse/JSON.stringify which may throw | ✓ | ✓ |
|
|
83
|
+
| `redundantSchemaTagIdentifier` | 💡 | 🔧 | Suggests removing redundant identifier argument when it equals the tag value in Schema.TaggedClass/TaggedError/TaggedRequest | ✓ | ✓ |
|
|
84
|
+
| `returnEffectInGen` | 💡 | 🔧 | Warns when returning an Effect in a generator causes nested Effect<Effect<...>> | ✓ | ✓ |
|
|
85
|
+
| `runEffectInsideEffect` | 💡 | 🔧 | Suggests using Runtime methods instead of Effect.run* inside Effect contexts | ✓ | |
|
|
86
|
+
| `schemaStructWithTag` | 💡 | 🔧 | Suggests using Schema.TaggedStruct instead of Schema.Struct with _tag field | ✓ | ✓ |
|
|
87
|
+
| `schemaSyncInEffect` | 💡 | | Suggests using Effect-based Schema methods instead of sync methods inside Effect generators | ✓ | ✓ |
|
|
88
|
+
| `schemaUnionOfLiterals` | ➖ | 🔧 | Simplifies Schema.Union of multiple Schema.Literal calls into single Schema.Literal | ✓ | |
|
|
89
|
+
| `scopeInLayerEffect` | ⚠️ | 🔧 | Suggests using Layer.scoped instead of Layer.effect when Scope is in requirements | ✓ | |
|
|
90
|
+
| `serviceNotAsClass` | ➖ | 🔧 | Warns when ServiceMap.Service is used as a variable instead of a class declaration | | ✓ |
|
|
91
|
+
| `strictBooleanExpressions` | ➖ | | Enforces boolean types in conditional expressions for type safety | ✓ | ✓ |
|
|
92
|
+
| `strictEffectProvide` | ➖ | | Warns when using Effect.provide with layers outside of application entry points | ✓ | ✓ |
|
|
93
|
+
| `tryCatchInEffectGen` | 💡 | | Discourages try/catch in Effect generators in favor of Effect error handling | ✓ | ✓ |
|
|
94
|
+
| `unknownInEffectCatch` | ⚠️ | | Warns when catch callbacks return unknown instead of typed errors | ✓ | ✓ |
|
|
95
|
+
| `unnecessaryEffectGen` | 💡 | 🔧 | Suggests removing Effect.gen when it contains only a single return statement | ✓ | ✓ |
|
|
96
|
+
| `unnecessaryFailYieldableError` | 💡 | 🔧 | Suggests yielding yieldable errors directly instead of wrapping with Effect.fail | ✓ | ✓ |
|
|
97
|
+
| `unnecessaryPipe` | 💡 | 🔧 | Removes pipe calls with no arguments | ✓ | ✓ |
|
|
98
|
+
| `unnecessaryPipeChain` | 💡 | 🔧 | Simplifies chained pipe calls into a single pipe call | ✓ | ✓ |
|
|
99
|
+
| `unsupportedServiceAccessors` | ⚠️ | 🔧 | Warns about service accessors that need codegen due to generic/complex signatures | ✓ | ✓ |
|
|
100
|
+
|
|
101
|
+
`➖` off by default, `❌` error, `⚠️` warning, `💬` message, `💡` suggestion, `🔧` quick fix available
|
|
102
|
+
<!-- diagnostics-table:end -->
|
|
103
|
+
|
|
42
104
|
### Quickinfo
|
|
43
105
|
|
|
44
106
|
- Show the extended type of the current Effect
|
|
@@ -46,48 +108,6 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
|
|
|
46
108
|
- Hovering a variable assignment of a type Layer, will show info on how each service got involved
|
|
47
109
|
- Hovering a layer, will attempt to produce a graph
|
|
48
110
|
|
|
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
111
|
### Completions
|
|
92
112
|
|
|
93
113
|
- Autocomplete 'Self' in `Effect.Service`, `Context.Tag`, `Schema.TaggedClass`, `Schema.TaggedRequest`, `ServiceMap.Service`, `Model.Class` and family
|
|
@@ -145,7 +165,9 @@ Few options can be provided alongside the initialization of the Language Service
|
|
|
145
165
|
"missingDiagnosticNextLine": "warning", // controls the severity of warnings for unused @effect-diagnostics-next-line comments (default: "warning", allowed values: off,error,warning,message,suggestion)
|
|
146
166
|
"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
167
|
"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)
|
|
168
|
+
"ignoreEffectErrorsInTscExitCode": false, // if set to true, effect-related errors won't change the exit code of tsc (default: false)
|
|
148
169
|
"ignoreEffectSuggestionsInTscExitCode": true, // if set to true, effect-related suggestions won't change the exit code of tsc (default: true)
|
|
170
|
+
"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
171
|
"quickinfo": true, // controls Effect quickinfo (default: true)
|
|
150
172
|
"quickinfoEffectParameters": "whenTruncated", // (default: "whenTruncated") controls when to display effect type parameters always,never,whenTruncated
|
|
151
173
|
"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.)
|