@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/README.md +1 -0
- package/cli.js +55 -4
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +54 -3
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +54 -3
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +54 -3
- package/transform.js.map +1 -1
|
@@ -5488,6 +5488,57 @@ var effectMapVoid = createDiagnostic({
|
|
|
5488
5488
|
})
|
|
5489
5489
|
});
|
|
5490
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
|
+
|
|
5491
5542
|
// src/diagnostics/floatingEffect.ts
|
|
5492
5543
|
var floatingEffect = createDiagnostic({
|
|
5493
5544
|
name: "floatingEffect",
|
|
@@ -5631,8 +5682,7 @@ var globalErrorInEffectCatch = createDiagnostic({
|
|
|
5631
5682
|
);
|
|
5632
5683
|
report({
|
|
5633
5684
|
location: node.expression,
|
|
5634
|
-
messageText: `The 'catch' callback in ${nodeText} returns
|
|
5635
|
-
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.`,
|
|
5636
5686
|
fixes: []
|
|
5637
5687
|
});
|
|
5638
5688
|
}
|
|
@@ -5684,7 +5734,7 @@ var globalErrorInEffectFailure = createDiagnostic({
|
|
|
5684
5734
|
if (hasGlobalError) {
|
|
5685
5735
|
report({
|
|
5686
5736
|
location: node,
|
|
5687
|
-
messageText: `
|
|
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.`,
|
|
5688
5738
|
fixes: []
|
|
5689
5739
|
});
|
|
5690
5740
|
}
|
|
@@ -9391,6 +9441,7 @@ var diagnostics = [
|
|
|
9391
9441
|
globalErrorInEffectFailure,
|
|
9392
9442
|
layerMergeAllWithDependencies,
|
|
9393
9443
|
effectMapVoid,
|
|
9444
|
+
effectSucceedWithVoid,
|
|
9394
9445
|
effectFnIife,
|
|
9395
9446
|
effectFnOpportunity,
|
|
9396
9447
|
redundantSchemaTagIdentifier,
|