Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/old-pugs-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/language-service": patch
---

Update the Effect v4 beta examples and type parsing to match the renamed Context APIs in the latest 4.0.0-beta releases.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Some diagnostics are off by default or have a default severity of suggestion, bu
<tr><td><code>redundantSchemaTagIdentifier</code></td><td>💡</td><td>🔧</td><td>Suggests removing redundant identifier argument when it equals the tag value in Schema.TaggedClass/TaggedError/TaggedRequest</td><td>✓</td><td>✓</td></tr>
<tr><td><code>schemaStructWithTag</code></td><td>💡</td><td>🔧</td><td>Suggests using Schema.TaggedStruct instead of Schema.Struct with _tag field</td><td>✓</td><td>✓</td></tr>
<tr><td><code>schemaUnionOfLiterals</code></td><td>➖</td><td>🔧</td><td>Simplifies Schema.Union of multiple Schema.Literal calls into single Schema.Literal</td><td>✓</td><td></td></tr>
<tr><td><code>serviceNotAsClass</code></td><td>➖</td><td>🔧</td><td>Warns when ServiceMap.Service is used as a variable instead of a class declaration</td><td></td><td>✓</td></tr>
<tr><td><code>serviceNotAsClass</code></td><td>➖</td><td>🔧</td><td>Warns when Context.Service is used as a variable instead of a class declaration</td><td></td><td>✓</td></tr>
<tr><td><code>strictBooleanExpressions</code></td><td>➖</td><td></td><td>Enforces boolean types in conditional expressions for type safety</td><td>✓</td><td>✓</td></tr>
<tr><td><code>unnecessaryArrowBlock</code></td><td>➖</td><td>🔧</td><td>Suggests using a concise arrow body when the block only returns an expression</td><td>✓</td><td>✓</td></tr>
<tr><td><code>unnecessaryEffectGen</code></td><td>💡</td><td>🔧</td><td>Suggests removing Effect.gen when it contains only a single return statement</td><td>✓</td><td>✓</td></tr>
Expand Down
46 changes: 23 additions & 23 deletions packages/harness-effect-v4/__snapshots__/completions.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -335,27 +335,27 @@ exports[`Completion genFunctionStar > genFunctionStar.ts at 4:24 1`] = `

exports[`Completion genFunctionStar > genFunctionStar_imports.ts at 2:16 1`] = `[]`;

exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses.ts at 4:43 1`] = `
exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses.ts at 4:40 1`] = `
[
{
"insertText": "ServiceMap.Service<MyService, {\${0}}>()("@effect/harness-effect-v4/MyService"){}",
"insertText": "Context.Service<MyService, {\${0}}>()("@effect/harness-effect-v4/MyService"){}",
"isSnippet": true,
"kind": "const",
"name": "Service<MyService, {}>",
"replacementSpan": {
"length": 11,
"start": 153,
"length": 8,
"start": 147,
},
"sortText": "11",
},
{
"insertText": "ServiceMap.Service<MyService>()("@effect/harness-effect-v4/MyService", { make: \${0} }){}",
"insertText": "Context.Service<MyService>()("@effect/harness-effect-v4/MyService", { make: \${0} }){}",
"isSnippet": true,
"kind": "const",
"name": "Service<MyService>({ make })",
"replacementSpan": {
"length": 11,
"start": 153,
"length": 8,
"start": 147,
},
"sortText": "11",
},
Expand All @@ -371,7 +371,7 @@ exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_directImpo
"name": "Service<MyService, {}>",
"replacementSpan": {
"length": 7,
"start": 149,
"start": 146,
},
"sortText": "11",
},
Expand All @@ -382,61 +382,61 @@ exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_directImpo
"name": "Service<MyService>({ make })",
"replacementSpan": {
"length": 7,
"start": 149,
"start": 146,
},
"sortText": "11",
},
]
`;

exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_identifierKey.ts at 5:43 1`] = `
exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_identifierKey.ts at 5:40 1`] = `
[
{
"insertText": "ServiceMap.Service<MyService, {\${0}}>()("@effect/harness-effect-v4/MyService"){}",
"insertText": "Context.Service<MyService, {\${0}}>()("@effect/harness-effect-v4/MyService"){}",
"isSnippet": true,
"kind": "const",
"name": "Service<MyService, {}>",
"replacementSpan": {
"length": 11,
"start": 249,
"length": 8,
"start": 243,
},
"sortText": "11",
},
{
"insertText": "ServiceMap.Service<MyService>()("@effect/harness-effect-v4/MyService", { make: \${0} }){}",
"insertText": "Context.Service<MyService>()("@effect/harness-effect-v4/MyService", { make: \${0} }){}",
"isSnippet": true,
"kind": "const",
"name": "Service<MyService>({ make })",
"replacementSpan": {
"length": 11,
"start": 249,
"length": 8,
"start": 243,
},
"sortText": "11",
},
]
`;

exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_middle.ts at 4:31 1`] = `
exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_middle.ts at 4:28 1`] = `
[
{
"insertText": "ServiceMap.Service<Foo, {\${0}}>()("@effect/harness-effect-v4/Foo"){}",
"insertText": "Context.Service<Foo, {\${0}}>()("@effect/harness-effect-v4/Foo"){}",
"isSnippet": true,
"kind": "const",
"name": "Service<Foo, {}>",
"replacementSpan": {
"length": 12,
"start": 144,
"length": 9,
"start": 141,
},
"sortText": "11",
},
{
"insertText": "ServiceMap.Service<Foo>()("@effect/harness-effect-v4/Foo", { make: \${0} }){}",
"insertText": "Context.Service<Foo>()("@effect/harness-effect-v4/Foo", { make: \${0} }){}",
"isSnippet": true,
"kind": "const",
"name": "Service<Foo>({ make })",
"replacementSpan": {
"length": 12,
"start": 144,
"length": 9,
"start": 141,
},
"sortText": "11",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
anyUnknownInErrorContext_skipNextLine from 1140 to 1152
anyUnknownInErrorContext_skipFile from 1140 to 1152
anyUnknownInErrorContext_skipNextLine from 1086 to 1106
anyUnknownInErrorContext_skipFile from 1086 to 1106
anyUnknownInErrorContext_skipNextLine from 1059 to 1071
anyUnknownInErrorContext_skipFile from 1059 to 1071
anyUnknownInErrorContext_skipNextLine from 1024 to 1036
anyUnknownInErrorContext_skipFile from 1024 to 1036
anyUnknownInErrorContext_skipNextLine from 991 to 1017
anyUnknownInErrorContext_skipFile from 991 to 1017
anyUnknownInErrorContext_skipNextLine from 976 to 988
anyUnknownInErrorContext_skipFile from 976 to 988
anyUnknownInErrorContext_skipNextLine from 596 to 616
anyUnknownInErrorContext_skipFile from 596 to 616
anyUnknownInErrorContext_skipNextLine from 553 to 579
anyUnknownInErrorContext_skipFile from 553 to 579
anyUnknownInErrorContext_skipNextLine from 499 to 516
anyUnknownInErrorContext_skipFile from 499 to 516
anyUnknownInErrorContext_skipNextLine from 457 to 481
anyUnknownInErrorContext_skipFile from 457 to 481
anyUnknownInErrorContext_skipNextLine from 395 to 413
anyUnknownInErrorContext_skipFile from 395 to 413
anyUnknownInErrorContext_skipNextLine from 357 to 377
anyUnknownInErrorContext_skipFile from 357 to 377
anyUnknownInErrorContext_skipNextLine from 299 to 313
anyUnknownInErrorContext_skipFile from 299 to 313
anyUnknownInErrorContext_skipNextLine from 259 to 281
anyUnknownInErrorContext_skipFile from 259 to 281
anyUnknownInErrorContext_skipNextLine from 208 to 222
anyUnknownInErrorContext_skipFile from 208 to 222
anyUnknownInErrorContext_skipNextLine from 164 to 190
anyUnknownInErrorContext_skipFile from 164 to 190
anyUnknownInErrorContext_skipNextLine from 1136 to 1148
anyUnknownInErrorContext_skipFile from 1136 to 1148
anyUnknownInErrorContext_skipNextLine from 1082 to 1102
anyUnknownInErrorContext_skipFile from 1082 to 1102
anyUnknownInErrorContext_skipNextLine from 1055 to 1067
anyUnknownInErrorContext_skipFile from 1055 to 1067
anyUnknownInErrorContext_skipNextLine from 1020 to 1032
anyUnknownInErrorContext_skipFile from 1020 to 1032
anyUnknownInErrorContext_skipNextLine from 988 to 1013
anyUnknownInErrorContext_skipFile from 988 to 1013
anyUnknownInErrorContext_skipNextLine from 973 to 985
anyUnknownInErrorContext_skipFile from 973 to 985
anyUnknownInErrorContext_skipNextLine from 593 to 613
anyUnknownInErrorContext_skipFile from 593 to 613
anyUnknownInErrorContext_skipNextLine from 551 to 576
anyUnknownInErrorContext_skipFile from 551 to 576
anyUnknownInErrorContext_skipNextLine from 497 to 514
anyUnknownInErrorContext_skipFile from 497 to 514
anyUnknownInErrorContext_skipNextLine from 455 to 479
anyUnknownInErrorContext_skipFile from 455 to 479
anyUnknownInErrorContext_skipNextLine from 393 to 411
anyUnknownInErrorContext_skipFile from 393 to 411
anyUnknownInErrorContext_skipNextLine from 355 to 375
anyUnknownInErrorContext_skipFile from 355 to 375
anyUnknownInErrorContext_skipNextLine from 297 to 311
anyUnknownInErrorContext_skipFile from 297 to 311
anyUnknownInErrorContext_skipNextLine from 258 to 279
anyUnknownInErrorContext_skipFile from 258 to 279
anyUnknownInErrorContext_skipNextLine from 207 to 221
anyUnknownInErrorContext_skipFile from 207 to 221
anyUnknownInErrorContext_skipNextLine from 164 to 189
anyUnknownInErrorContext_skipFile from 164 to 189
anyUnknownInErrorContext_skipNextLine from 109 to 127
anyUnknownInErrorContext_skipFile from 109 to 127
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ withUnknownContext
4:13 - 4:31 | 0 | This has unknown in the requirements channel which is not recommended.
Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext)

Effect.services<unknown>()
5:9 - 5:35 | 0 | This has unknown in the requirements channel which is not recommended.
Effect.context<unknown>()
5:9 - 5:34 | 0 | This has unknown in the requirements channel which is not recommended.
Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext)

withAnyContext
8:13 - 8:27 | 0 | This has any in the requirements channel which is not recommended.
Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext)

Effect.services<any>()
9:9 - 9:31 | 0 | This has any in the requirements channel which is not recommended.
Effect.context<any>()
9:9 - 9:30 | 0 | This has any in the requirements channel which is not recommended.
Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext)

withAnyFailure
Expand All @@ -35,8 +35,8 @@ hasBothAnyUnknown
Only service identifiers should appear in the requirements channel.
Having an unknown or any error type is not useful. Consider instead using specific error types baked by Data.TaggedError for example. effect(anyUnknownInErrorContext)

Effect.services<unknown>()
21:9 - 21:35 | 0 | This has unknown in the requirements channel which is not recommended.
Effect.context<unknown>()
21:9 - 21:34 | 0 | This has unknown in the requirements channel which is not recommended.
Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext)

Effect.fail<any>(42)
Expand All @@ -47,8 +47,8 @@ effectUnkown
37:6 - 37:18 | 0 | This has unknown in the requirements channel which is not recommended.
Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext)

Effect.services<unknown>()
37:21 - 37:47 | 0 | This has unknown in the requirements channel which is not recommended.
Effect.context<unknown>()
37:21 - 37:46 | 0 | This has unknown in the requirements channel which is not recommended.
Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext)

layerUnknown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
anyUnknownInErrorContext_skipNextLine from 218 to 242
anyUnknownInErrorContext_skipFile from 218 to 242
anyUnknownInErrorContext_skipNextLine from 175 to 201
anyUnknownInErrorContext_skipFile from 175 to 201
anyUnknownInErrorContext_skipNextLine from 217 to 241
anyUnknownInErrorContext_skipFile from 217 to 241
anyUnknownInErrorContext_skipNextLine from 175 to 200
anyUnknownInErrorContext_skipFile from 175 to 200
anyUnknownInErrorContext_skipNextLine from 131 to 138
anyUnknownInErrorContext_skipFile from 131 to 138
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ preview
Only service identifiers should appear in the requirements channel.
Having an unknown or any error type is not useful. Consider instead using specific error types baked by Data.TaggedError for example. effect(anyUnknownInErrorContext)

Effect.services<unknown>()
6:9 - 6:35 | 0 | This has unknown in the requirements channel which is not recommended.
Effect.context<unknown>()
6:9 - 6:34 | 0 | This has unknown in the requirements channel which is not recommended.
Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext)

Effect.fail<any>("boom")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// code fix classSelfMismatch_fix output for range 308 - 319
import { Context, Effect } from "effect"

export class CorrectName extends Context.Service<CorrectName, {
writeCache: () => Effect.Effect<void, never, FileSystem | Cache>
readCache: Effect.Effect<void, never, FileSystem | Cache>
}>()("CorrectName") {}

export class WrongName extends Context.Service<WrongName, {
writeCache: () => Effect.Effect<void, never, FileSystem | Cache>
readCache: Effect.Effect<void, never, FileSystem | Cache>
}>()("WrongName") {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
classSelfMismatch_fix from 317 to 328
classSelfMismatch_skipNextLine from 317 to 328
classSelfMismatch_skipFile from 317 to 328
classSelfMismatch_fix from 308 to 319
classSelfMismatch_skipNextLine from 308 to 319
classSelfMismatch_skipFile from 308 to 319
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CorrectName
8:50 - 8:61 | 1 | The `Self` type parameter for this class should be `WrongName`. effect(classSelfMismatch)
8:47 - 8:58 | 1 | The `Self` type parameter for this class should be `WrongName`. effect(classSelfMismatch)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
deterministicKeys_fix from 321 to 348
deterministicKeys_skipNextLine from 321 to 348
deterministicKeys_skipFile from 321 to 348
deterministicKeys_fix from 399 to 407
deterministicKeys_skipNextLine from 399 to 407
deterministicKeys_skipFile from 399 to 407
deterministicKeys_fix from 315 to 342
deterministicKeys_skipNextLine from 315 to 342
deterministicKeys_skipFile from 315 to 342
deterministicKeys_fix from 393 to 401
deterministicKeys_skipNextLine from 393 to 401
deterministicKeys_skipFile from 393 to 401
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// code fix deterministicKeys_fix output for range 315 - 342
// @effect-diagnostics deterministicKeys:error
// @test-config { "keyPatterns": [ { "target": "service", "pattern": "default" }, { "target": "error", "pattern": "default" } ] }
import { Context, Data } from "effect"

export class ExpectedServiceIdentifier
extends Context.Service<ExpectedServiceIdentifier, {}>()("@effect/harness-effect-v4/ExpectedServiceIdentifier")
{}

export class ErrorA extends Data.TaggedError("ErrorA")<{}> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// code fix deterministicKeys_fix output for range 393 - 401
// @effect-diagnostics deterministicKeys:error
// @test-config { "keyPatterns": [ { "target": "service", "pattern": "default" }, { "target": "error", "pattern": "default" } ] }
import { Context, Data } from "effect"

export class ExpectedServiceIdentifier
extends Context.Service<ExpectedServiceIdentifier, {}>()("ExpectedServiceIdentifier")
{}

export class ErrorA extends Data.TaggedError("@effect/harness-effect-v4/ErrorA")<{}> {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"ExpectedServiceIdentifier"
6:62 - 6:89 | 1 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/ExpectedServiceIdentifier`. effect(deterministicKeys)
6:59 - 6:86 | 1 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/ExpectedServiceIdentifier`. effect(deterministicKeys)

"ErrorA"
9:45 - 9:53 | 1 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/ErrorA`. effect(deterministicKeys)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
deterministicKeys_fix from 427 to 434
deterministicKeys_skipNextLine from 427 to 434
deterministicKeys_skipFile from 427 to 434
deterministicKeys_fix from 554 to 566
deterministicKeys_skipNextLine from 554 to 566
deterministicKeys_skipFile from 554 to 566
deterministicKeys_fix from 421 to 428
deterministicKeys_skipNextLine from 421 to 428
deterministicKeys_skipFile from 421 to 428
deterministicKeys_fix from 548 to 560
deterministicKeys_skipNextLine from 548 to 560
deterministicKeys_skipFile from 548 to 560
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// code fix deterministicKeys_fix output for range 421 - 428
// @effect-diagnostics deterministicKeys:error
// @test-config { "extendedKeyDetection": true }
import * as Persistable from "@/diagnostics/utils"
import { Context } from "effect"

// simple case inside same file
export function MyConstructor<X>(/** @effect-identifier */ identifier: string) {
return class extends Context.Service<X, {}>()("hey/" + identifier) {}
}

export class MyClass extends MyConstructor<MyClass>("@effect/harness-effect-v4/MyClass") {
}

// referenced on another file
export class TTLRequest extends Persistable.Class<{
payload: { id: number }
}>()("TTLRequest", {
primaryKey: (req) => `TTLRequest:${req.id}`
}) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// code fix deterministicKeys_fix output for range 548 - 560
// @effect-diagnostics deterministicKeys:error
// @test-config { "extendedKeyDetection": true }
import * as Persistable from "@/diagnostics/utils"
import { Context } from "effect"

// simple case inside same file
export function MyConstructor<X>(/** @effect-identifier */ identifier: string) {
return class extends Context.Service<X, {}>()("hey/" + identifier) {}
}

export class MyClass extends MyConstructor<MyClass>("Hello") {
}

// referenced on another file
export class TTLRequest extends Persistable.Class<{
payload: { id: number }
}>()("@effect/harness-effect-v4/TTLRequest", {
primaryKey: (req) => `TTLRequest:${req.id}`
}) {}
Loading
Loading