@effect/language-service 0.70.0 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/language-service",
3
- "version": "0.70.0",
3
+ "version": "0.71.0",
4
4
  "description": "A Language-Service Plugin to Refactor and Diagnostic effect-ts projects",
5
5
  "main": "index.cjs",
6
6
  "bin": {
package/transform.js CHANGED
@@ -5484,6 +5484,57 @@ var effectMapVoid = createDiagnostic({
5484
5484
  })
5485
5485
  });
5486
5486
 
5487
+ // src/diagnostics/effectSucceedWithVoid.ts
5488
+ var effectSucceedWithVoid = createDiagnostic({
5489
+ name: "effectSucceedWithVoid",
5490
+ code: 47,
5491
+ description: "Suggests using Effect.void instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
5492
+ severity: "suggestion",
5493
+ apply: fn("effectSucceedWithVoid.apply")(function* (sourceFile, report) {
5494
+ const ts = yield* service(TypeScriptApi);
5495
+ const typeParser = yield* service(TypeParser);
5496
+ const tsUtils = yield* service(TypeScriptUtils);
5497
+ const nodeToVisit = [];
5498
+ const appendNodeToVisit = (node) => {
5499
+ nodeToVisit.push(node);
5500
+ return void 0;
5501
+ };
5502
+ ts.forEachChild(sourceFile, appendNodeToVisit);
5503
+ while (nodeToVisit.length > 0) {
5504
+ const node = nodeToVisit.shift();
5505
+ ts.forEachChild(node, appendNodeToVisit);
5506
+ if (ts.isCallExpression(node)) {
5507
+ const isSucceedCall = yield* pipe(
5508
+ typeParser.isNodeReferenceToEffectModuleApi("succeed")(node.expression),
5509
+ option
5510
+ );
5511
+ if (isSome2(isSucceedCall)) {
5512
+ const argument = node.arguments[0];
5513
+ if (!argument) continue;
5514
+ if (!tsUtils.isVoidExpression(argument)) continue;
5515
+ report({
5516
+ location: node,
5517
+ messageText: "Effect.void can be used instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
5518
+ fixes: [{
5519
+ fixName: "effectSucceedWithVoid_fix",
5520
+ description: "Replace with Effect.void",
5521
+ apply: gen(function* () {
5522
+ const changeTracker = yield* service(ChangeTracker);
5523
+ const effectModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(sourceFile, "effect", "Effect") || "Effect";
5524
+ const newNode = ts.factory.createPropertyAccessExpression(
5525
+ ts.factory.createIdentifier(effectModuleIdentifier),
5526
+ ts.factory.createIdentifier("void")
5527
+ );
5528
+ changeTracker.replaceNode(sourceFile, node, newNode);
5529
+ })
5530
+ }]
5531
+ });
5532
+ }
5533
+ }
5534
+ }
5535
+ })
5536
+ });
5537
+
5487
5538
  // src/diagnostics/floatingEffect.ts
5488
5539
  var floatingEffect = createDiagnostic({
5489
5540
  name: "floatingEffect",
@@ -5627,8 +5678,7 @@ var globalErrorInEffectCatch = createDiagnostic({
5627
5678
  );
5628
5679
  report({
5629
5680
  location: node.expression,
5630
- messageText: `The 'catch' callback in ${nodeText} returns the global Error type. It's not recommended to use the global Error type in Effect failures as they can get merged together.
5631
- Instead, use tagged errors or custom errors with a discriminator property to get properly type-checked errors.`,
5681
+ messageText: `The 'catch' callback in ${nodeText} returns global 'Error', which loses type safety as untagged errors merge together. Consider using a tagged error and optionally wrapping the original in a 'cause' property.`,
5632
5682
  fixes: []
5633
5683
  });
5634
5684
  }
@@ -5680,7 +5730,7 @@ var globalErrorInEffectFailure = createDiagnostic({
5680
5730
  if (hasGlobalError) {
5681
5731
  report({
5682
5732
  location: node,
5683
- messageText: `The global Error type is used in an Effect failure channel. It's not recommended to use the global Error type in Effect failures as they can get merged together. Instead, use tagged errors or custom errors with a discriminator property to get properly type-checked errors.`,
5733
+ messageText: `Global 'Error' loses type safety as untagged errors merge together in the Effect failure channel. Consider using a tagged error and optionally wrapping the original in a 'cause' property.`,
5684
5734
  fixes: []
5685
5735
  });
5686
5736
  }
@@ -9387,6 +9437,7 @@ var diagnostics = [
9387
9437
  globalErrorInEffectFailure,
9388
9438
  layerMergeAllWithDependencies,
9389
9439
  effectMapVoid,
9440
+ effectSucceedWithVoid,
9390
9441
  effectFnIife,
9391
9442
  effectFnOpportunity,
9392
9443
  redundantSchemaTagIdentifier,