@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
package/index.js
CHANGED
|
@@ -8958,6 +8958,57 @@ var effectMapVoid = createDiagnostic({
|
|
|
8958
8958
|
})
|
|
8959
8959
|
});
|
|
8960
8960
|
|
|
8961
|
+
// src/diagnostics/effectSucceedWithVoid.ts
|
|
8962
|
+
var effectSucceedWithVoid = createDiagnostic({
|
|
8963
|
+
name: "effectSucceedWithVoid",
|
|
8964
|
+
code: 47,
|
|
8965
|
+
description: "Suggests using Effect.void instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
|
|
8966
|
+
severity: "suggestion",
|
|
8967
|
+
apply: fn("effectSucceedWithVoid.apply")(function* (sourceFile, report) {
|
|
8968
|
+
const ts = yield* service(TypeScriptApi);
|
|
8969
|
+
const typeParser = yield* service(TypeParser);
|
|
8970
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
8971
|
+
const nodeToVisit = [];
|
|
8972
|
+
const appendNodeToVisit = (node) => {
|
|
8973
|
+
nodeToVisit.push(node);
|
|
8974
|
+
return void 0;
|
|
8975
|
+
};
|
|
8976
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
8977
|
+
while (nodeToVisit.length > 0) {
|
|
8978
|
+
const node = nodeToVisit.shift();
|
|
8979
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
8980
|
+
if (ts.isCallExpression(node)) {
|
|
8981
|
+
const isSucceedCall = yield* pipe(
|
|
8982
|
+
typeParser.isNodeReferenceToEffectModuleApi("succeed")(node.expression),
|
|
8983
|
+
option
|
|
8984
|
+
);
|
|
8985
|
+
if (isSome2(isSucceedCall)) {
|
|
8986
|
+
const argument = node.arguments[0];
|
|
8987
|
+
if (!argument) continue;
|
|
8988
|
+
if (!tsUtils.isVoidExpression(argument)) continue;
|
|
8989
|
+
report({
|
|
8990
|
+
location: node,
|
|
8991
|
+
messageText: "Effect.void can be used instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
|
|
8992
|
+
fixes: [{
|
|
8993
|
+
fixName: "effectSucceedWithVoid_fix",
|
|
8994
|
+
description: "Replace with Effect.void",
|
|
8995
|
+
apply: gen(function* () {
|
|
8996
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
8997
|
+
const effectModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(sourceFile, "effect", "Effect") || "Effect";
|
|
8998
|
+
const newNode = ts.factory.createPropertyAccessExpression(
|
|
8999
|
+
ts.factory.createIdentifier(effectModuleIdentifier),
|
|
9000
|
+
ts.factory.createIdentifier("void")
|
|
9001
|
+
);
|
|
9002
|
+
changeTracker.replaceNode(sourceFile, node, newNode);
|
|
9003
|
+
})
|
|
9004
|
+
}]
|
|
9005
|
+
});
|
|
9006
|
+
}
|
|
9007
|
+
}
|
|
9008
|
+
}
|
|
9009
|
+
})
|
|
9010
|
+
});
|
|
9011
|
+
|
|
8961
9012
|
// src/diagnostics/floatingEffect.ts
|
|
8962
9013
|
var floatingEffect = createDiagnostic({
|
|
8963
9014
|
name: "floatingEffect",
|
|
@@ -9101,8 +9152,7 @@ var globalErrorInEffectCatch = createDiagnostic({
|
|
|
9101
9152
|
);
|
|
9102
9153
|
report({
|
|
9103
9154
|
location: node.expression,
|
|
9104
|
-
messageText: `The 'catch' callback in ${nodeText} returns
|
|
9105
|
-
Instead, use tagged errors or custom errors with a discriminator property to get properly type-checked errors.`,
|
|
9155
|
+
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
9156
|
fixes: []
|
|
9107
9157
|
});
|
|
9108
9158
|
}
|
|
@@ -9154,7 +9204,7 @@ var globalErrorInEffectFailure = createDiagnostic({
|
|
|
9154
9204
|
if (hasGlobalError) {
|
|
9155
9205
|
report({
|
|
9156
9206
|
location: node,
|
|
9157
|
-
messageText: `
|
|
9207
|
+
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
9208
|
fixes: []
|
|
9159
9209
|
});
|
|
9160
9210
|
}
|
|
@@ -11828,6 +11878,7 @@ var diagnostics = [
|
|
|
11828
11878
|
globalErrorInEffectFailure,
|
|
11829
11879
|
layerMergeAllWithDependencies,
|
|
11830
11880
|
effectMapVoid,
|
|
11881
|
+
effectSucceedWithVoid,
|
|
11831
11882
|
effectFnIife,
|
|
11832
11883
|
effectFnOpportunity,
|
|
11833
11884
|
redundantSchemaTagIdentifier,
|