@effect/language-service 0.70.0 → 0.71.1

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.1",
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
@@ -1225,6 +1225,8 @@ var defaults = {
1225
1225
  skipLeadingPath: ["src/"]
1226
1226
  }],
1227
1227
  extendedKeyDetection: false,
1228
+ ignoreEffectWarningsInTscExitCode: false,
1229
+ ignoreEffectSuggestionsInTscExitCode: true,
1228
1230
  pipeableMinArgCount: 2,
1229
1231
  effectFn: ["span"],
1230
1232
  layerGraphFollowDepth: 0,
@@ -1250,6 +1252,8 @@ function parse(config) {
1250
1252
  diagnosticsName: isObject(config) && hasProperty(config, "diagnosticsName") && isBoolean(config.diagnosticsName) ? config.diagnosticsName : defaults.diagnosticsName,
1251
1253
  missingDiagnosticNextLine: isObject(config) && hasProperty(config, "missingDiagnosticNextLine") && isString(config.missingDiagnosticNextLine) && isValidSeverityLevel(config.missingDiagnosticNextLine) ? config.missingDiagnosticNextLine : defaults.missingDiagnosticNextLine,
1252
1254
  includeSuggestionsInTsc: isObject(config) && hasProperty(config, "includeSuggestionsInTsc") && isBoolean(config.includeSuggestionsInTsc) ? config.includeSuggestionsInTsc : defaults.includeSuggestionsInTsc,
1255
+ ignoreEffectWarningsInTscExitCode: isObject(config) && hasProperty(config, "ignoreEffectWarningsInTscExitCode") && isBoolean(config.ignoreEffectWarningsInTscExitCode) ? config.ignoreEffectWarningsInTscExitCode : defaults.ignoreEffectWarningsInTscExitCode,
1256
+ ignoreEffectSuggestionsInTscExitCode: isObject(config) && hasProperty(config, "ignoreEffectSuggestionsInTscExitCode") && isBoolean(config.ignoreEffectSuggestionsInTscExitCode) ? config.ignoreEffectSuggestionsInTscExitCode : defaults.ignoreEffectSuggestionsInTscExitCode,
1253
1257
  quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
1254
1258
  quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
1255
1259
  quickinfoMaximumLength: isObject(config) && hasProperty(config, "quickinfoMaximumLength") && isNumber(config.quickinfoMaximumLength) ? config.quickinfoMaximumLength : defaults.quickinfoMaximumLength,
@@ -5484,6 +5488,57 @@ var effectMapVoid = createDiagnostic({
5484
5488
  })
5485
5489
  });
5486
5490
 
5491
+ // src/diagnostics/effectSucceedWithVoid.ts
5492
+ var effectSucceedWithVoid = createDiagnostic({
5493
+ name: "effectSucceedWithVoid",
5494
+ code: 47,
5495
+ description: "Suggests using Effect.void instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
5496
+ severity: "suggestion",
5497
+ apply: fn("effectSucceedWithVoid.apply")(function* (sourceFile, report) {
5498
+ const ts = yield* service(TypeScriptApi);
5499
+ const typeParser = yield* service(TypeParser);
5500
+ const tsUtils = yield* service(TypeScriptUtils);
5501
+ const nodeToVisit = [];
5502
+ const appendNodeToVisit = (node) => {
5503
+ nodeToVisit.push(node);
5504
+ return void 0;
5505
+ };
5506
+ ts.forEachChild(sourceFile, appendNodeToVisit);
5507
+ while (nodeToVisit.length > 0) {
5508
+ const node = nodeToVisit.shift();
5509
+ ts.forEachChild(node, appendNodeToVisit);
5510
+ if (ts.isCallExpression(node)) {
5511
+ const isSucceedCall = yield* pipe(
5512
+ typeParser.isNodeReferenceToEffectModuleApi("succeed")(node.expression),
5513
+ option
5514
+ );
5515
+ if (isSome2(isSucceedCall)) {
5516
+ const argument = node.arguments[0];
5517
+ if (!argument) continue;
5518
+ if (!tsUtils.isVoidExpression(argument)) continue;
5519
+ report({
5520
+ location: node,
5521
+ messageText: "Effect.void can be used instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
5522
+ fixes: [{
5523
+ fixName: "effectSucceedWithVoid_fix",
5524
+ description: "Replace with Effect.void",
5525
+ apply: gen(function* () {
5526
+ const changeTracker = yield* service(ChangeTracker);
5527
+ const effectModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(sourceFile, "effect", "Effect") || "Effect";
5528
+ const newNode = ts.factory.createPropertyAccessExpression(
5529
+ ts.factory.createIdentifier(effectModuleIdentifier),
5530
+ ts.factory.createIdentifier("void")
5531
+ );
5532
+ changeTracker.replaceNode(sourceFile, node, newNode);
5533
+ })
5534
+ }]
5535
+ });
5536
+ }
5537
+ }
5538
+ }
5539
+ })
5540
+ });
5541
+
5487
5542
  // src/diagnostics/floatingEffect.ts
5488
5543
  var floatingEffect = createDiagnostic({
5489
5544
  name: "floatingEffect",
@@ -5627,8 +5682,7 @@ var globalErrorInEffectCatch = createDiagnostic({
5627
5682
  );
5628
5683
  report({
5629
5684
  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.`,
5685
+ 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
5686
  fixes: []
5633
5687
  });
5634
5688
  }
@@ -5680,7 +5734,7 @@ var globalErrorInEffectFailure = createDiagnostic({
5680
5734
  if (hasGlobalError) {
5681
5735
  report({
5682
5736
  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.`,
5737
+ 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
5738
  fixes: []
5685
5739
  });
5686
5740
  }
@@ -9387,6 +9441,7 @@ var diagnostics = [
9387
9441
  globalErrorInEffectFailure,
9388
9442
  layerMergeAllWithDependencies,
9389
9443
  effectMapVoid,
9444
+ effectSucceedWithVoid,
9390
9445
  effectFnIife,
9391
9446
  effectFnOpportunity,
9392
9447
  redundantSchemaTagIdentifier,