diff --git a/.changeset/effect-fn-opportunity-inferred-layer-v4.md b/.changeset/effect-fn-opportunity-inferred-layer-v4.md new file mode 100644 index 00000000..a7aaf624 --- /dev/null +++ b/.changeset/effect-fn-opportunity-inferred-layer-v4.md @@ -0,0 +1,18 @@ +--- +"@effect/language-service": minor +--- + +Improve `effectFnOpportunity` inferred span naming for service-layer methods and align examples for Effect v4. + +The inferred span can now include service + method names (for example `MyService.log`) when the convertible function is a method inside a layer service object for strict supported patterns like: + +- `Layer.succeed(Service)(...)` +- `Layer.sync(Service)(...)` +- `Layer.effect(Service)(Effect.gen(...))` +- `Layer.effect(Service, Effect.gen(...))` + +Also add Effect v4 diagnostics fixtures for: + +- `effectFnOpportunity_inferred.ts` +- `effectFnOpportunity_inferredLayer.ts` + diff --git a/README.md b/README.md index f73626df..9cf591fe 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ Few options can be provided alongside the initialization of the Language Service "importAliases": { "Array": "Arr" }, // allows to chose some different names for import name aliases (only when not chosing to import the whole module) (default: {}) "noExternal": false, // disables features that provides links to external websites (such as links to mermaidchart.com) (default: false) "keyPatterns": [{ "target": "service", "pattern": "default", "skipLeadingPath": ["src/"] }], // configure the key patterns; recommended reading more on the section "Configuring Key Patterns" - "effectFn": ["span"], // what types of Effect.fn you want to get suggested, zero or multiple between "untraced" for fnUntraced, "span" for Effect.fn with span, "inferred-span" for Effect.fn with the inferred span name, "no-span" for Effect.fn with no span (default: ["span"]) + "effectFn": ["span"], // what types of Effect.fn you want to get suggested, zero or multiple between "untraced" for fnUntraced, "span" for Effect.fn with explicit withSpan span, "suggested-span" for Effect.fn with a broadly suggested name from local context, "inferred-span" for Effect.fn with inferred exported declaration names, "no-span" for Effect.fn with no span (default: ["span"]) "layerGraphFollowDepth": 0, // controls the depth level that the layer graph will follow when resolving layer dependencies, depth is counted only when exiting the currently hovered/analyzed layer definition (default: 0) "mermaidProvider": "mermaid.live" // which provider to use for mermaid, can also be a uri like http://localhost:8080 if running mermaid-live-editor locally. } diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.codefixes b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.codefixes index dedb7404..08c81e25 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.codefixes +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.codefixes @@ -1,20 +1,20 @@ -effectFnOpportunity_toEffectFnUntraced from 762 to 784 -effectFnOpportunity_toEffectFnNoSpan from 762 to 784 -effectFnOpportunity_toEffectFnSpanInferred from 762 to 784 -effectFnOpportunity_skipNextLine from 762 to 784 -effectFnOpportunity_skipFile from 762 to 784 -effectFnOpportunity_toEffectFnUntraced from 386 to 399 -effectFnOpportunity_toEffectFnNoSpan from 386 to 399 -effectFnOpportunity_toEffectFnSpanInferred from 386 to 399 -effectFnOpportunity_skipNextLine from 386 to 399 -effectFnOpportunity_skipFile from 386 to 399 -effectFnOpportunity_toEffectFnUntraced from 508 to 526 -effectFnOpportunity_toEffectFnNoSpan from 508 to 526 -effectFnOpportunity_toEffectFnSpanInferred from 508 to 526 -effectFnOpportunity_skipNextLine from 508 to 526 -effectFnOpportunity_skipFile from 508 to 526 -effectFnOpportunity_toEffectFnUntraced from 624 to 645 -effectFnOpportunity_toEffectFnNoSpan from 624 to 645 -effectFnOpportunity_toEffectFnSpanInferred from 624 to 645 -effectFnOpportunity_skipNextLine from 624 to 645 -effectFnOpportunity_skipFile from 624 to 645 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 780 to 802 +effectFnOpportunity_toEffectFnNoSpan from 780 to 802 +effectFnOpportunity_toEffectFnSpanInferred from 780 to 802 +effectFnOpportunity_skipNextLine from 780 to 802 +effectFnOpportunity_skipFile from 780 to 802 +effectFnOpportunity_toEffectFnUntraced from 404 to 417 +effectFnOpportunity_toEffectFnNoSpan from 404 to 417 +effectFnOpportunity_toEffectFnSpanInferred from 404 to 417 +effectFnOpportunity_skipNextLine from 404 to 417 +effectFnOpportunity_skipFile from 404 to 417 +effectFnOpportunity_toEffectFnUntraced from 526 to 544 +effectFnOpportunity_toEffectFnNoSpan from 526 to 544 +effectFnOpportunity_toEffectFnSpanInferred from 526 to 544 +effectFnOpportunity_skipNextLine from 526 to 544 +effectFnOpportunity_skipFile from 526 to 544 +effectFnOpportunity_toEffectFnUntraced from 642 to 663 +effectFnOpportunity_toEffectFnNoSpan from 642 to 663 +effectFnOpportunity_toEffectFnSpanInferred from 642 to 663 +effectFnOpportunity_skipNextLine from 642 to 663 +effectFnOpportunity_skipFile from 642 to 663 \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from404to417.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from404to417.output new file mode 100644 index 00000000..aaef22e1 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from404to417.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 404 - 417 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = Effect.fn(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from526to544.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from526to544.output new file mode 100644 index 00000000..5b2c6348 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from526to544.output @@ -0,0 +1,35 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 526 - 544 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = Effect.fn(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from642to663.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from642to663.output new file mode 100644 index 00000000..78f518a3 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from642to663.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 642 - 663 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = Effect.fn(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from780to802.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from780to802.output new file mode 100644 index 00000000..473261eb --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from780to802.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 780 - 802 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const functionDeclarationGen = Effect.fn(function*() { + yield* Effect.succeed(1) + return 42 +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from404to417.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from404to417.output new file mode 100644 index 00000000..0eee93c8 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from404to417.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 404 - 417 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = Effect.fn("arrowBlockGen")(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from526to544.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from526to544.output new file mode 100644 index 00000000..3e1a55a0 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from526to544.output @@ -0,0 +1,35 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 526 - 544 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = Effect.fn("arrowExpressionGen")(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from642to663.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from642to663.output new file mode 100644 index 00000000..7e40191d --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from642to663.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 642 - 663 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = Effect.fn("functionExpressionGen")(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from780to802.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from780to802.output new file mode 100644 index 00000000..4b9dab9a --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from780to802.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 780 - 802 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const functionDeclarationGen = Effect.fn("functionDeclarationGen")(function*() { + yield* Effect.succeed(1) + return 42 +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from404to417.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from404to417.output new file mode 100644 index 00000000..86e6376d --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from404to417.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 404 - 417 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = Effect.fnUntraced(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from526to544.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from526to544.output new file mode 100644 index 00000000..f050fe68 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from526to544.output @@ -0,0 +1,35 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 526 - 544 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = Effect.fnUntraced(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from642to663.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from642to663.output new file mode 100644 index 00000000..76774130 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from642to663.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 642 - 663 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = Effect.fnUntraced(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from780to802.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from780to802.output new file mode 100644 index 00000000..19a42544 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from780to802.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 780 - 802 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const functionDeclarationGen = Effect.fnUntraced(function*() { + yield* Effect.succeed(1) + return 42 +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.codefixes b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.codefixes new file mode 100644 index 00000000..aab6d1d4 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.codefixes @@ -0,0 +1,6 @@ +effectFnOpportunity_toEffectFnSpanInferred from 373 to 400 +effectFnOpportunity_skipNextLine from 373 to 400 +effectFnOpportunity_skipFile from 373 to 400 +effectFnOpportunity_toEffectFnSpanInferred from 230 to 250 +effectFnOpportunity_skipNextLine from 230 to 250 +effectFnOpportunity_skipFile from 230 to 250 \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from230to250.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from230to250.output new file mode 100644 index 00000000..7d20add9 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from230to250.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 230 - 250 +// @test-config { "effectFn": ["inferred-span"] } +import * as Effect from "effect/Effect" + + +const _notExporedNoSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const shouldHaveSuggestion = Effect.fn("shouldHaveSuggestion")(function*() { + yield* Effect.succeed(1) + return 42 +}) + + +export function shouldHaveSuggestioFunction() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + } + + diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from373to400.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from373to400.output new file mode 100644 index 00000000..8ca92df1 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from373to400.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 373 - 400 +// @test-config { "effectFn": ["inferred-span"] } +import * as Effect from "effect/Effect" + + +const _notExporedNoSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const shouldHaveSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + } + + +export const shouldHaveSuggestioFunction = Effect.fn("shouldHaveSuggestioFunction")(function*() { + yield* Effect.succeed(1) + return 42 +}) + + diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.output new file mode 100644 index 00000000..2ef18691 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.output @@ -0,0 +1,5 @@ +shouldHaveSuggestion +12:13 - 12:33 | 2 | Can be rewritten as a reusable function: Effect.fn("shouldHaveSuggestion")(function*() { ... }) effect(effectFnOpportunity) + +shouldHaveSuggestioFunction +20:16 - 20:43 | 2 | Can be rewritten as a reusable function: Effect.fn("shouldHaveSuggestioFunction")(function*() { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes new file mode 100644 index 00000000..1b2bcf1f --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes @@ -0,0 +1,12 @@ +effectFnOpportunity_toEffectFnSpanInferred from 845 to 848 +effectFnOpportunity_skipNextLine from 845 to 848 +effectFnOpportunity_skipFile from 845 to 848 +effectFnOpportunity_toEffectFnSpanInferred from 1013 to 1016 +effectFnOpportunity_skipNextLine from 1013 to 1016 +effectFnOpportunity_skipFile from 1013 to 1016 +effectFnOpportunity_toEffectFnSpanInferred from 457 to 460 +effectFnOpportunity_skipNextLine from 457 to 460 +effectFnOpportunity_skipFile from 457 to 460 +effectFnOpportunity_toEffectFnSpanInferred from 683 to 686 +effectFnOpportunity_skipNextLine from 683 to 686 +effectFnOpportunity_skipFile from 683 to 686 \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from1013to1016.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from1013to1016.output new file mode 100644 index 00000000..d8674767 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from1013to1016.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1013 - 1016 +// @test-config { "effectFn": ["inferred-span"] } +import * as Context from "effect/Context" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" + +class MyService extends Context.Tag("MyService") Effect.Effect +} +>(){} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from1052to1055.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from1052to1055.output new file mode 100644 index 00000000..2b1a24d8 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from1052to1055.output @@ -0,0 +1,46 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1052 - 1055 +// @test-config { "effectFn": ["inferred-span"] } +import * as Context from "effect/Context" +import * as Effect from "effect/Effect" +import { pipe } from "effect/Function" +import * as Layer from "effect/Layer" + +class MyService extends Context.Tag("MyService") Effect.Effect +} +>(){} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +}) + +const _shouldTriggerPipeableEffect = pipe(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}), Layer.effect(MyService)) + +const _shouldTriggerPipeableSucceed = pipe({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}, Layer.succeed(MyService)) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from457to460.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from457to460.output new file mode 100644 index 00000000..d5b524f3 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from457to460.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 457 - 460 +// @test-config { "effectFn": ["inferred-span"] } +import * as Context from "effect/Context" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" + +class MyService extends Context.Tag("MyService") Effect.Effect +} +>(){} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from496to499.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from496to499.output new file mode 100644 index 00000000..753e4ac5 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from496to499.output @@ -0,0 +1,46 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 496 - 499 +// @test-config { "effectFn": ["inferred-span"] } +import * as Context from "effect/Context" +import * as Effect from "effect/Effect" +import { pipe } from "effect/Function" +import * as Layer from "effect/Layer" + +class MyService extends Context.Tag("MyService") Effect.Effect +} +>(){} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) + +const _shouldTriggerPipeableEffect = pipe(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}), Layer.effect(MyService)) + +const _shouldTriggerPipeableSucceed = pipe({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}, Layer.succeed(MyService)) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from683to686.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from683to686.output new file mode 100644 index 00000000..f828ab0b --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from683to686.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 683 - 686 +// @test-config { "effectFn": ["inferred-span"] } +import * as Context from "effect/Context" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" + +class MyService extends Context.Tag("MyService") Effect.Effect +} +>(){} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from722to725.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from722to725.output new file mode 100644 index 00000000..df387473 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from722to725.output @@ -0,0 +1,46 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 722 - 725 +// @test-config { "effectFn": ["inferred-span"] } +import * as Context from "effect/Context" +import * as Effect from "effect/Effect" +import { pipe } from "effect/Function" +import * as Layer from "effect/Layer" + +class MyService extends Context.Tag("MyService") Effect.Effect +} +>(){} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) + +const _shouldTriggerPipeableEffect = pipe(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}), Layer.effect(MyService)) + +const _shouldTriggerPipeableSucceed = pipe({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}, Layer.succeed(MyService)) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from845to848.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from845to848.output new file mode 100644 index 00000000..af44ba2a --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from845to848.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 845 - 848 +// @test-config { "effectFn": ["inferred-span"] } +import * as Context from "effect/Context" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" + +class MyService extends Context.Tag("MyService") Effect.Effect +} +>(){} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from884to887.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from884to887.output new file mode 100644 index 00000000..bf4dde46 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from884to887.output @@ -0,0 +1,46 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 884 - 887 +// @test-config { "effectFn": ["inferred-span"] } +import * as Context from "effect/Context" +import * as Effect from "effect/Effect" +import { pipe } from "effect/Function" +import * as Layer from "effect/Layer" + +class MyService extends Context.Tag("MyService") Effect.Effect +} +>(){} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) + +const _shouldTriggerPipeableEffect = pipe(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}), Layer.effect(MyService)) + +const _shouldTriggerPipeableSucceed = pipe({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}, Layer.succeed(MyService)) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.output new file mode 100644 index 00000000..84cf3a50 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.output @@ -0,0 +1,11 @@ +log +14:13 - 14:16 | 2 | Can be rewritten as a reusable function: Effect.fn("MyService.log")((what) => { ... }) effect(effectFnOpportunity) + +log +20:13 - 20:16 | 2 | Can be rewritten as a reusable function: Effect.fn("MyService.log")((what) => { ... }) effect(effectFnOpportunity) + +log +25:4 - 25:7 | 2 | Can be rewritten as a reusable function: Effect.fn("MyService.log")((what) => { ... }) effect(effectFnOpportunity) + +log +30:13 - 30:16 | 2 | Can be rewritten as a reusable function: Effect.fn("MyService.log")((what) => { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.codefixes b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.codefixes index 077a7a44..99a204e4 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.codefixes +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.codefixes @@ -1,15 +1,15 @@ -effectFnOpportunity_toEffectFnUntraced from 701 to 728 -effectFnOpportunity_toEffectFnNoSpan from 701 to 728 -effectFnOpportunity_toEffectFnSpanInferred from 701 to 728 -effectFnOpportunity_skipNextLine from 701 to 728 -effectFnOpportunity_skipFile from 701 to 728 -effectFnOpportunity_toEffectFnUntraced from 360 to 373 -effectFnOpportunity_toEffectFnNoSpan from 360 to 373 -effectFnOpportunity_toEffectFnSpanInferred from 360 to 373 -effectFnOpportunity_skipNextLine from 360 to 373 -effectFnOpportunity_skipFile from 360 to 373 -effectFnOpportunity_toEffectFnUntraced from 491 to 517 -effectFnOpportunity_toEffectFnNoSpan from 491 to 517 -effectFnOpportunity_toEffectFnSpanInferred from 491 to 517 -effectFnOpportunity_skipNextLine from 491 to 517 -effectFnOpportunity_skipFile from 491 to 517 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 719 to 746 +effectFnOpportunity_toEffectFnNoSpan from 719 to 746 +effectFnOpportunity_toEffectFnSpanInferred from 719 to 746 +effectFnOpportunity_skipNextLine from 719 to 746 +effectFnOpportunity_skipFile from 719 to 746 +effectFnOpportunity_toEffectFnUntraced from 378 to 391 +effectFnOpportunity_toEffectFnNoSpan from 378 to 391 +effectFnOpportunity_toEffectFnSpanInferred from 378 to 391 +effectFnOpportunity_skipNextLine from 378 to 391 +effectFnOpportunity_skipFile from 378 to 391 +effectFnOpportunity_toEffectFnUntraced from 509 to 535 +effectFnOpportunity_toEffectFnNoSpan from 509 to 535 +effectFnOpportunity_toEffectFnSpanInferred from 509 to 535 +effectFnOpportunity_skipNextLine from 509 to 535 +effectFnOpportunity_skipFile from 509 to 535 \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from378to391.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from378to391.output new file mode 100644 index 00000000..a8fc4d10 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from378to391.output @@ -0,0 +1,23 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 378 - 391 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.ignoreLogged) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignoreLogged) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignoreLogged) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from509to535.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from509to535.output new file mode 100644 index 00000000..f211a9a3 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from509to535.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 509 - 535 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignoreLogged) + +export const functionExpressionWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("functionExpressionWithPipe"), Effect.ignoreLogged) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignoreLogged) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from719to746.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from719to746.output new file mode 100644 index 00000000..8305848f --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from719to746.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 719 - 746 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignoreLogged) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignoreLogged) +} + +export const functionDeclarationWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignoreLogged) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from378to391.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from378to391.output new file mode 100644 index 00000000..67a89c92 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from378to391.output @@ -0,0 +1,23 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 378 - 391 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = Effect.fn("arrowWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.ignoreLogged) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignoreLogged) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignoreLogged) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from509to535.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from509to535.output new file mode 100644 index 00000000..26df52b1 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from509to535.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 509 - 535 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignoreLogged) + +export const functionExpressionWithPipe = Effect.fn("functionExpressionWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("functionExpressionWithPipe"), Effect.ignoreLogged) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignoreLogged) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from719to746.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from719to746.output new file mode 100644 index 00000000..5e783ee6 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from719to746.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 719 - 746 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignoreLogged) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignoreLogged) +} + +export const functionDeclarationWithPipe = Effect.fn("functionDeclarationWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignoreLogged) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from378to391.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from378to391.output new file mode 100644 index 00000000..e46d8b30 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from378to391.output @@ -0,0 +1,23 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 378 - 391 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.ignoreLogged) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignoreLogged) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignoreLogged) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from509to535.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from509to535.output new file mode 100644 index 00000000..5334e1e1 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from509to535.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 509 - 535 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignoreLogged) + +export const functionExpressionWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("functionExpressionWithPipe"), Effect.ignoreLogged) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignoreLogged) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from719to746.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from719to746.output new file mode 100644 index 00000000..9210cc4a --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from719to746.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 719 - 746 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignoreLogged) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignoreLogged) +} + +export const functionDeclarationWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignoreLogged) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.codefixes b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.codefixes index d4e16b62..3f26b532 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.codefixes +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.codefixes @@ -1,18 +1,18 @@ -effectFnOpportunity_toEffectFnUntraced from 449 to 464 -effectFnOpportunity_toEffectFnNoSpan from 449 to 464 -effectFnOpportunity_toEffectFnSpanInferred from 449 to 464 -effectFnOpportunity_skipNextLine from 449 to 464 -effectFnOpportunity_skipFile from 449 to 464 -effectFnOpportunity_toEffectFnUntraced from 725 to 753 -effectFnOpportunity_toEffectFnNoSpan from 725 to 753 -effectFnOpportunity_toEffectFnSpanInferred from 725 to 753 -effectFnOpportunity_skipNextLine from 725 to 753 -effectFnOpportunity_skipFile from 725 to 753 -effectFnOpportunity_toEffectFnNoSpan from 1024 to 1044 -effectFnOpportunity_toEffectFnSpanInferred from 1024 to 1044 -effectFnOpportunity_skipNextLine from 1024 to 1044 -effectFnOpportunity_skipFile from 1024 to 1044 -effectFnOpportunity_toEffectFnNoSpan from 1342 to 1375 -effectFnOpportunity_toEffectFnSpanInferred from 1342 to 1375 -effectFnOpportunity_skipNextLine from 1342 to 1375 -effectFnOpportunity_skipFile from 1342 to 1375 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 467 to 482 +effectFnOpportunity_toEffectFnNoSpan from 467 to 482 +effectFnOpportunity_toEffectFnSpanInferred from 467 to 482 +effectFnOpportunity_skipNextLine from 467 to 482 +effectFnOpportunity_skipFile from 467 to 482 +effectFnOpportunity_toEffectFnUntraced from 743 to 771 +effectFnOpportunity_toEffectFnNoSpan from 743 to 771 +effectFnOpportunity_toEffectFnSpanInferred from 743 to 771 +effectFnOpportunity_skipNextLine from 743 to 771 +effectFnOpportunity_skipFile from 743 to 771 +effectFnOpportunity_toEffectFnNoSpan from 1042 to 1062 +effectFnOpportunity_toEffectFnSpanInferred from 1042 to 1062 +effectFnOpportunity_skipNextLine from 1042 to 1062 +effectFnOpportunity_skipFile from 1042 to 1062 +effectFnOpportunity_toEffectFnNoSpan from 1360 to 1393 +effectFnOpportunity_toEffectFnSpanInferred from 1360 to 1393 +effectFnOpportunity_skipNextLine from 1360 to 1393 +effectFnOpportunity_skipFile from 1360 to 1393 \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1042to1062.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1042to1062.output new file mode 100644 index 00000000..f1818620 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1042to1062.output @@ -0,0 +1,53 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 1042 - 1062 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = Effect.fn(function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1360to1393.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1360to1393.output new file mode 100644 index 00000000..9460b667 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1360to1393.output @@ -0,0 +1,53 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 1360 - 1393 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = Effect.fn(function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from467to482.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from467to482.output new file mode 100644 index 00000000..56a3cbab --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from467to482.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 467 - 482 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = Effect.fn(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from743to771.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from743to771.output new file mode 100644 index 00000000..1e7f50ea --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from743to771.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 743 - 771 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = Effect.fn(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1042to1062.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1042to1062.output new file mode 100644 index 00000000..3b093605 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1042to1062.output @@ -0,0 +1,53 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1042 - 1062 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = Effect.fn("overloadedArrowNoGen")(function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1360to1393.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1360to1393.output new file mode 100644 index 00000000..b6630fd8 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1360to1393.output @@ -0,0 +1,53 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1360 - 1393 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = Effect.fn("overloadedFunctionExpressionNoGen")(function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from467to482.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from467to482.output new file mode 100644 index 00000000..6a3a2e93 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from467to482.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 467 - 482 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = Effect.fn("overloadedArrow")(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from743to771.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from743to771.output new file mode 100644 index 00000000..21cc0003 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from743to771.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 743 - 771 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = Effect.fn("overloadedFunctionExpression")(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from467to482.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from467to482.output new file mode 100644 index 00000000..6a912d92 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from467to482.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 467 - 482 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = Effect.fnUntraced(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from743to771.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from743to771.output new file mode 100644 index 00000000..9575b71b --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from743to771.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 743 - 771 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = Effect.fnUntraced(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.output index 514508ff..5fac11d3 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.output +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.output @@ -5,7 +5,7 @@ overloadedFunctionExpression 22:13 - 22:41 | 2 | Can be rewritten as a reusable function: Effect.fnUntraced(function*(a) { ... }) effect(effectFnOpportunity) overloadedArrowNoGen -32:13 - 32:33 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(a) { ... }) effect(effectFnOpportunity) +32:13 - 32:33 | 2 | Can be rewritten as a reusable function: Effect.fn((a) => { ... }) effect(effectFnOpportunity) overloadedFunctionExpressionNoGen -45:13 - 45:46 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(a) { ... }) effect(effectFnOpportunity) \ No newline at end of file +45:13 - 45:46 | 2 | Can be rewritten as a reusable function: Effect.fn(function(a) { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.codefixes b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.codefixes index 80aae1f7..4dcca218 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.codefixes +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.codefixes @@ -1,15 +1,15 @@ -effectFnOpportunity_toEffectFnUntraced from 562 to 591 -effectFnOpportunity_toEffectFnNoSpan from 562 to 591 -effectFnOpportunity_toEffectFnSpanInferred from 562 to 591 -effectFnOpportunity_skipNextLine from 562 to 591 -effectFnOpportunity_skipFile from 562 to 591 -effectFnOpportunity_toEffectFnUntraced from 255 to 270 -effectFnOpportunity_toEffectFnNoSpan from 255 to 270 -effectFnOpportunity_toEffectFnSpanInferred from 255 to 270 -effectFnOpportunity_skipNextLine from 255 to 270 -effectFnOpportunity_skipFile from 255 to 270 -effectFnOpportunity_toEffectFnUntraced from 398 to 426 -effectFnOpportunity_toEffectFnNoSpan from 398 to 426 -effectFnOpportunity_toEffectFnSpanInferred from 398 to 426 -effectFnOpportunity_skipNextLine from 398 to 426 -effectFnOpportunity_skipFile from 398 to 426 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 580 to 609 +effectFnOpportunity_toEffectFnNoSpan from 580 to 609 +effectFnOpportunity_toEffectFnSpanInferred from 580 to 609 +effectFnOpportunity_skipNextLine from 580 to 609 +effectFnOpportunity_skipFile from 580 to 609 +effectFnOpportunity_toEffectFnUntraced from 273 to 288 +effectFnOpportunity_toEffectFnNoSpan from 273 to 288 +effectFnOpportunity_toEffectFnSpanInferred from 273 to 288 +effectFnOpportunity_skipNextLine from 273 to 288 +effectFnOpportunity_skipFile from 273 to 288 +effectFnOpportunity_toEffectFnUntraced from 416 to 444 +effectFnOpportunity_toEffectFnNoSpan from 416 to 444 +effectFnOpportunity_toEffectFnSpanInferred from 416 to 444 +effectFnOpportunity_skipNextLine from 416 to 444 +effectFnOpportunity_skipFile from 416 to 444 \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from273to288.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from273to288.output new file mode 100644 index 00000000..4204ceef --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from273to288.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 273 - 288 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = Effect.fn(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from416to444.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from416to444.output new file mode 100644 index 00000000..ceba814e --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from416to444.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 416 - 444 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = Effect.fn(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from580to609.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from580to609.output new file mode 100644 index 00000000..5ced1885 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from580to609.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 580 - 609 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionDeclarationWithParams = Effect.fn(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from273to288.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from273to288.output new file mode 100644 index 00000000..fefb7f16 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from273to288.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 273 - 288 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = Effect.fn("arrowWithParams")(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from416to444.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from416to444.output new file mode 100644 index 00000000..0682a2f1 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from416to444.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 416 - 444 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = Effect.fn("functionExpressionWithParams")(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from580to609.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from580to609.output new file mode 100644 index 00000000..7b7314db --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from580to609.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 580 - 609 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionDeclarationWithParams = Effect.fn("functionDeclarationWithParams")(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from273to288.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from273to288.output new file mode 100644 index 00000000..1fb58432 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from273to288.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 273 - 288 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = Effect.fnUntraced(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from416to444.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from416to444.output new file mode 100644 index 00000000..1f73260a --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from416to444.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 416 - 444 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = Effect.fnUntraced(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from580to609.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from580to609.output new file mode 100644 index 00000000..bf6ff4ad --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from580to609.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 580 - 609 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionDeclarationWithParams = Effect.fnUntraced(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.codefixes b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.codefixes index 44317d76..e26595f6 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.codefixes +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.codefixes @@ -1,15 +1,15 @@ -effectFnOpportunity_toEffectFnWithSpan from 916 to 943 -effectFnOpportunity_toEffectFnUntraced from 916 to 943 -effectFnOpportunity_toEffectFnNoSpan from 916 to 943 -effectFnOpportunity_skipNextLine from 916 to 943 -effectFnOpportunity_skipFile from 916 to 943 -effectFnOpportunity_toEffectFnWithSpan from 557 to 570 -effectFnOpportunity_toEffectFnUntraced from 557 to 570 -effectFnOpportunity_toEffectFnNoSpan from 557 to 570 -effectFnOpportunity_skipNextLine from 557 to 570 -effectFnOpportunity_skipFile from 557 to 570 -effectFnOpportunity_toEffectFnWithSpan from 701 to 727 -effectFnOpportunity_toEffectFnUntraced from 701 to 727 -effectFnOpportunity_toEffectFnNoSpan from 701 to 727 -effectFnOpportunity_skipNextLine from 701 to 727 -effectFnOpportunity_skipFile from 701 to 727 \ No newline at end of file +effectFnOpportunity_toEffectFnWithSpan from 934 to 961 +effectFnOpportunity_toEffectFnUntraced from 934 to 961 +effectFnOpportunity_toEffectFnNoSpan from 934 to 961 +effectFnOpportunity_skipNextLine from 934 to 961 +effectFnOpportunity_skipFile from 934 to 961 +effectFnOpportunity_toEffectFnWithSpan from 575 to 588 +effectFnOpportunity_toEffectFnUntraced from 575 to 588 +effectFnOpportunity_toEffectFnNoSpan from 575 to 588 +effectFnOpportunity_skipNextLine from 575 to 588 +effectFnOpportunity_skipFile from 575 to 588 +effectFnOpportunity_toEffectFnWithSpan from 719 to 745 +effectFnOpportunity_toEffectFnUntraced from 719 to 745 +effectFnOpportunity_toEffectFnNoSpan from 719 to 745 +effectFnOpportunity_skipNextLine from 719 to 745 +effectFnOpportunity_skipFile from 719 to 745 \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from575to588.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from575to588.output new file mode 100644 index 00000000..4506fbbb --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from575to588.output @@ -0,0 +1,27 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 575 - 588 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignoreLogged, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from719to745.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from719to745.output new file mode 100644 index 00000000..ea45c6b5 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from719to745.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 719 - 745 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignoreLogged, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from934to961.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from934to961.output new file mode 100644 index 00000000..61fb84a7 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from934to961.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 934 - 961 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export const functionDeclarationWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.ignoreLogged, Effect.withSpan("functionDeclarationWithPipe")) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from575to588.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from575to588.output new file mode 100644 index 00000000..b69b1b55 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from575to588.output @@ -0,0 +1,27 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 575 - 588 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignoreLogged, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from719to745.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from719to745.output new file mode 100644 index 00000000..6790339d --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from719to745.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 719 - 745 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignoreLogged, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from934to961.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from934to961.output new file mode 100644 index 00000000..fcd5f54e --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from934to961.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 934 - 961 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export const functionDeclarationWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.ignoreLogged, Effect.withSpan("functionDeclarationWithPipe")) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from575to588.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from575to588.output new file mode 100644 index 00000000..083fbcc8 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from575to588.output @@ -0,0 +1,27 @@ +// code fix effectFnOpportunity_toEffectFnWithSpan output for range 575 - 588 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = Effect.fn("arrowWithPipe")(function*() { + return yield* Effect.succeed(42) +}) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignoreLogged, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from719to745.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from719to745.output new file mode 100644 index 00000000..4d25a45e --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from719to745.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnWithSpan output for range 719 - 745 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = Effect.fn("functionExpressionWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1)) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignoreLogged, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from934to961.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from934to961.output new file mode 100644 index 00000000..3358bb19 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from934to961.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnWithSpan output for range 934 - 961 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export const functionDeclarationWithPipe = Effect.fn("functionDeclarationWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.ignoreLogged) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.codefixes b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.codefixes index 7588443e..170bc13b 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.codefixes +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.codefixes @@ -1,12 +1,12 @@ -effectFnOpportunity_toEffectFnNoSpan from 757 to 785 -effectFnOpportunity_toEffectFnSpanInferred from 757 to 785 -effectFnOpportunity_skipNextLine from 757 to 785 -effectFnOpportunity_skipFile from 757 to 785 -effectFnOpportunity_toEffectFnNoSpan from 366 to 380 -effectFnOpportunity_toEffectFnSpanInferred from 366 to 380 -effectFnOpportunity_skipNextLine from 366 to 380 -effectFnOpportunity_skipFile from 366 to 380 -effectFnOpportunity_toEffectFnNoSpan from 520 to 547 -effectFnOpportunity_toEffectFnSpanInferred from 520 to 547 -effectFnOpportunity_skipNextLine from 520 to 547 -effectFnOpportunity_skipFile from 520 to 547 \ No newline at end of file +effectFnOpportunity_toEffectFnNoSpan from 775 to 803 +effectFnOpportunity_toEffectFnSpanInferred from 775 to 803 +effectFnOpportunity_skipNextLine from 775 to 803 +effectFnOpportunity_skipFile from 775 to 803 +effectFnOpportunity_toEffectFnNoSpan from 384 to 398 +effectFnOpportunity_toEffectFnSpanInferred from 384 to 398 +effectFnOpportunity_skipNextLine from 384 to 398 +effectFnOpportunity_skipFile from 384 to 398 +effectFnOpportunity_toEffectFnNoSpan from 538 to 565 +effectFnOpportunity_toEffectFnSpanInferred from 538 to 565 +effectFnOpportunity_skipNextLine from 538 to 565 +effectFnOpportunity_skipFile from 538 to 565 \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from384to398.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from384to398.output new file mode 100644 index 00000000..3c0e1fa8 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from384to398.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 384 - 398 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = Effect.fn(function() { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +}) + +export const functionExpressionPlainMany = function(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} + +export function functionDeclarationPlainMany(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from538to565.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from538to565.output new file mode 100644 index 00000000..d01ae96d --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from538to565.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 538 - 565 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = () => { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +} + +export const functionExpressionPlainMany = Effect.fn(function (value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +}) + +export function functionDeclarationPlainMany(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from775to803.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from775to803.output new file mode 100644 index 00000000..c23622e0 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from775to803.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 775 - 803 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = () => { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +} + +export const functionExpressionPlainMany = function(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} + +export const functionDeclarationPlainMany = Effect.fn(function (value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from384to398.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from384to398.output new file mode 100644 index 00000000..6353afc0 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from384to398.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 384 - 398 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = Effect.fn("arrowPlainMany")(function() { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +}) + +export const functionExpressionPlainMany = function(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} + +export function functionDeclarationPlainMany(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from538to565.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from538to565.output new file mode 100644 index 00000000..569c11c5 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from538to565.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 538 - 565 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = () => { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +} + +export const functionExpressionPlainMany = Effect.fn("functionExpressionPlainMany")(function (value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +}) + +export function functionDeclarationPlainMany(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from775to803.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from775to803.output new file mode 100644 index 00000000..aaf799be --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from775to803.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 775 - 803 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = () => { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +} + +export const functionExpressionPlainMany = function(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} + +export const functionDeclarationPlainMany = Effect.fn("functionDeclarationPlainMany")(function (value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.output index e247843b..c63c718a 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.output +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.output @@ -1,8 +1,8 @@ arrowPlainMany -9:13 - 9:27 | 2 | Can be rewritten as a reusable function: Effect.fn(function*() { ... }) effect(effectFnOpportunity) +9:13 - 9:27 | 2 | Can be rewritten as a reusable function: Effect.fn(() => { ... }) effect(effectFnOpportunity) functionExpressionPlainMany -18:13 - 18:40 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) +18:13 - 18:40 | 2 | Can be rewritten as a reusable function: Effect.fn(function(value) { ... }) effect(effectFnOpportunity) functionDeclarationPlainMany -28:16 - 28:44 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) \ No newline at end of file +28:16 - 28:44 | 2 | Can be rewritten as a reusable function: Effect.fn(function(value) { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.codefixes b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.codefixes index 30cbf627..049705de 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.codefixes +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.codefixes @@ -1,27 +1,27 @@ -effectFnOpportunity_toEffectFnUntraced from 557 to 590 -effectFnOpportunity_toEffectFnNoSpan from 557 to 590 -effectFnOpportunity_toEffectFnSpanInferred from 557 to 590 -effectFnOpportunity_skipNextLine from 557 to 590 -effectFnOpportunity_skipFile from 557 to 590 -effectFnOpportunity_toEffectFnNoSpan from 1200 to 1238 -effectFnOpportunity_toEffectFnSpanInferred from 1200 to 1238 -effectFnOpportunity_skipNextLine from 1200 to 1238 -effectFnOpportunity_skipFile from 1200 to 1238 -effectFnOpportunity_toEffectFnUntraced from 264 to 283 -effectFnOpportunity_toEffectFnNoSpan from 264 to 283 -effectFnOpportunity_toEffectFnSpanInferred from 264 to 283 -effectFnOpportunity_skipNextLine from 264 to 283 -effectFnOpportunity_skipFile from 264 to 283 -effectFnOpportunity_toEffectFnUntraced from 400 to 432 -effectFnOpportunity_toEffectFnNoSpan from 400 to 432 -effectFnOpportunity_toEffectFnSpanInferred from 400 to 432 -effectFnOpportunity_skipNextLine from 400 to 432 -effectFnOpportunity_skipFile from 400 to 432 -effectFnOpportunity_toEffectFnNoSpan from 843 to 867 -effectFnOpportunity_toEffectFnSpanInferred from 843 to 867 -effectFnOpportunity_skipNextLine from 843 to 867 -effectFnOpportunity_skipFile from 843 to 867 -effectFnOpportunity_toEffectFnNoSpan from 1011 to 1048 -effectFnOpportunity_toEffectFnSpanInferred from 1011 to 1048 -effectFnOpportunity_skipNextLine from 1011 to 1048 -effectFnOpportunity_skipFile from 1011 to 1048 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 575 to 608 +effectFnOpportunity_toEffectFnNoSpan from 575 to 608 +effectFnOpportunity_toEffectFnSpanInferred from 575 to 608 +effectFnOpportunity_skipNextLine from 575 to 608 +effectFnOpportunity_skipFile from 575 to 608 +effectFnOpportunity_toEffectFnNoSpan from 1218 to 1256 +effectFnOpportunity_toEffectFnSpanInferred from 1218 to 1256 +effectFnOpportunity_skipNextLine from 1218 to 1256 +effectFnOpportunity_skipFile from 1218 to 1256 +effectFnOpportunity_toEffectFnUntraced from 282 to 301 +effectFnOpportunity_toEffectFnNoSpan from 282 to 301 +effectFnOpportunity_toEffectFnSpanInferred from 282 to 301 +effectFnOpportunity_skipNextLine from 282 to 301 +effectFnOpportunity_skipFile from 282 to 301 +effectFnOpportunity_toEffectFnUntraced from 418 to 450 +effectFnOpportunity_toEffectFnNoSpan from 418 to 450 +effectFnOpportunity_toEffectFnSpanInferred from 418 to 450 +effectFnOpportunity_skipNextLine from 418 to 450 +effectFnOpportunity_skipFile from 418 to 450 +effectFnOpportunity_toEffectFnNoSpan from 861 to 885 +effectFnOpportunity_toEffectFnSpanInferred from 861 to 885 +effectFnOpportunity_skipNextLine from 861 to 885 +effectFnOpportunity_skipFile from 861 to 885 +effectFnOpportunity_toEffectFnNoSpan from 1029 to 1066 +effectFnOpportunity_toEffectFnSpanInferred from 1029 to 1066 +effectFnOpportunity_skipNextLine from 1029 to 1066 +effectFnOpportunity_skipFile from 1029 to 1066 \ No newline at end of file diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1029to1066.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1029to1066.output new file mode 100644 index 00000000..407311fd --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1029to1066.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 1029 - 1066 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = Effect.fn(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1218to1256.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1218to1256.output new file mode 100644 index 00000000..11b166ec --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1218to1256.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 1218 - 1256 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionDeclarationWithTypeParamsNoGen = Effect.fn(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from282to301.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from282to301.output new file mode 100644 index 00000000..c2a2c865 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from282to301.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 282 - 301 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = Effect.fn(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from418to450.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from418to450.output new file mode 100644 index 00000000..8385cb4c --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from418to450.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 418 - 450 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = Effect.fn(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from575to608.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from575to608.output new file mode 100644 index 00000000..7bb517a8 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from575to608.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 575 - 608 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionDeclarationWithTypeParams = Effect.fn(function* (value: T) { + return yield* Effect.succeed(value) +}) + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from861to885.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from861to885.output new file mode 100644 index 00000000..ec1f8a63 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from861to885.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 861 - 885 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = Effect.fn(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1029to1066.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1029to1066.output new file mode 100644 index 00000000..accb5deb --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1029to1066.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1029 - 1066 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = Effect.fn("functionExpressionWithTypeParamsNoGen")(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1218to1256.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1218to1256.output new file mode 100644 index 00000000..0fc2779c --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1218to1256.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1218 - 1256 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionDeclarationWithTypeParamsNoGen = Effect.fn("functionDeclarationWithTypeParamsNoGen")(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from282to301.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from282to301.output new file mode 100644 index 00000000..0bbe1260 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from282to301.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 282 - 301 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = Effect.fn("arrowWithTypeParams")(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from418to450.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from418to450.output new file mode 100644 index 00000000..1ed21c6d --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from418to450.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 418 - 450 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = Effect.fn("functionExpressionWithTypeParams")(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from575to608.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from575to608.output new file mode 100644 index 00000000..2adbdcde --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from575to608.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 575 - 608 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionDeclarationWithTypeParams = Effect.fn("functionDeclarationWithTypeParams")(function* (value: T) { + return yield* Effect.succeed(value) +}) + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from861to885.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from861to885.output new file mode 100644 index 00000000..97ceb260 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from861to885.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 861 - 885 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = Effect.fn("arrowWithTypeParamsNoGen")(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from282to301.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from282to301.output new file mode 100644 index 00000000..958145c3 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from282to301.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 282 - 301 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = Effect.fnUntraced(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from418to450.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from418to450.output new file mode 100644 index 00000000..c79b10a7 --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from418to450.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 418 - 450 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = Effect.fnUntraced(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from575to608.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from575to608.output new file mode 100644 index 00000000..a16dc79f --- /dev/null +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from575to608.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 575 - 608 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionDeclarationWithTypeParams = Effect.fnUntraced(function* (value: T) { + return yield* Effect.succeed(value) +}) + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.output b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.output index beb9d15c..afe66b6e 100644 --- a/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.output +++ b/packages/harness-effect-v3/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.output @@ -8,10 +8,10 @@ functionDeclarationWithTypeParams 19:16 - 19:49 | 2 | Can be rewritten as a reusable function: Effect.fnUntraced(function*(value) { ... }) effect(effectFnOpportunity) arrowWithTypeParamsNoGen -28:13 - 28:37 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) +28:13 - 28:37 | 2 | Can be rewritten as a reusable function: Effect.fn((value) => { ... }) effect(effectFnOpportunity) functionExpressionWithTypeParamsNoGen -37:13 - 37:50 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) +37:13 - 37:50 | 2 | Can be rewritten as a reusable function: Effect.fn(function(value) { ... }) effect(effectFnOpportunity) functionDeclarationWithTypeParamsNoGen -46:16 - 46:54 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) \ No newline at end of file +46:16 - 46:54 | 2 | Can be rewritten as a reusable function: Effect.fn(function(value) { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_alreadyEffectFn.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_alreadyEffectFn.ts index 5c109df2..730094c1 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_alreadyEffectFn.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_alreadyEffectFn.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" export const alreadyEffectFnWithName = Effect.fn("alreadyEffectFnWithName")(function*() { diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_basic.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_basic.ts index 0b079621..831b2420 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_basic.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_basic.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // These cases can be converted to Effect.fnUntraced because: diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_genWithThis.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_genWithThis.ts index d7054837..6138c96f 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_genWithThis.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_genWithThis.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should NOT trigger for these cases because Effect.gen is diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_inferred.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_inferred.ts new file mode 100644 index 00000000..9da9c74f --- /dev/null +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_inferred.ts @@ -0,0 +1,27 @@ +// @test-config { "effectFn": ["inferred-span"] } +import * as Effect from "effect/Effect" + + +const _notExporedNoSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const shouldHaveSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + } + + +export function shouldHaveSuggestioFunction() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + } + + diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_inferredLayer.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_inferredLayer.ts new file mode 100644 index 00000000..2fe95815 --- /dev/null +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_inferredLayer.ts @@ -0,0 +1,31 @@ +// @test-config { "effectFn": ["inferred-span"] } +import * as Context from "effect/Context" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" + +class MyService extends Context.Tag("MyService") Effect.Effect +} +>(){} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_invalid.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_invalid.ts index b367d32c..74e8270b 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_invalid.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_invalid.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } // Generator functions export const generatorExpression = function*() { diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_multipleReturns.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_multipleReturns.ts index dfafbf04..e87e288c 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_multipleReturns.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_multipleReturns.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // These should not trigger because they are not returning just Effect.gen, diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_noPipeWithSpan.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_noPipeWithSpan.ts index 3857784b..e04bdf12 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_noPipeWithSpan.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_noPipeWithSpan.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // This case differs from pipeWithSpan because the withSpan is not the last diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_overloadsNever.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_overloadsNever.ts index 76eb2a72..469c0e49 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_overloadsNever.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_overloadsNever.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic will never trigger for function declarations with overload diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_overloadsOk.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_overloadsOk.ts index 1948e620..9f557219 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_overloadsOk.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_overloadsOk.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should trigger for these cases. When assigning to a const diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_params.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_params.ts index 75d2f72d..dec881d5 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_params.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_params.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // These cases are okay and should trigger the diagnostic. diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_paramsInPipe.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_paramsInPipe.ts index 80961fe9..355583a5 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_paramsInPipe.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_paramsInPipe.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should NOT trigger for these cases because the function diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_pipeWithSpan.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_pipeWithSpan.ts index 5d3d43ed..0eb630ed 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_pipeWithSpan.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_pipeWithSpan.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // For these cases we should suggest using Effect.fn (not Effect.fnUntraced) diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_plainFew.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_plainFew.ts index d45b2d10..c7d29f3d 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_plainFew.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_plainFew.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // For these cases we could only convert to Effect.fn (not Effect.fnUntraced diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_plainMany.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_plainMany.ts index 7e257b82..39554acb 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_plainMany.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_plainMany.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // There should be two code fixes offered: diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_returnType.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_returnType.ts index 5c47ccee..6ee1371e 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_returnType.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_returnType.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should never trigger on these cases because there is diff --git a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_typeParams.ts b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_typeParams.ts index 2c114afc..14a65ca0 100644 --- a/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_typeParams.ts +++ b/packages/harness-effect-v3/examples/diagnostics/effectFnOpportunity_typeParams.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should trigger for these cases. We should check that diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.codefixes index dedb7404..08c81e25 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.codefixes @@ -1,20 +1,20 @@ -effectFnOpportunity_toEffectFnUntraced from 762 to 784 -effectFnOpportunity_toEffectFnNoSpan from 762 to 784 -effectFnOpportunity_toEffectFnSpanInferred from 762 to 784 -effectFnOpportunity_skipNextLine from 762 to 784 -effectFnOpportunity_skipFile from 762 to 784 -effectFnOpportunity_toEffectFnUntraced from 386 to 399 -effectFnOpportunity_toEffectFnNoSpan from 386 to 399 -effectFnOpportunity_toEffectFnSpanInferred from 386 to 399 -effectFnOpportunity_skipNextLine from 386 to 399 -effectFnOpportunity_skipFile from 386 to 399 -effectFnOpportunity_toEffectFnUntraced from 508 to 526 -effectFnOpportunity_toEffectFnNoSpan from 508 to 526 -effectFnOpportunity_toEffectFnSpanInferred from 508 to 526 -effectFnOpportunity_skipNextLine from 508 to 526 -effectFnOpportunity_skipFile from 508 to 526 -effectFnOpportunity_toEffectFnUntraced from 624 to 645 -effectFnOpportunity_toEffectFnNoSpan from 624 to 645 -effectFnOpportunity_toEffectFnSpanInferred from 624 to 645 -effectFnOpportunity_skipNextLine from 624 to 645 -effectFnOpportunity_skipFile from 624 to 645 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 780 to 802 +effectFnOpportunity_toEffectFnNoSpan from 780 to 802 +effectFnOpportunity_toEffectFnSpanInferred from 780 to 802 +effectFnOpportunity_skipNextLine from 780 to 802 +effectFnOpportunity_skipFile from 780 to 802 +effectFnOpportunity_toEffectFnUntraced from 404 to 417 +effectFnOpportunity_toEffectFnNoSpan from 404 to 417 +effectFnOpportunity_toEffectFnSpanInferred from 404 to 417 +effectFnOpportunity_skipNextLine from 404 to 417 +effectFnOpportunity_skipFile from 404 to 417 +effectFnOpportunity_toEffectFnUntraced from 526 to 544 +effectFnOpportunity_toEffectFnNoSpan from 526 to 544 +effectFnOpportunity_toEffectFnSpanInferred from 526 to 544 +effectFnOpportunity_skipNextLine from 526 to 544 +effectFnOpportunity_skipFile from 526 to 544 +effectFnOpportunity_toEffectFnUntraced from 642 to 663 +effectFnOpportunity_toEffectFnNoSpan from 642 to 663 +effectFnOpportunity_toEffectFnSpanInferred from 642 to 663 +effectFnOpportunity_skipNextLine from 642 to 663 +effectFnOpportunity_skipFile from 642 to 663 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from404to417.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from404to417.output new file mode 100644 index 00000000..aaef22e1 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from404to417.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 404 - 417 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = Effect.fn(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from526to544.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from526to544.output new file mode 100644 index 00000000..5b2c6348 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from526to544.output @@ -0,0 +1,35 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 526 - 544 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = Effect.fn(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from642to663.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from642to663.output new file mode 100644 index 00000000..78f518a3 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from642to663.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 642 - 663 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = Effect.fn(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from780to802.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from780to802.output new file mode 100644 index 00000000..473261eb --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnNoSpan.from780to802.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 780 - 802 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const functionDeclarationGen = Effect.fn(function*() { + yield* Effect.succeed(1) + return 42 +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from404to417.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from404to417.output new file mode 100644 index 00000000..0eee93c8 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from404to417.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 404 - 417 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = Effect.fn("arrowBlockGen")(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from526to544.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from526to544.output new file mode 100644 index 00000000..3e1a55a0 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from526to544.output @@ -0,0 +1,35 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 526 - 544 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = Effect.fn("arrowExpressionGen")(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from642to663.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from642to663.output new file mode 100644 index 00000000..7e40191d --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from642to663.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 642 - 663 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = Effect.fn("functionExpressionGen")(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from780to802.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from780to802.output new file mode 100644 index 00000000..4b9dab9a --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnSpanInferred.from780to802.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 780 - 802 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const functionDeclarationGen = Effect.fn("functionDeclarationGen")(function*() { + yield* Effect.succeed(1) + return 42 +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from404to417.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from404to417.output new file mode 100644 index 00000000..86e6376d --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from404to417.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 404 - 417 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = Effect.fnUntraced(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from526to544.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from526to544.output new file mode 100644 index 00000000..f050fe68 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from526to544.output @@ -0,0 +1,35 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 526 - 544 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = Effect.fnUntraced(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from642to663.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from642to663.output new file mode 100644 index 00000000..76774130 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from642to663.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 642 - 663 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = Effect.fnUntraced(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export function functionDeclarationGen() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from780to802.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from780to802.output new file mode 100644 index 00000000..19a42544 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_basic.ts.effectFnOpportunity_toEffectFnUntraced.from780to802.output @@ -0,0 +1,34 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 780 - 802 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases can be converted to Effect.fnUntraced because: +// - There are no pipe arguments +// - There is no withSpan for tracing +// Converting to Effect.fnUntraced improves performance by not +// reallocating the generator function on every call. + +export const arrowBlockGen = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const arrowExpressionGen = () => + Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) + +export const functionExpressionGen = function() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const functionDeclarationGen = Effect.fnUntraced(function*() { + yield* Effect.succeed(1) + return 42 +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.codefixes new file mode 100644 index 00000000..bc9e1c00 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.codefixes @@ -0,0 +1,6 @@ +effectFnOpportunity_toEffectFnSpanInferred from 361 to 388 +effectFnOpportunity_skipNextLine from 361 to 388 +effectFnOpportunity_skipFile from 361 to 388 +effectFnOpportunity_toEffectFnSpanInferred from 229 to 249 +effectFnOpportunity_skipNextLine from 229 to 249 +effectFnOpportunity_skipFile from 229 to 249 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from229to249.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from229to249.output new file mode 100644 index 00000000..c23a669d --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from229to249.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 229 - 249 +// @test-config { "effectFn": ["inferred-span"] } +import * as Effect from "effect/Effect" + +const _notExporedNoSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const shouldHaveSuggestion = Effect.fn("shouldHaveSuggestion")(function*() { + yield* Effect.succeed(1) + return 42 +}) + +export function shouldHaveSuggestioFunction() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from361to388.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from361to388.output new file mode 100644 index 00000000..f28972fc --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.effectFnOpportunity_toEffectFnSpanInferred.from361to388.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 361 - 388 +// @test-config { "effectFn": ["inferred-span"] } +import * as Effect from "effect/Effect" + +const _notExporedNoSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const shouldHaveSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const shouldHaveSuggestioFunction = Effect.fn("shouldHaveSuggestioFunction")(function*() { + yield* Effect.succeed(1) + return 42 +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.output new file mode 100644 index 00000000..e90e6cd9 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferred.ts.output @@ -0,0 +1,5 @@ +shouldHaveSuggestion +11:13 - 11:33 | 2 | Can be rewritten as a reusable function: Effect.fn("shouldHaveSuggestion")(function*() { ... }) effect(effectFnOpportunity) + +shouldHaveSuggestioFunction +18:16 - 18:43 | 2 | Can be rewritten as a reusable function: Effect.fn("shouldHaveSuggestioFunction")(function*() { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes new file mode 100644 index 00000000..ea09c356 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes @@ -0,0 +1,12 @@ +effectFnOpportunity_toEffectFnSpanInferred from 766 to 769 +effectFnOpportunity_skipNextLine from 766 to 769 +effectFnOpportunity_skipFile from 766 to 769 +effectFnOpportunity_toEffectFnSpanInferred from 930 to 933 +effectFnOpportunity_skipNextLine from 930 to 933 +effectFnOpportunity_skipFile from 930 to 933 +effectFnOpportunity_toEffectFnSpanInferred from 388 to 391 +effectFnOpportunity_skipNextLine from 388 to 391 +effectFnOpportunity_skipFile from 388 to 391 +effectFnOpportunity_toEffectFnSpanInferred from 608 to 611 +effectFnOpportunity_skipNextLine from 608 to 611 +effectFnOpportunity_skipFile from 608 to 611 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from388to391.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from388to391.output new file mode 100644 index 00000000..667b0661 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from388to391.output @@ -0,0 +1,31 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 388 - 391 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, ServiceMap } from "effect" + +class MyService extends ServiceMap.Service Effect.Effect +}>()("MyService") {} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from608to611.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from608to611.output new file mode 100644 index 00000000..0df0cec7 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from608to611.output @@ -0,0 +1,31 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 608 - 611 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, ServiceMap } from "effect" + +class MyService extends ServiceMap.Service Effect.Effect +}>()("MyService") {} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from766to769.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from766to769.output new file mode 100644 index 00000000..eef9802f --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from766to769.output @@ -0,0 +1,31 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 766 - 769 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, ServiceMap } from "effect" + +class MyService extends ServiceMap.Service Effect.Effect +}>()("MyService") {} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from930to933.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from930to933.output new file mode 100644 index 00000000..efa75582 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from930to933.output @@ -0,0 +1,31 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 930 - 933 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, ServiceMap } from "effect" + +class MyService extends ServiceMap.Service Effect.Effect +}>()("MyService") {} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.output new file mode 100644 index 00000000..b868a6f6 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.output @@ -0,0 +1,11 @@ +log +11:11 - 11:14 | 2 | Can be rewritten as a reusable function: Effect.fn("MyService.log")((what) => { ... }) effect(effectFnOpportunity) + +log +17:11 - 17:14 | 2 | Can be rewritten as a reusable function: Effect.fn("MyService.log")((what) => { ... }) effect(effectFnOpportunity) + +log +22:2 - 22:5 | 2 | Can be rewritten as a reusable function: Effect.fn("MyService.log")((what) => { ... }) effect(effectFnOpportunity) + +log +27:11 - 27:14 | 2 | Can be rewritten as a reusable function: Effect.fn("MyService.log")((what) => { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.codefixes index a4092406..39366c3d 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.codefixes @@ -1,15 +1,15 @@ -effectFnOpportunity_toEffectFnUntraced from 689 to 716 -effectFnOpportunity_toEffectFnNoSpan from 689 to 716 -effectFnOpportunity_toEffectFnSpanInferred from 689 to 716 -effectFnOpportunity_skipNextLine from 689 to 716 -effectFnOpportunity_skipFile from 689 to 716 -effectFnOpportunity_toEffectFnUntraced from 360 to 373 -effectFnOpportunity_toEffectFnNoSpan from 360 to 373 -effectFnOpportunity_toEffectFnSpanInferred from 360 to 373 -effectFnOpportunity_skipNextLine from 360 to 373 -effectFnOpportunity_skipFile from 360 to 373 -effectFnOpportunity_toEffectFnUntraced from 485 to 511 -effectFnOpportunity_toEffectFnNoSpan from 485 to 511 -effectFnOpportunity_toEffectFnSpanInferred from 485 to 511 -effectFnOpportunity_skipNextLine from 485 to 511 -effectFnOpportunity_skipFile from 485 to 511 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 707 to 734 +effectFnOpportunity_toEffectFnNoSpan from 707 to 734 +effectFnOpportunity_toEffectFnSpanInferred from 707 to 734 +effectFnOpportunity_skipNextLine from 707 to 734 +effectFnOpportunity_skipFile from 707 to 734 +effectFnOpportunity_toEffectFnUntraced from 378 to 391 +effectFnOpportunity_toEffectFnNoSpan from 378 to 391 +effectFnOpportunity_toEffectFnSpanInferred from 378 to 391 +effectFnOpportunity_skipNextLine from 378 to 391 +effectFnOpportunity_skipFile from 378 to 391 +effectFnOpportunity_toEffectFnUntraced from 503 to 529 +effectFnOpportunity_toEffectFnNoSpan from 503 to 529 +effectFnOpportunity_toEffectFnSpanInferred from 503 to 529 +effectFnOpportunity_skipNextLine from 503 to 529 +effectFnOpportunity_skipFile from 503 to 529 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from378to391.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from378to391.output new file mode 100644 index 00000000..76e5c57b --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from378to391.output @@ -0,0 +1,23 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 378 - 391 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.ignore) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignore) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignore) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from503to529.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from503to529.output new file mode 100644 index 00000000..1c9d01b1 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from503to529.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 503 - 529 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignore) + +export const functionExpressionWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("functionExpressionWithPipe"), Effect.ignore) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignore) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from707to734.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from707to734.output new file mode 100644 index 00000000..baef2f73 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from707to734.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 707 - 734 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignore) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignore) +} + +export const functionDeclarationWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignore) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from378to391.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from378to391.output new file mode 100644 index 00000000..d78c8a83 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from378to391.output @@ -0,0 +1,23 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 378 - 391 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = Effect.fn("arrowWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.ignore) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignore) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignore) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from503to529.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from503to529.output new file mode 100644 index 00000000..eb1b8ba1 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from503to529.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 503 - 529 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignore) + +export const functionExpressionWithPipe = Effect.fn("functionExpressionWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("functionExpressionWithPipe"), Effect.ignore) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignore) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from707to734.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from707to734.output new file mode 100644 index 00000000..9f99b371 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnSpanInferred.from707to734.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 707 - 734 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignore) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignore) +} + +export const functionDeclarationWithPipe = Effect.fn("functionDeclarationWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignore) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from378to391.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from378to391.output new file mode 100644 index 00000000..b28d874c --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from378to391.output @@ -0,0 +1,23 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 378 - 391 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.ignore) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignore) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignore) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from503to529.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from503to529.output new file mode 100644 index 00000000..c6224681 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from503to529.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 503 - 529 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignore) + +export const functionExpressionWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("functionExpressionWithPipe"), Effect.ignore) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignore) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from707to734.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from707to734.output new file mode 100644 index 00000000..1c91da03 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_noPipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from707to734.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 707 - 734 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// This case differs from pipeWithSpan because the withSpan is not the last +// piped transformation, so we cannot extract the span name to use with +// Effect.fn. Instead, we should suggest Effect.fnUntraced for these cases. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.ignore) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("functionExpressionWithPipe"), Effect.ignore) +} + +export const functionDeclarationWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionDeclarationWithPipe"), Effect.ignore) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.codefixes index d4e16b62..3f26b532 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.codefixes @@ -1,18 +1,18 @@ -effectFnOpportunity_toEffectFnUntraced from 449 to 464 -effectFnOpportunity_toEffectFnNoSpan from 449 to 464 -effectFnOpportunity_toEffectFnSpanInferred from 449 to 464 -effectFnOpportunity_skipNextLine from 449 to 464 -effectFnOpportunity_skipFile from 449 to 464 -effectFnOpportunity_toEffectFnUntraced from 725 to 753 -effectFnOpportunity_toEffectFnNoSpan from 725 to 753 -effectFnOpportunity_toEffectFnSpanInferred from 725 to 753 -effectFnOpportunity_skipNextLine from 725 to 753 -effectFnOpportunity_skipFile from 725 to 753 -effectFnOpportunity_toEffectFnNoSpan from 1024 to 1044 -effectFnOpportunity_toEffectFnSpanInferred from 1024 to 1044 -effectFnOpportunity_skipNextLine from 1024 to 1044 -effectFnOpportunity_skipFile from 1024 to 1044 -effectFnOpportunity_toEffectFnNoSpan from 1342 to 1375 -effectFnOpportunity_toEffectFnSpanInferred from 1342 to 1375 -effectFnOpportunity_skipNextLine from 1342 to 1375 -effectFnOpportunity_skipFile from 1342 to 1375 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 467 to 482 +effectFnOpportunity_toEffectFnNoSpan from 467 to 482 +effectFnOpportunity_toEffectFnSpanInferred from 467 to 482 +effectFnOpportunity_skipNextLine from 467 to 482 +effectFnOpportunity_skipFile from 467 to 482 +effectFnOpportunity_toEffectFnUntraced from 743 to 771 +effectFnOpportunity_toEffectFnNoSpan from 743 to 771 +effectFnOpportunity_toEffectFnSpanInferred from 743 to 771 +effectFnOpportunity_skipNextLine from 743 to 771 +effectFnOpportunity_skipFile from 743 to 771 +effectFnOpportunity_toEffectFnNoSpan from 1042 to 1062 +effectFnOpportunity_toEffectFnSpanInferred from 1042 to 1062 +effectFnOpportunity_skipNextLine from 1042 to 1062 +effectFnOpportunity_skipFile from 1042 to 1062 +effectFnOpportunity_toEffectFnNoSpan from 1360 to 1393 +effectFnOpportunity_toEffectFnSpanInferred from 1360 to 1393 +effectFnOpportunity_skipNextLine from 1360 to 1393 +effectFnOpportunity_skipFile from 1360 to 1393 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1042to1062.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1042to1062.output new file mode 100644 index 00000000..f1818620 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1042to1062.output @@ -0,0 +1,53 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 1042 - 1062 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = Effect.fn(function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1360to1393.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1360to1393.output new file mode 100644 index 00000000..9460b667 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from1360to1393.output @@ -0,0 +1,53 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 1360 - 1393 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = Effect.fn(function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from467to482.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from467to482.output new file mode 100644 index 00000000..56a3cbab --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from467to482.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 467 - 482 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = Effect.fn(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from743to771.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from743to771.output new file mode 100644 index 00000000..1e7f50ea --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnNoSpan.from743to771.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 743 - 771 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = Effect.fn(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1042to1062.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1042to1062.output new file mode 100644 index 00000000..3b093605 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1042to1062.output @@ -0,0 +1,53 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1042 - 1062 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = Effect.fn("overloadedArrowNoGen")(function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1360to1393.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1360to1393.output new file mode 100644 index 00000000..b6630fd8 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from1360to1393.output @@ -0,0 +1,53 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1360 - 1393 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = Effect.fn("overloadedFunctionExpressionNoGen")(function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from467to482.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from467to482.output new file mode 100644 index 00000000..6a3a2e93 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from467to482.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 467 - 482 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = Effect.fn("overloadedArrow")(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from743to771.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from743to771.output new file mode 100644 index 00000000..21cc0003 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnSpanInferred.from743to771.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 743 - 771 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = Effect.fn("overloadedFunctionExpression")(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from467to482.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from467to482.output new file mode 100644 index 00000000..6a912d92 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from467to482.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 467 - 482 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = Effect.fnUntraced(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = function(a: number | string) { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from743to771.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from743to771.output new file mode 100644 index 00000000..9575b71b --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.effectFnOpportunity_toEffectFnUntraced.from743to771.output @@ -0,0 +1,51 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 743 - 771 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. When assigning to a const +// with an overloaded interface type, the overload signature is preserved +// by the interface, so it's safe to convert to Effect.fn. + +interface OverloadedArrow { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrow: OverloadedArrow = (a: number | string) => { + return Effect.gen(function*() { + return yield* Effect.succeed(a as any) + }) +} + +interface OverloadedFunctionExpression { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpression: OverloadedFunctionExpression = Effect.fnUntraced(function*(a: number | string) { + return yield* Effect.succeed(a as any) +}) + +interface OverloadedArrowNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedArrowNoGen: OverloadedArrowNoGen = (a: number | string) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} + +interface OverloadedFunctionExpressionNoGen { + (a: number): Effect.Effect + (a: string): Effect.Effect +} +export const overloadedFunctionExpressionNoGen: OverloadedFunctionExpressionNoGen = function(a: number | string) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(a as any) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.output index 514508ff..5fac11d3 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_overloadsOk.ts.output @@ -5,7 +5,7 @@ overloadedFunctionExpression 22:13 - 22:41 | 2 | Can be rewritten as a reusable function: Effect.fnUntraced(function*(a) { ... }) effect(effectFnOpportunity) overloadedArrowNoGen -32:13 - 32:33 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(a) { ... }) effect(effectFnOpportunity) +32:13 - 32:33 | 2 | Can be rewritten as a reusable function: Effect.fn((a) => { ... }) effect(effectFnOpportunity) overloadedFunctionExpressionNoGen -45:13 - 45:46 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(a) { ... }) effect(effectFnOpportunity) \ No newline at end of file +45:13 - 45:46 | 2 | Can be rewritten as a reusable function: Effect.fn(function(a) { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.codefixes index 80aae1f7..4dcca218 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.codefixes @@ -1,15 +1,15 @@ -effectFnOpportunity_toEffectFnUntraced from 562 to 591 -effectFnOpportunity_toEffectFnNoSpan from 562 to 591 -effectFnOpportunity_toEffectFnSpanInferred from 562 to 591 -effectFnOpportunity_skipNextLine from 562 to 591 -effectFnOpportunity_skipFile from 562 to 591 -effectFnOpportunity_toEffectFnUntraced from 255 to 270 -effectFnOpportunity_toEffectFnNoSpan from 255 to 270 -effectFnOpportunity_toEffectFnSpanInferred from 255 to 270 -effectFnOpportunity_skipNextLine from 255 to 270 -effectFnOpportunity_skipFile from 255 to 270 -effectFnOpportunity_toEffectFnUntraced from 398 to 426 -effectFnOpportunity_toEffectFnNoSpan from 398 to 426 -effectFnOpportunity_toEffectFnSpanInferred from 398 to 426 -effectFnOpportunity_skipNextLine from 398 to 426 -effectFnOpportunity_skipFile from 398 to 426 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 580 to 609 +effectFnOpportunity_toEffectFnNoSpan from 580 to 609 +effectFnOpportunity_toEffectFnSpanInferred from 580 to 609 +effectFnOpportunity_skipNextLine from 580 to 609 +effectFnOpportunity_skipFile from 580 to 609 +effectFnOpportunity_toEffectFnUntraced from 273 to 288 +effectFnOpportunity_toEffectFnNoSpan from 273 to 288 +effectFnOpportunity_toEffectFnSpanInferred from 273 to 288 +effectFnOpportunity_skipNextLine from 273 to 288 +effectFnOpportunity_skipFile from 273 to 288 +effectFnOpportunity_toEffectFnUntraced from 416 to 444 +effectFnOpportunity_toEffectFnNoSpan from 416 to 444 +effectFnOpportunity_toEffectFnSpanInferred from 416 to 444 +effectFnOpportunity_skipNextLine from 416 to 444 +effectFnOpportunity_skipFile from 416 to 444 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from273to288.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from273to288.output new file mode 100644 index 00000000..4204ceef --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from273to288.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 273 - 288 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = Effect.fn(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from416to444.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from416to444.output new file mode 100644 index 00000000..ceba814e --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from416to444.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 416 - 444 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = Effect.fn(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from580to609.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from580to609.output new file mode 100644 index 00000000..5ced1885 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnNoSpan.from580to609.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 580 - 609 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionDeclarationWithParams = Effect.fn(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from273to288.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from273to288.output new file mode 100644 index 00000000..fefb7f16 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from273to288.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 273 - 288 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = Effect.fn("arrowWithParams")(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from416to444.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from416to444.output new file mode 100644 index 00000000..0682a2f1 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from416to444.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 416 - 444 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = Effect.fn("functionExpressionWithParams")(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from580to609.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from580to609.output new file mode 100644 index 00000000..7b7314db --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnSpanInferred.from580to609.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 580 - 609 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionDeclarationWithParams = Effect.fn("functionDeclarationWithParams")(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from273to288.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from273to288.output new file mode 100644 index 00000000..1fb58432 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from273to288.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 273 - 288 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = Effect.fnUntraced(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from416to444.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from416to444.output new file mode 100644 index 00000000..1f73260a --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from416to444.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 416 - 444 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = Effect.fnUntraced(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) + +export function functionDeclarationWithParams(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from580to609.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from580to609.output new file mode 100644 index 00000000..bf6ff4ad --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_params.ts.effectFnOpportunity_toEffectFnUntraced.from580to609.output @@ -0,0 +1,25 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 580 - 609 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// These cases are okay and should trigger the diagnostic. +// Functions with parameters can be converted to Effect.fn. + +export const arrowWithParams = (a: number, b: string) => { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionExpressionWithParams = function(a: number, b: string) { + return Effect.gen(function*() { + yield* Effect.succeed(a) + return b + }) +} + +export const functionDeclarationWithParams = Effect.fnUntraced(function*(a: number, b: string) { + yield* Effect.succeed(a) + return b +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.codefixes index 44317d76..e26595f6 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.codefixes @@ -1,15 +1,15 @@ -effectFnOpportunity_toEffectFnWithSpan from 916 to 943 -effectFnOpportunity_toEffectFnUntraced from 916 to 943 -effectFnOpportunity_toEffectFnNoSpan from 916 to 943 -effectFnOpportunity_skipNextLine from 916 to 943 -effectFnOpportunity_skipFile from 916 to 943 -effectFnOpportunity_toEffectFnWithSpan from 557 to 570 -effectFnOpportunity_toEffectFnUntraced from 557 to 570 -effectFnOpportunity_toEffectFnNoSpan from 557 to 570 -effectFnOpportunity_skipNextLine from 557 to 570 -effectFnOpportunity_skipFile from 557 to 570 -effectFnOpportunity_toEffectFnWithSpan from 701 to 727 -effectFnOpportunity_toEffectFnUntraced from 701 to 727 -effectFnOpportunity_toEffectFnNoSpan from 701 to 727 -effectFnOpportunity_skipNextLine from 701 to 727 -effectFnOpportunity_skipFile from 701 to 727 \ No newline at end of file +effectFnOpportunity_toEffectFnWithSpan from 934 to 961 +effectFnOpportunity_toEffectFnUntraced from 934 to 961 +effectFnOpportunity_toEffectFnNoSpan from 934 to 961 +effectFnOpportunity_skipNextLine from 934 to 961 +effectFnOpportunity_skipFile from 934 to 961 +effectFnOpportunity_toEffectFnWithSpan from 575 to 588 +effectFnOpportunity_toEffectFnUntraced from 575 to 588 +effectFnOpportunity_toEffectFnNoSpan from 575 to 588 +effectFnOpportunity_skipNextLine from 575 to 588 +effectFnOpportunity_skipFile from 575 to 588 +effectFnOpportunity_toEffectFnWithSpan from 719 to 745 +effectFnOpportunity_toEffectFnUntraced from 719 to 745 +effectFnOpportunity_toEffectFnNoSpan from 719 to 745 +effectFnOpportunity_skipNextLine from 719 to 745 +effectFnOpportunity_skipFile from 719 to 745 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from575to588.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from575to588.output new file mode 100644 index 00000000..a916a149 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from575to588.output @@ -0,0 +1,27 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 575 - 588 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignore, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from719to745.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from719to745.output new file mode 100644 index 00000000..56fd101f --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from719to745.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 719 - 745 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignore, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from934to961.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from934to961.output new file mode 100644 index 00000000..1c460fd1 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnNoSpan.from934to961.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 934 - 961 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export const functionDeclarationWithPipe = Effect.fn(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.ignore, Effect.withSpan("functionDeclarationWithPipe")) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from575to588.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from575to588.output new file mode 100644 index 00000000..4f088cea --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from575to588.output @@ -0,0 +1,27 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 575 - 588 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignore, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from719to745.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from719to745.output new file mode 100644 index 00000000..2164fd7f --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from719to745.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 719 - 745 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignore, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from934to961.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from934to961.output new file mode 100644 index 00000000..fa12319c --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnUntraced.from934to961.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 934 - 961 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export const functionDeclarationWithPipe = Effect.fnUntraced(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.ignore, Effect.withSpan("functionDeclarationWithPipe")) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from575to588.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from575to588.output new file mode 100644 index 00000000..012c275f --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from575to588.output @@ -0,0 +1,27 @@ +// code fix effectFnOpportunity_toEffectFnWithSpan output for range 575 - 588 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = Effect.fn("arrowWithPipe")(function*() { + return yield* Effect.succeed(42) +}) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignore, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from719to745.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from719to745.output new file mode 100644 index 00000000..89b0d377 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from719to745.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnWithSpan output for range 719 - 745 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = Effect.fn("functionExpressionWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1)) + +export function functionDeclarationWithPipe() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.ignore, Effect.withSpan("functionDeclarationWithPipe")) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from934to961.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from934to961.output new file mode 100644 index 00000000..b718448a --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_pipeWithSpan.ts.effectFnOpportunity_toEffectFnWithSpan.from934to961.output @@ -0,0 +1,26 @@ +// code fix effectFnOpportunity_toEffectFnWithSpan output for range 934 - 961 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// For these cases we should suggest using Effect.fn (not Effect.fnUntraced) +// because the piped transformations end with Effect.withSpan. We can extract +// the span name expression from withSpan and use it as the parameter to +// Effect.fn("spanName")(function*() { ... }). +// +// Using Effect.fn is an improvement because the stack traces will include +// the call site of that function, not just the span in the traces. + +export const arrowWithPipe = () => + Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.withSpan("arrowWithPipe")) + +export const functionExpressionWithPipe = function() { + return Effect.gen(function*() { + return yield* Effect.succeed(42) + }).pipe(Effect.map((x) => x + 1), Effect.withSpan("functionExpressionWithPipe")) +} + +export const functionDeclarationWithPipe = Effect.fn("functionDeclarationWithPipe")(function*() { + return yield* Effect.succeed(42) +}, Effect.map((x) => x + 1), Effect.ignore) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.codefixes index 7588443e..170bc13b 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.codefixes @@ -1,12 +1,12 @@ -effectFnOpportunity_toEffectFnNoSpan from 757 to 785 -effectFnOpportunity_toEffectFnSpanInferred from 757 to 785 -effectFnOpportunity_skipNextLine from 757 to 785 -effectFnOpportunity_skipFile from 757 to 785 -effectFnOpportunity_toEffectFnNoSpan from 366 to 380 -effectFnOpportunity_toEffectFnSpanInferred from 366 to 380 -effectFnOpportunity_skipNextLine from 366 to 380 -effectFnOpportunity_skipFile from 366 to 380 -effectFnOpportunity_toEffectFnNoSpan from 520 to 547 -effectFnOpportunity_toEffectFnSpanInferred from 520 to 547 -effectFnOpportunity_skipNextLine from 520 to 547 -effectFnOpportunity_skipFile from 520 to 547 \ No newline at end of file +effectFnOpportunity_toEffectFnNoSpan from 775 to 803 +effectFnOpportunity_toEffectFnSpanInferred from 775 to 803 +effectFnOpportunity_skipNextLine from 775 to 803 +effectFnOpportunity_skipFile from 775 to 803 +effectFnOpportunity_toEffectFnNoSpan from 384 to 398 +effectFnOpportunity_toEffectFnSpanInferred from 384 to 398 +effectFnOpportunity_skipNextLine from 384 to 398 +effectFnOpportunity_skipFile from 384 to 398 +effectFnOpportunity_toEffectFnNoSpan from 538 to 565 +effectFnOpportunity_toEffectFnSpanInferred from 538 to 565 +effectFnOpportunity_skipNextLine from 538 to 565 +effectFnOpportunity_skipFile from 538 to 565 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from384to398.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from384to398.output new file mode 100644 index 00000000..3c0e1fa8 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from384to398.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 384 - 398 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = Effect.fn(function() { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +}) + +export const functionExpressionPlainMany = function(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} + +export function functionDeclarationPlainMany(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from538to565.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from538to565.output new file mode 100644 index 00000000..d01ae96d --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from538to565.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 538 - 565 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = () => { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +} + +export const functionExpressionPlainMany = Effect.fn(function (value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +}) + +export function functionDeclarationPlainMany(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from775to803.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from775to803.output new file mode 100644 index 00000000..c23622e0 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnNoSpan.from775to803.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 775 - 803 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = () => { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +} + +export const functionExpressionPlainMany = function(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} + +export const functionDeclarationPlainMany = Effect.fn(function (value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from384to398.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from384to398.output new file mode 100644 index 00000000..6353afc0 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from384to398.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 384 - 398 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = Effect.fn("arrowPlainMany")(function() { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +}) + +export const functionExpressionPlainMany = function(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} + +export function functionDeclarationPlainMany(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from538to565.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from538to565.output new file mode 100644 index 00000000..569c11c5 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from538to565.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 538 - 565 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = () => { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +} + +export const functionExpressionPlainMany = Effect.fn("functionExpressionPlainMany")(function (value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +}) + +export function functionDeclarationPlainMany(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from775to803.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from775to803.output new file mode 100644 index 00000000..aaf799be --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.effectFnOpportunity_toEffectFnSpanInferred.from775to803.output @@ -0,0 +1,37 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 775 - 803 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// There should be two code fixes offered: +// 1. Effect.fn("inferredName") - uses the inferred span name, improves +// tracing by adding spans. Recommended for app code. +// 2. Effect.fn (without name) - won't add tracing spans. + +export const arrowPlainMany = () => { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + return Effect.succeed(a + b + c + d + e) +} + +export const functionExpressionPlainMany = function(value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +} + +export const functionDeclarationPlainMany = Effect.fn("functionDeclarationPlainMany")(function (value: T) { + const a = 1 + const b = 2 + const c = 3 + const d = 4 + const e = 5 + if (value === null) return Effect.fail("Error!") + return Effect.succeed(a + b + c + d + e) +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.output index e247843b..c63c718a 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_plainMany.ts.output @@ -1,8 +1,8 @@ arrowPlainMany -9:13 - 9:27 | 2 | Can be rewritten as a reusable function: Effect.fn(function*() { ... }) effect(effectFnOpportunity) +9:13 - 9:27 | 2 | Can be rewritten as a reusable function: Effect.fn(() => { ... }) effect(effectFnOpportunity) functionExpressionPlainMany -18:13 - 18:40 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) +18:13 - 18:40 | 2 | Can be rewritten as a reusable function: Effect.fn(function(value) { ... }) effect(effectFnOpportunity) functionDeclarationPlainMany -28:16 - 28:44 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) \ No newline at end of file +28:16 - 28:44 | 2 | Can be rewritten as a reusable function: Effect.fn(function(value) { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.codefixes index 30cbf627..049705de 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.codefixes @@ -1,27 +1,27 @@ -effectFnOpportunity_toEffectFnUntraced from 557 to 590 -effectFnOpportunity_toEffectFnNoSpan from 557 to 590 -effectFnOpportunity_toEffectFnSpanInferred from 557 to 590 -effectFnOpportunity_skipNextLine from 557 to 590 -effectFnOpportunity_skipFile from 557 to 590 -effectFnOpportunity_toEffectFnNoSpan from 1200 to 1238 -effectFnOpportunity_toEffectFnSpanInferred from 1200 to 1238 -effectFnOpportunity_skipNextLine from 1200 to 1238 -effectFnOpportunity_skipFile from 1200 to 1238 -effectFnOpportunity_toEffectFnUntraced from 264 to 283 -effectFnOpportunity_toEffectFnNoSpan from 264 to 283 -effectFnOpportunity_toEffectFnSpanInferred from 264 to 283 -effectFnOpportunity_skipNextLine from 264 to 283 -effectFnOpportunity_skipFile from 264 to 283 -effectFnOpportunity_toEffectFnUntraced from 400 to 432 -effectFnOpportunity_toEffectFnNoSpan from 400 to 432 -effectFnOpportunity_toEffectFnSpanInferred from 400 to 432 -effectFnOpportunity_skipNextLine from 400 to 432 -effectFnOpportunity_skipFile from 400 to 432 -effectFnOpportunity_toEffectFnNoSpan from 843 to 867 -effectFnOpportunity_toEffectFnSpanInferred from 843 to 867 -effectFnOpportunity_skipNextLine from 843 to 867 -effectFnOpportunity_skipFile from 843 to 867 -effectFnOpportunity_toEffectFnNoSpan from 1011 to 1048 -effectFnOpportunity_toEffectFnSpanInferred from 1011 to 1048 -effectFnOpportunity_skipNextLine from 1011 to 1048 -effectFnOpportunity_skipFile from 1011 to 1048 \ No newline at end of file +effectFnOpportunity_toEffectFnUntraced from 575 to 608 +effectFnOpportunity_toEffectFnNoSpan from 575 to 608 +effectFnOpportunity_toEffectFnSpanInferred from 575 to 608 +effectFnOpportunity_skipNextLine from 575 to 608 +effectFnOpportunity_skipFile from 575 to 608 +effectFnOpportunity_toEffectFnNoSpan from 1218 to 1256 +effectFnOpportunity_toEffectFnSpanInferred from 1218 to 1256 +effectFnOpportunity_skipNextLine from 1218 to 1256 +effectFnOpportunity_skipFile from 1218 to 1256 +effectFnOpportunity_toEffectFnUntraced from 282 to 301 +effectFnOpportunity_toEffectFnNoSpan from 282 to 301 +effectFnOpportunity_toEffectFnSpanInferred from 282 to 301 +effectFnOpportunity_skipNextLine from 282 to 301 +effectFnOpportunity_skipFile from 282 to 301 +effectFnOpportunity_toEffectFnUntraced from 418 to 450 +effectFnOpportunity_toEffectFnNoSpan from 418 to 450 +effectFnOpportunity_toEffectFnSpanInferred from 418 to 450 +effectFnOpportunity_skipNextLine from 418 to 450 +effectFnOpportunity_skipFile from 418 to 450 +effectFnOpportunity_toEffectFnNoSpan from 861 to 885 +effectFnOpportunity_toEffectFnSpanInferred from 861 to 885 +effectFnOpportunity_skipNextLine from 861 to 885 +effectFnOpportunity_skipFile from 861 to 885 +effectFnOpportunity_toEffectFnNoSpan from 1029 to 1066 +effectFnOpportunity_toEffectFnSpanInferred from 1029 to 1066 +effectFnOpportunity_skipNextLine from 1029 to 1066 +effectFnOpportunity_skipFile from 1029 to 1066 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1029to1066.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1029to1066.output new file mode 100644 index 00000000..407311fd --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1029to1066.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 1029 - 1066 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = Effect.fn(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1218to1256.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1218to1256.output new file mode 100644 index 00000000..11b166ec --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from1218to1256.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 1218 - 1256 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionDeclarationWithTypeParamsNoGen = Effect.fn(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from282to301.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from282to301.output new file mode 100644 index 00000000..c2a2c865 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from282to301.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 282 - 301 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = Effect.fn(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from418to450.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from418to450.output new file mode 100644 index 00000000..8385cb4c --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from418to450.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 418 - 450 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = Effect.fn(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from575to608.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from575to608.output new file mode 100644 index 00000000..7bb517a8 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from575to608.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 575 - 608 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionDeclarationWithTypeParams = Effect.fn(function* (value: T) { + return yield* Effect.succeed(value) +}) + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from861to885.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from861to885.output new file mode 100644 index 00000000..ec1f8a63 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnNoSpan.from861to885.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnNoSpan output for range 861 - 885 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = Effect.fn(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1029to1066.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1029to1066.output new file mode 100644 index 00000000..accb5deb --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1029to1066.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1029 - 1066 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = Effect.fn("functionExpressionWithTypeParamsNoGen")(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1218to1256.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1218to1256.output new file mode 100644 index 00000000..0fc2779c --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from1218to1256.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 1218 - 1256 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionDeclarationWithTypeParamsNoGen = Effect.fn("functionDeclarationWithTypeParamsNoGen")(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from282to301.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from282to301.output new file mode 100644 index 00000000..0bbe1260 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from282to301.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 282 - 301 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = Effect.fn("arrowWithTypeParams")(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from418to450.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from418to450.output new file mode 100644 index 00000000..1ed21c6d --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from418to450.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 418 - 450 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = Effect.fn("functionExpressionWithTypeParams")(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from575to608.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from575to608.output new file mode 100644 index 00000000..2adbdcde --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from575to608.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 575 - 608 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionDeclarationWithTypeParams = Effect.fn("functionDeclarationWithTypeParams")(function* (value: T) { + return yield* Effect.succeed(value) +}) + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from861to885.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from861to885.output new file mode 100644 index 00000000..97ceb260 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnSpanInferred.from861to885.output @@ -0,0 +1,54 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 861 - 885 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = Effect.fn("arrowWithTypeParamsNoGen")(function (value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +}) + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from282to301.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from282to301.output new file mode 100644 index 00000000..958145c3 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from282to301.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 282 - 301 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = Effect.fnUntraced(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from418to450.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from418to450.output new file mode 100644 index 00000000..c79b10a7 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from418to450.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 418 - 450 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = Effect.fnUntraced(function* (value: T) { + return yield* Effect.succeed(value) +}) + +export function functionDeclarationWithTypeParams(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from575to608.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from575to608.output new file mode 100644 index 00000000..a16dc79f --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.effectFnOpportunity_toEffectFnUntraced.from575to608.output @@ -0,0 +1,52 @@ +// code fix effectFnOpportunity_toEffectFnUntraced output for range 575 - 608 +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } +import * as Effect from "effect/Effect" + +// The diagnostic should trigger for these cases. We should check that +// the quick fixes have kept the generic type arguments. + +export const arrowWithTypeParams = (value: T) => { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionExpressionWithTypeParams = function(value: T) { + return Effect.gen(function*() { + return yield* Effect.succeed(value) + }) +} + +export const functionDeclarationWithTypeParams = Effect.fnUntraced(function* (value: T) { + return yield* Effect.succeed(value) +}) + +// Regular functions with type parameters returning Effect (no Effect.gen) +// These have >5 statements so they should trigger the diagnostic + +export const arrowWithTypeParamsNoGen = (value: T) => { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export const functionExpressionWithTypeParamsNoGen = function(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} + +export function functionDeclarationWithTypeParamsNoGen(value: T) { + const _a = 1 + const _b = 2 + const _c = 3 + const _d = 4 + const _e = 5 + return Effect.succeed(value) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.output index beb9d15c..afe66b6e 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_typeParams.ts.output @@ -8,10 +8,10 @@ functionDeclarationWithTypeParams 19:16 - 19:49 | 2 | Can be rewritten as a reusable function: Effect.fnUntraced(function*(value) { ... }) effect(effectFnOpportunity) arrowWithTypeParamsNoGen -28:13 - 28:37 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) +28:13 - 28:37 | 2 | Can be rewritten as a reusable function: Effect.fn((value) => { ... }) effect(effectFnOpportunity) functionExpressionWithTypeParamsNoGen -37:13 - 37:50 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) +37:13 - 37:50 | 2 | Can be rewritten as a reusable function: Effect.fn(function(value) { ... }) effect(effectFnOpportunity) functionDeclarationWithTypeParamsNoGen -46:16 - 46:54 | 2 | Can be rewritten as a reusable function: Effect.fn(function*(value) { ... }) effect(effectFnOpportunity) \ No newline at end of file +46:16 - 46:54 | 2 | Can be rewritten as a reusable function: Effect.fn(function(value) { ... }) effect(effectFnOpportunity) \ No newline at end of file diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_alreadyEffectFn.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_alreadyEffectFn.ts index 5c109df2..730094c1 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_alreadyEffectFn.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_alreadyEffectFn.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" export const alreadyEffectFnWithName = Effect.fn("alreadyEffectFnWithName")(function*() { diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_basic.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_basic.ts index 0b079621..831b2420 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_basic.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_basic.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // These cases can be converted to Effect.fnUntraced because: diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_genWithThis.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_genWithThis.ts index 72a9d549..c1eeb0ac 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_genWithThis.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_genWithThis.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should NOT trigger for these cases because Effect.gen is diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferred.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferred.ts new file mode 100644 index 00000000..230c6616 --- /dev/null +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferred.ts @@ -0,0 +1,23 @@ +// @test-config { "effectFn": ["inferred-span"] } +import * as Effect from "effect/Effect" + +const _notExporedNoSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export const shouldHaveSuggestion = () => { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} + +export function shouldHaveSuggestioFunction() { + return Effect.gen(function*() { + yield* Effect.succeed(1) + return 42 + }) +} diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayer.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayer.ts new file mode 100644 index 00000000..6b667594 --- /dev/null +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayer.ts @@ -0,0 +1,28 @@ +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, ServiceMap } from "effect" + +class MyService extends ServiceMap.Service Effect.Effect +}>()("MyService") {} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_invalid.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_invalid.ts index b367d32c..74e8270b 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_invalid.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_invalid.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } // Generator functions export const generatorExpression = function*() { diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_multipleReturns.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_multipleReturns.ts index dfafbf04..e87e288c 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_multipleReturns.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_multipleReturns.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // These should not trigger because they are not returning just Effect.gen, diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_noPipeWithSpan.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_noPipeWithSpan.ts index 12bd5a46..f8d7fd41 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_noPipeWithSpan.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_noPipeWithSpan.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // This case differs from pipeWithSpan because the withSpan is not the last diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_overloadsNever.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_overloadsNever.ts index 76eb2a72..469c0e49 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_overloadsNever.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_overloadsNever.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic will never trigger for function declarations with overload diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_overloadsOk.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_overloadsOk.ts index 1948e620..9f557219 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_overloadsOk.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_overloadsOk.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should trigger for these cases. When assigning to a const diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_params.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_params.ts index 75d2f72d..dec881d5 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_params.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_params.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // These cases are okay and should trigger the diagnostic. diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_paramsInPipe.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_paramsInPipe.ts index 80961fe9..355583a5 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_paramsInPipe.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_paramsInPipe.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should NOT trigger for these cases because the function diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_pipeWithSpan.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_pipeWithSpan.ts index ce152fbb..4f3dbd27 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_pipeWithSpan.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_pipeWithSpan.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // For these cases we should suggest using Effect.fn (not Effect.fnUntraced) diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_plainFew.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_plainFew.ts index d45b2d10..c7d29f3d 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_plainFew.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_plainFew.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // For these cases we could only convert to Effect.fn (not Effect.fnUntraced diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_plainMany.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_plainMany.ts index 7e257b82..39554acb 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_plainMany.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_plainMany.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // There should be two code fixes offered: diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_returnType.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_returnType.ts index 5c47ccee..6ee1371e 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_returnType.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_returnType.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should never trigger on these cases because there is diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_typeParams.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_typeParams.ts index 2c114afc..14a65ca0 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_typeParams.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_typeParams.ts @@ -1,4 +1,4 @@ -// @test-config { "effectFn": ["span", "inferred-span", "no-span", "untraced"] } +// @test-config { "effectFn": ["span", "suggested-span", "inferred-span", "no-span", "untraced"] } import * as Effect from "effect/Effect" // The diagnostic should trigger for these cases. We should check that diff --git a/packages/language-service/src/core/LanguageServicePluginOptions.ts b/packages/language-service/src/core/LanguageServicePluginOptions.ts index ef1525d2..db0319d5 100644 --- a/packages/language-service/src/core/LanguageServicePluginOptions.ts +++ b/packages/language-service/src/core/LanguageServicePluginOptions.ts @@ -40,7 +40,7 @@ export interface LanguageServicePluginOptions { renames: boolean noExternal: boolean pipeableMinArgCount: number - effectFn: Array<"untraced" | "span" | "inferred-span" | "no-span"> + effectFn: Array<"untraced" | "span" | "suggested-span" | "inferred-span" | "no-span"> layerGraphFollowDepth: number mermaidProvider: "mermaid.com" | "mermaid.live" | ({} & string) } @@ -215,7 +215,9 @@ export function parse(config: any): LanguageServicePluginOptions { : defaults.pipeableMinArgCount, effectFn: isObject(config) && hasProperty(config, "effectFn") && isArray(config.effectFn) && config.effectFn.every(isString) - ? config.effectFn.map((_) => _.toLowerCase() as "untraced" | "span" | "inferred-span" | "no-span") + ? config.effectFn.map((_) => + _.toLowerCase() as "untraced" | "span" | "inferred-span" | "suggested-span" | "no-span" + ) : defaults.effectFn, layerGraphFollowDepth: isObject(config) && hasProperty(config, "layerGraphFollowDepth") && isNumber(config.layerGraphFollowDepth) diff --git a/packages/language-service/src/diagnostics/effectFnOpportunity.ts b/packages/language-service/src/diagnostics/effectFnOpportunity.ts index 045ae410..c1a16580 100644 --- a/packages/language-service/src/diagnostics/effectFnOpportunity.ts +++ b/packages/language-service/src/diagnostics/effectFnOpportunity.ts @@ -1,5 +1,4 @@ import { pipe } from "effect/Function" -import * as Option from "effect/Option" import type ts from "typescript" import * as LanguageServicePluginOptions from "../core/LanguageServicePluginOptions.js" import * as LSP from "../core/LSP.js" @@ -16,7 +15,9 @@ interface EffectFnOpportunityTarget { readonly node: SupportedFunctionNode readonly nameIdentifier: ts.Identifier | ts.StringLiteral | undefined readonly effectModuleName: string - /** Inferred trace name from the function/variable name */ + /** Suggested trace name from the function/variable name */ + readonly suggestedTraceName: string | undefined + /** Inferred trace name from exported member/context */ readonly inferredTraceName: string | undefined /** Explicit trace expression extracted from withSpan (if last pipe arg is withSpan) */ readonly explicitTraceExpression: ts.Expression | undefined @@ -78,20 +79,25 @@ export const effectFnOpportunity = LSP.createDiagnostic({ /** * Gets the name identifier node from the context (variable name or function declaration name) */ - const getNameIdentifier = (node: SupportedFunctionNode): ts.Identifier | ts.StringLiteral | undefined => { + const getNameIdentifier = ( + node: SupportedFunctionNode + ): ts.Identifier | ts.StringLiteral | undefined => { if (ts.isFunctionDeclaration(node) && node.name) { return node.name } - if (node.parent && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { + if ( + node.parent && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) && + node.parent.initializer === node + ) { return node.parent.name } - if (node.parent && ts.isPropertyAssignment(node.parent)) { + if (node.parent && ts.isPropertyAssignment(node.parent) && node.parent.initializer === node) { const name = node.parent.name if (ts.isIdentifier(name) || ts.isStringLiteral(name)) { return name } } - if (node.parent && ts.isPropertyDeclaration(node.parent)) { + if (node.parent && ts.isPropertyDeclaration(node.parent) && node.parent.initializer === node) { const name = node.parent.name if (ts.isIdentifier(name)) { return name @@ -100,6 +106,191 @@ export const effectFnOpportunity = LSP.createDiagnostic({ return undefined } + const hasExportModifier = (node: ts.Node): boolean => { + if (!ts.canHaveModifiers(node)) return false + const modifiers = ts.getModifiers(node) + return modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false + } + + const textOfExpression = (expression: ts.Expression): string => { + if (ts.isIdentifier(expression)) return ts.idText(expression) + return sourceFile.text.slice(expression.pos, expression.end).trim() + } + + const tryGetLayerApiMethod = ( + node: ts.Node + ): Nano.Nano<"effect" | "succeed" | "sync" | undefined, never, never> => + pipe( + typeParser.isNodeReferenceToEffectLayerModuleApi("effect")(node), + Nano.map(() => "effect" as const), + Nano.orElse(() => + pipe( + typeParser.isNodeReferenceToEffectLayerModuleApi("succeed")(node), + Nano.map(() => "succeed" as const), + Nano.orElse(() => + pipe( + typeParser.isNodeReferenceToEffectLayerModuleApi("sync")(node), + Nano.map(() => "sync" as const), + Nano.orElse(() => Nano.succeed(undefined)) + ) + ) + ) + ) + ) + + const verifyLayerMethodAtCall: ( + callExpression: ts.CallExpression, + method: "effect" | "succeed" | "sync", + implementationExpression: ts.Expression + ) => Nano.Nano = Nano.fn("effectFnOpportunity.verifyLayerMethodAtCall")( + function*( + callExpression: ts.CallExpression, + method: "effect" | "succeed" | "sync", + implementationExpression: ts.Expression + ) { + const directMethod = yield* tryGetLayerApiMethod(callExpression.expression) + if ( + directMethod === method && callExpression.arguments.length >= 2 && + callExpression.arguments[1] === implementationExpression + ) { + return textOfExpression(callExpression.arguments[0]) + } + if (ts.isCallExpression(callExpression.expression)) { + const innerCall = callExpression.expression + const innerMethod = yield* tryGetLayerApiMethod(innerCall.expression) + if ( + innerMethod === method && innerCall.arguments.length >= 1 && callExpression.arguments.length >= 1 && + callExpression.arguments[0] === implementationExpression + ) { + return textOfExpression(innerCall.arguments[0]) + } + } + return undefined + } + ) + + const tryMatchLayerSucceedInference: ( + objectLiteral: ts.ObjectLiteralExpression + ) => Nano.Nano = Nano.fn("effectFnOpportunity.tryMatchLayerSucceedInference")( + function*(objectLiteral: ts.ObjectLiteralExpression) { + const callExpression = objectLiteral.parent + if (!callExpression || !ts.isCallExpression(callExpression)) return undefined + return yield* verifyLayerMethodAtCall(callExpression, "succeed", objectLiteral) + } + ) + + const tryMatchLayerSyncInference: ( + objectLiteral: ts.ObjectLiteralExpression + ) => Nano.Nano = Nano.fn("effectFnOpportunity.tryMatchLayerSyncInference")( + function*(objectLiteral: ts.ObjectLiteralExpression) { + const returnStatement = objectLiteral.parent + if (!returnStatement || !ts.isReturnStatement(returnStatement)) return undefined + const functionBody = returnStatement.parent + if (!functionBody || !ts.isBlock(functionBody)) return undefined + const lazyFunction = functionBody.parent + if (!lazyFunction || (!ts.isArrowFunction(lazyFunction) && !ts.isFunctionExpression(lazyFunction))) { + return undefined + } + const callExpression = lazyFunction.parent + if (!callExpression || !ts.isCallExpression(callExpression)) return undefined + return yield* verifyLayerMethodAtCall(callExpression, "sync", lazyFunction) + } + ) + + const tryMatchLayerEffectInference: ( + objectLiteral: ts.ObjectLiteralExpression + ) => Nano.Nano = Nano.fn("effectFnOpportunity.tryMatchLayerEffectInference")( + function*(objectLiteral: ts.ObjectLiteralExpression) { + const returnStatement = objectLiteral.parent + if (!returnStatement || !ts.isReturnStatement(returnStatement)) return undefined + const generatorBody = returnStatement.parent + if (!generatorBody || !ts.isBlock(generatorBody)) return undefined + const generatorFunction = generatorBody.parent + if (!generatorFunction || !ts.isFunctionExpression(generatorFunction) || !generatorFunction.asteriskToken) { + return undefined + } + const genCall = generatorFunction.parent + if (!genCall || !ts.isCallExpression(genCall)) return undefined + const parsedEffectGen = yield* Nano.option(typeParser.effectGen(genCall)) + if (parsedEffectGen._tag === "None" || parsedEffectGen.value.generatorFunction !== generatorFunction) { + return undefined + } + const layerCall = genCall.parent + if (!layerCall || !ts.isCallExpression(layerCall)) return undefined + return yield* verifyLayerMethodAtCall(layerCall, "effect", genCall) + } + ) + + /** + * Gets a strict inferred trace name from layer pattern suspects. + */ + const tryGetLayerInferredTraceName: ( + node: SupportedFunctionNode, + suggestedTraceName: string | undefined + ) => Nano.Nano = Nano.fn("effectFnOpportunity.tryGetLayerInferredTraceName")( + function*(node: SupportedFunctionNode, suggestedTraceName: string | undefined) { + if (!suggestedTraceName) return undefined + if ( + !( + node.parent && + ts.isPropertyAssignment(node.parent) && + node.parent.initializer === node && + node.parent.parent && + ts.isObjectLiteralExpression(node.parent.parent) + ) + ) { + return undefined + } + + const objectLiteral = node.parent.parent + const succeedServiceName = yield* tryMatchLayerSucceedInference(objectLiteral) + if (succeedServiceName) return `${succeedServiceName}.${suggestedTraceName}` + + const syncServiceName = yield* tryMatchLayerSyncInference(objectLiteral) + if (syncServiceName) return `${syncServiceName}.${suggestedTraceName}` + + const effectServiceName = yield* tryMatchLayerEffectInference(objectLiteral) + return effectServiceName ? `${effectServiceName}.${suggestedTraceName}` : undefined + } + ) + + /** + * Gets an inferred trace name from strict contexts: + * - Layer service implementation members (ServiceTag.memberName) + * - exported declarations (function declarations or exported const initializers) + */ + const getInferredTraceName: ( + node: SupportedFunctionNode, + suggestedTraceName: string | undefined + ) => Nano.Nano = Nano.fn("effectFnOpportunity.getInferredTraceName")( + function*(node: SupportedFunctionNode, suggestedTraceName: string | undefined) { + const inferredFromLayer = yield* tryGetLayerInferredTraceName(node, suggestedTraceName) + if (inferredFromLayer) return inferredFromLayer + + if (ts.isFunctionDeclaration(node) && node.name && hasExportModifier(node)) { + return ts.idText(node.name) + } + + if ( + node.parent && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) && + node.parent.initializer === node + ) { + const variableDeclarationList = node.parent.parent + const variableStatement = variableDeclarationList?.parent + if ( + variableDeclarationList && ts.isVariableDeclarationList(variableDeclarationList) && + variableStatement && ts.isVariableStatement(variableStatement) && + hasExportModifier(variableStatement) && + (variableDeclarationList.flags & ts.NodeFlags.Const) !== 0 + ) { + return ts.idText(node.parent.name) + } + } + + return undefined + } + ) + interface ParsedOpportunity { readonly effectModuleName: string readonly pipeArguments: ReadonlyArray @@ -249,9 +440,14 @@ export const effectFnOpportunity = LSP.createDiagnostic({ function*( node: SupportedFunctionNode, returnType: ts.Type, - traceName: string, - nameIdentifier: ts.Identifier | ts.StringLiteral + nameIdentifier: ts.Identifier | ts.StringLiteral | undefined ) { + const suggestedTraceName = nameIdentifier + ? ts.isIdentifier(nameIdentifier) ? ts.idText(nameIdentifier) : nameIdentifier.text + : undefined + const inferredTraceName = yield* getInferredTraceName(node, suggestedTraceName) + const hasStrictLayerInferredName = inferredTraceName !== undefined && inferredTraceName !== suggestedTraceName + // Check if this function is already inside an Effect.fn call if (yield* isInsideEffectFn(node)) { return yield* TypeParser.TypeParserIssue.issue @@ -269,12 +465,15 @@ export const effectFnOpportunity = LSP.createDiagnostic({ tryParseGenOpportunity(node), Nano.orElse(() => { // Skip arrow functions with concise body (expression body, no braces) - if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) { + if (ts.isArrowFunction(node) && !ts.isBlock(node.body) && !hasStrictLayerInferredName) { return TypeParser.TypeParserIssue.issue } // For functions with a block body, only suggest if there are more than 5 statements const body = ts.isArrowFunction(node) ? node.body as ts.Block : node.body - if (!body || !ts.isBlock(body) || body.statements.length <= 5) { + if ( + (!body || !ts.isBlock(body) || body.statements.length <= 5) && + !hasStrictLayerInferredName + ) { return TypeParser.TypeParserIssue.issue } return Nano.succeed({ @@ -290,7 +489,8 @@ export const effectFnOpportunity = LSP.createDiagnostic({ node, nameIdentifier, effectModuleName: opportunity.effectModuleName, - inferredTraceName: traceName, + inferredTraceName, + suggestedTraceName, explicitTraceExpression: opportunity.explicitTraceExpression, pipeArguments: opportunity.pipeArguments, generatorFunction: opportunity.generatorFunction, @@ -304,34 +504,34 @@ export const effectFnOpportunity = LSP.createDiagnostic({ */ const parseEffectFnOpportunityTarget = ( node: ts.Node - ): Nano.Nano => { + ): undefined | Nano.Nano => { // We're looking for function expressions, arrow functions, or function declarations if (!ts.isFunctionExpression(node) && !ts.isArrowFunction(node) && !ts.isFunctionDeclaration(node)) { - return TypeParser.TypeParserIssue.issue + return } // Skip generator functions (they can't be converted) if ((ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) && node.asteriskToken) { - return TypeParser.TypeParserIssue.issue + return } // Skip named function expressions (they are typically used for recursion) if (ts.isFunctionExpression(node) && node.name) { - return TypeParser.TypeParserIssue.issue + return } // Skip functions with return type annotations (they could be recursive) if (node.type) { - return TypeParser.TypeParserIssue.issue + return } // Get the type of the function to check call signatures const functionType = typeChecker.getTypeAtLocation(node) - if (!functionType) return TypeParser.TypeParserIssue.issue + if (!functionType) return // Check if the function has only one call signature (no overloads) const callSignatures = typeChecker.getSignaturesOfType(functionType, ts.SignatureKind.Call) - if (callSignatures.length !== 1) return TypeParser.TypeParserIssue.issue + if (callSignatures.length !== 1) return // Get the return type of the function const signature = callSignatures[0] @@ -339,14 +539,9 @@ export const effectFnOpportunity = LSP.createDiagnostic({ // Try to get a name identifier and trace name const nameIdentifier = getNameIdentifier(node) - const traceName = nameIdentifier - ? ts.isIdentifier(nameIdentifier) ? ts.idText(nameIdentifier) : nameIdentifier.text - : undefined + if (!nameIdentifier) return - // Only if we have a traceName, that means basically either declaration name or parent - if (!traceName) return TypeParser.TypeParserIssue.issue - - return parseEffectFnOpportunityTargetGen(node, returnType, traceName, nameIdentifier!) + return parseEffectFnOpportunityTargetGen(node, returnType, nameIdentifier) } // ==================== Fix creation helpers ==================== @@ -469,12 +664,14 @@ export const effectFnOpportunity = LSP.createDiagnostic({ const node = nodeToVisit.shift()! ts.forEachChild(node, appendNodeToVisit) - const target = yield* pipe(parseEffectFnOpportunityTarget(node), Nano.option) - if (Option.isNone(target)) continue + const test = parseEffectFnOpportunityTarget(node) + if (!test) continue + const target = yield* Nano.orUndefined(test) + if (!target) continue // Skip if function parameters are referenced in pipe arguments // (unsafe to convert - parameters wouldn't be in scope after transformation) - if (target.value.hasParamsInPipeArgs) continue + if (target.hasParamsInPipeArgs) continue const { effectModuleName, @@ -482,9 +679,10 @@ export const effectFnOpportunity = LSP.createDiagnostic({ inferredTraceName, nameIdentifier, node: targetNode, - pipeArguments - } = target.value - const innerFunction = target.value.generatorFunction ?? targetNode + pipeArguments, + suggestedTraceName + } = target + const innerFunction = target.generatorFunction ?? targetNode const fixes: Array = [] @@ -511,7 +709,7 @@ export const effectFnOpportunity = LSP.createDiagnostic({ // toEffectFnUntraced: available when we have a generator function // Keeps ALL pipe arguments including withSpan since fnUntraced doesn't add tracing - if (pluginOptions.effectFn.includes("untraced") && target.value.generatorFunction) { + if (pluginOptions.effectFn.includes("untraced") && target.generatorFunction) { fixes.push({ fixName: "effectFnOpportunity_toEffectFnUntraced", description: "Convert to Effect.fnUntraced", @@ -536,23 +734,48 @@ export const effectFnOpportunity = LSP.createDiagnostic({ }) } - // toEffectFnSpanInferred: available if we have inferred span name AND no explicit one - if (pluginOptions.effectFn.includes("inferred-span") && inferredTraceName && !explicitTraceExpression) { - fixes.push({ - fixName: "effectFnOpportunity_toEffectFnSpanInferred", - description: `Convert to Effect.fn("${inferredTraceName}")`, - apply: Nano.gen(function*() { - const changeTracker = yield* Nano.service(TypeScriptApi.ChangeTracker) - const newNode = createEffectFnNode( - targetNode, - innerFunction, - effectModuleName, - inferredTraceName, - pipeArguments - ) - changeTracker.replaceNode(sourceFile, targetNode, newNode) + // toEffectFnSpanInferred: available if we have strict inferred span name AND no explicit one + if (!explicitTraceExpression) { + if (pluginOptions.effectFn.includes("inferred-span") && inferredTraceName) { + fixes.push({ + fixName: "effectFnOpportunity_toEffectFnSpanInferred", + description: `Convert to Effect.fn("${inferredTraceName}")`, + apply: Nano.gen(function*() { + const changeTracker = yield* Nano.service(TypeScriptApi.ChangeTracker) + const newNode = createEffectFnNode( + targetNode, + innerFunction, + effectModuleName, + inferredTraceName, + pipeArguments + ) + changeTracker.replaceNode(sourceFile, targetNode, newNode) + }) }) - }) + } + + // toEffectFnSpanSuggested: broad suggestion based on local naming context + if ( + pluginOptions.effectFn.includes("suggested-span") && + suggestedTraceName && + (!pluginOptions.effectFn.includes("inferred-span") || suggestedTraceName !== inferredTraceName) + ) { + fixes.push({ + fixName: "effectFnOpportunity_toEffectFnSpanSuggested", + description: `Convert to Effect.fn("${suggestedTraceName}")`, + apply: Nano.gen(function*() { + const changeTracker = yield* Nano.service(TypeScriptApi.ChangeTracker) + const newNode = createEffectFnNode( + targetNode, + innerFunction, + effectModuleName, + suggestedTraceName, + pipeArguments + ) + changeTracker.replaceNode(sourceFile, targetNode, newNode) + }) + }) + } } // no fix, continue @@ -577,7 +800,11 @@ export const effectFnOpportunity = LSP.createDiagnostic({ return "_" }).join(", ") - const fnSignature = `function*${typeParamNames}(${paramNames}) { ... }` + const fnSignature = ts.isArrowFunction(innerFunction) + ? `${typeParamNames}(${paramNames}) => { ... }` + : isGeneratorFunction(innerFunction) + ? `function*${typeParamNames}(${paramNames}) { ... }` + : `function${typeParamNames}(${paramNames}) { ... }` const pipeArgsForWithSpan = pipeArguments.slice(0, -1) const pipeArgsSuffix = (args: ReadonlyArray) => args.length > 0 ? ", ...pipeTransformations" : "" @@ -594,6 +821,8 @@ export const effectFnOpportunity = LSP.createDiagnostic({ return `${effectModuleName}.fn(${fnSignature}${pipeArgsSuffix(pipeArguments)})` case "effectFnOpportunity_toEffectFnSpanInferred": return `${effectModuleName}.fn("${inferredTraceName}")(${fnSignature}${pipeArgsSuffix(pipeArguments)})` + case "effectFnOpportunity_toEffectFnSpanSuggested": + return `${effectModuleName}.fn("${suggestedTraceName}")(${fnSignature}${pipeArgsSuffix(pipeArguments)})` default: return `${effectModuleName}.fn(${fnSignature})` } diff --git a/packages/language-service/test/perf.ts b/packages/language-service/test/perf.ts index 76efc9b6..576c4e2c 100644 --- a/packages/language-service/test/perf.ts +++ b/packages/language-service/test/perf.ts @@ -2,7 +2,6 @@ import { pipe } from "effect/Function" import * as Result from "effect/Result" import * as fs from "fs" import * as path from "path" -import { getExamplesDir, getHarnessDir } from "test/utils/harness.js" import * as ts from "typescript" import * as LanguageServicePluginOptions from "../src/core/LanguageServicePluginOptions.js" import * as LSP from "../src/core/LSP" @@ -13,6 +12,7 @@ import * as TypeParser from "../src/core/TypeParser" import * as TypeScriptApi from "../src/core/TypeScriptApi" import * as TypeScriptUtils from "../src/core/TypeScriptUtils" import { diagnostics } from "../src/diagnostics" +import { getExamplesDir, getHarnessDir } from "./utils/harness.js" import { createServicesWithMockedVFS } from "./utils/mocks.js" const getExamplesDiagnosticsDir = () => path.join(__dirname, "..", "..", "harness-effect-v3", "examples", "diagnostics")