@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/index.js CHANGED
@@ -3478,6 +3478,8 @@ var defaults = {
3478
3478
  skipLeadingPath: ["src/"]
3479
3479
  }],
3480
3480
  extendedKeyDetection: false,
3481
+ ignoreEffectWarningsInTscExitCode: false,
3482
+ ignoreEffectSuggestionsInTscExitCode: true,
3481
3483
  pipeableMinArgCount: 2,
3482
3484
  effectFn: ["span"],
3483
3485
  layerGraphFollowDepth: 0,
@@ -3503,6 +3505,8 @@ function parse(config) {
3503
3505
  diagnosticsName: isObject(config) && hasProperty(config, "diagnosticsName") && isBoolean(config.diagnosticsName) ? config.diagnosticsName : defaults.diagnosticsName,
3504
3506
  missingDiagnosticNextLine: isObject(config) && hasProperty(config, "missingDiagnosticNextLine") && isString(config.missingDiagnosticNextLine) && isValidSeverityLevel(config.missingDiagnosticNextLine) ? config.missingDiagnosticNextLine : defaults.missingDiagnosticNextLine,
3505
3507
  includeSuggestionsInTsc: isObject(config) && hasProperty(config, "includeSuggestionsInTsc") && isBoolean(config.includeSuggestionsInTsc) ? config.includeSuggestionsInTsc : defaults.includeSuggestionsInTsc,
3508
+ ignoreEffectWarningsInTscExitCode: isObject(config) && hasProperty(config, "ignoreEffectWarningsInTscExitCode") && isBoolean(config.ignoreEffectWarningsInTscExitCode) ? config.ignoreEffectWarningsInTscExitCode : defaults.ignoreEffectWarningsInTscExitCode,
3509
+ ignoreEffectSuggestionsInTscExitCode: isObject(config) && hasProperty(config, "ignoreEffectSuggestionsInTscExitCode") && isBoolean(config.ignoreEffectSuggestionsInTscExitCode) ? config.ignoreEffectSuggestionsInTscExitCode : defaults.ignoreEffectSuggestionsInTscExitCode,
3506
3510
  quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
3507
3511
  quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
3508
3512
  quickinfoMaximumLength: isObject(config) && hasProperty(config, "quickinfoMaximumLength") && isNumber(config.quickinfoMaximumLength) ? config.quickinfoMaximumLength : defaults.quickinfoMaximumLength,
@@ -8958,6 +8962,57 @@ var effectMapVoid = createDiagnostic({
8958
8962
  })
8959
8963
  });
8960
8964
 
8965
+ // src/diagnostics/effectSucceedWithVoid.ts
8966
+ var effectSucceedWithVoid = createDiagnostic({
8967
+ name: "effectSucceedWithVoid",
8968
+ code: 47,
8969
+ description: "Suggests using Effect.void instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
8970
+ severity: "suggestion",
8971
+ apply: fn("effectSucceedWithVoid.apply")(function* (sourceFile, report) {
8972
+ const ts = yield* service(TypeScriptApi);
8973
+ const typeParser = yield* service(TypeParser);
8974
+ const tsUtils = yield* service(TypeScriptUtils);
8975
+ const nodeToVisit = [];
8976
+ const appendNodeToVisit = (node) => {
8977
+ nodeToVisit.push(node);
8978
+ return void 0;
8979
+ };
8980
+ ts.forEachChild(sourceFile, appendNodeToVisit);
8981
+ while (nodeToVisit.length > 0) {
8982
+ const node = nodeToVisit.shift();
8983
+ ts.forEachChild(node, appendNodeToVisit);
8984
+ if (ts.isCallExpression(node)) {
8985
+ const isSucceedCall = yield* pipe(
8986
+ typeParser.isNodeReferenceToEffectModuleApi("succeed")(node.expression),
8987
+ option
8988
+ );
8989
+ if (isSome2(isSucceedCall)) {
8990
+ const argument = node.arguments[0];
8991
+ if (!argument) continue;
8992
+ if (!tsUtils.isVoidExpression(argument)) continue;
8993
+ report({
8994
+ location: node,
8995
+ messageText: "Effect.void can be used instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
8996
+ fixes: [{
8997
+ fixName: "effectSucceedWithVoid_fix",
8998
+ description: "Replace with Effect.void",
8999
+ apply: gen(function* () {
9000
+ const changeTracker = yield* service(ChangeTracker);
9001
+ const effectModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(sourceFile, "effect", "Effect") || "Effect";
9002
+ const newNode = ts.factory.createPropertyAccessExpression(
9003
+ ts.factory.createIdentifier(effectModuleIdentifier),
9004
+ ts.factory.createIdentifier("void")
9005
+ );
9006
+ changeTracker.replaceNode(sourceFile, node, newNode);
9007
+ })
9008
+ }]
9009
+ });
9010
+ }
9011
+ }
9012
+ }
9013
+ })
9014
+ });
9015
+
8961
9016
  // src/diagnostics/floatingEffect.ts
8962
9017
  var floatingEffect = createDiagnostic({
8963
9018
  name: "floatingEffect",
@@ -9101,8 +9156,7 @@ var globalErrorInEffectCatch = createDiagnostic({
9101
9156
  );
9102
9157
  report({
9103
9158
  location: node.expression,
9104
- 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.
9105
- Instead, use tagged errors or custom errors with a discriminator property to get properly type-checked errors.`,
9159
+ 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.`,
9106
9160
  fixes: []
9107
9161
  });
9108
9162
  }
@@ -9154,7 +9208,7 @@ var globalErrorInEffectFailure = createDiagnostic({
9154
9208
  if (hasGlobalError) {
9155
9209
  report({
9156
9210
  location: node,
9157
- 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.`,
9211
+ 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.`,
9158
9212
  fixes: []
9159
9213
  });
9160
9214
  }
@@ -11828,6 +11882,7 @@ var diagnostics = [
11828
11882
  globalErrorInEffectFailure,
11829
11883
  layerMergeAllWithDependencies,
11830
11884
  effectMapVoid,
11885
+ effectSucceedWithVoid,
11831
11886
  effectFnIife,
11832
11887
  effectFnOpportunity,
11833
11888
  redundantSchemaTagIdentifier,