@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/README.md +3 -0
- package/cli.js +113 -7
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +80 -5
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +58 -3
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +58 -3
- package/transform.js.map +1 -1
|
@@ -22,7 +22,8 @@ var effect_lsp_patch_utils_exports = {};
|
|
|
22
22
|
__export(effect_lsp_patch_utils_exports, {
|
|
23
23
|
appendMetadataRelationError: () => appendMetadataRelationError,
|
|
24
24
|
checkSourceFileWorker: () => checkSourceFileWorker,
|
|
25
|
-
clearSourceFileEffectMetadata: () => clearSourceFileEffectMetadata
|
|
25
|
+
clearSourceFileEffectMetadata: () => clearSourceFileEffectMetadata,
|
|
26
|
+
extractDiagnosticsForExitStatus: () => extractDiagnosticsForExitStatus
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(effect_lsp_patch_utils_exports);
|
|
28
29
|
|
|
@@ -1224,6 +1225,8 @@ var defaults = {
|
|
|
1224
1225
|
skipLeadingPath: ["src/"]
|
|
1225
1226
|
}],
|
|
1226
1227
|
extendedKeyDetection: false,
|
|
1228
|
+
ignoreEffectWarningsInTscExitCode: false,
|
|
1229
|
+
ignoreEffectSuggestionsInTscExitCode: true,
|
|
1227
1230
|
pipeableMinArgCount: 2,
|
|
1228
1231
|
effectFn: ["span"],
|
|
1229
1232
|
layerGraphFollowDepth: 0,
|
|
@@ -1249,6 +1252,8 @@ function parse(config) {
|
|
|
1249
1252
|
diagnosticsName: isObject(config) && hasProperty(config, "diagnosticsName") && isBoolean(config.diagnosticsName) ? config.diagnosticsName : defaults.diagnosticsName,
|
|
1250
1253
|
missingDiagnosticNextLine: isObject(config) && hasProperty(config, "missingDiagnosticNextLine") && isString(config.missingDiagnosticNextLine) && isValidSeverityLevel(config.missingDiagnosticNextLine) ? config.missingDiagnosticNextLine : defaults.missingDiagnosticNextLine,
|
|
1251
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,
|
|
1252
1257
|
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
|
|
1253
1258
|
quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
|
|
1254
1259
|
quickinfoMaximumLength: isObject(config) && hasProperty(config, "quickinfoMaximumLength") && isNumber(config.quickinfoMaximumLength) ? config.quickinfoMaximumLength : defaults.quickinfoMaximumLength,
|
|
@@ -5488,6 +5493,57 @@ var effectMapVoid = createDiagnostic({
|
|
|
5488
5493
|
})
|
|
5489
5494
|
});
|
|
5490
5495
|
|
|
5496
|
+
// src/diagnostics/effectSucceedWithVoid.ts
|
|
5497
|
+
var effectSucceedWithVoid = createDiagnostic({
|
|
5498
|
+
name: "effectSucceedWithVoid",
|
|
5499
|
+
code: 47,
|
|
5500
|
+
description: "Suggests using Effect.void instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
|
|
5501
|
+
severity: "suggestion",
|
|
5502
|
+
apply: fn("effectSucceedWithVoid.apply")(function* (sourceFile, report) {
|
|
5503
|
+
const ts = yield* service(TypeScriptApi);
|
|
5504
|
+
const typeParser = yield* service(TypeParser);
|
|
5505
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
5506
|
+
const nodeToVisit = [];
|
|
5507
|
+
const appendNodeToVisit = (node) => {
|
|
5508
|
+
nodeToVisit.push(node);
|
|
5509
|
+
return void 0;
|
|
5510
|
+
};
|
|
5511
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
5512
|
+
while (nodeToVisit.length > 0) {
|
|
5513
|
+
const node = nodeToVisit.shift();
|
|
5514
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
5515
|
+
if (ts.isCallExpression(node)) {
|
|
5516
|
+
const isSucceedCall = yield* pipe(
|
|
5517
|
+
typeParser.isNodeReferenceToEffectModuleApi("succeed")(node.expression),
|
|
5518
|
+
option
|
|
5519
|
+
);
|
|
5520
|
+
if (isSome2(isSucceedCall)) {
|
|
5521
|
+
const argument = node.arguments[0];
|
|
5522
|
+
if (!argument) continue;
|
|
5523
|
+
if (!tsUtils.isVoidExpression(argument)) continue;
|
|
5524
|
+
report({
|
|
5525
|
+
location: node,
|
|
5526
|
+
messageText: "Effect.void can be used instead of Effect.succeed(undefined) or Effect.succeed(void 0)",
|
|
5527
|
+
fixes: [{
|
|
5528
|
+
fixName: "effectSucceedWithVoid_fix",
|
|
5529
|
+
description: "Replace with Effect.void",
|
|
5530
|
+
apply: gen(function* () {
|
|
5531
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
5532
|
+
const effectModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(sourceFile, "effect", "Effect") || "Effect";
|
|
5533
|
+
const newNode = ts.factory.createPropertyAccessExpression(
|
|
5534
|
+
ts.factory.createIdentifier(effectModuleIdentifier),
|
|
5535
|
+
ts.factory.createIdentifier("void")
|
|
5536
|
+
);
|
|
5537
|
+
changeTracker.replaceNode(sourceFile, node, newNode);
|
|
5538
|
+
})
|
|
5539
|
+
}]
|
|
5540
|
+
});
|
|
5541
|
+
}
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
})
|
|
5545
|
+
});
|
|
5546
|
+
|
|
5491
5547
|
// src/diagnostics/floatingEffect.ts
|
|
5492
5548
|
var floatingEffect = createDiagnostic({
|
|
5493
5549
|
name: "floatingEffect",
|
|
@@ -5631,8 +5687,7 @@ var globalErrorInEffectCatch = createDiagnostic({
|
|
|
5631
5687
|
);
|
|
5632
5688
|
report({
|
|
5633
5689
|
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.`,
|
|
5690
|
+
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
5691
|
fixes: []
|
|
5637
5692
|
});
|
|
5638
5693
|
}
|
|
@@ -5684,7 +5739,7 @@ var globalErrorInEffectFailure = createDiagnostic({
|
|
|
5684
5739
|
if (hasGlobalError) {
|
|
5685
5740
|
report({
|
|
5686
5741
|
location: node,
|
|
5687
|
-
messageText: `
|
|
5742
|
+
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
5743
|
fixes: []
|
|
5689
5744
|
});
|
|
5690
5745
|
}
|
|
@@ -9391,6 +9446,7 @@ var diagnostics = [
|
|
|
9391
9446
|
globalErrorInEffectFailure,
|
|
9392
9447
|
layerMergeAllWithDependencies,
|
|
9393
9448
|
effectMapVoid,
|
|
9449
|
+
effectSucceedWithVoid,
|
|
9394
9450
|
effectFnIife,
|
|
9395
9451
|
effectFnOpportunity,
|
|
9396
9452
|
redundantSchemaTagIdentifier,
|
|
@@ -9460,10 +9516,29 @@ function checkSourceFileWorker(tsInstance, program, sourceFile, compilerOptions,
|
|
|
9460
9516
|
map3(addDiagnostic)
|
|
9461
9517
|
);
|
|
9462
9518
|
}
|
|
9519
|
+
function extractDiagnosticsForExitStatus(tsInstance, program, diagnostics2, _moduleName) {
|
|
9520
|
+
const options = extractEffectLspOptions(program.getCompilerOptions());
|
|
9521
|
+
const parsedOptions = parse(options);
|
|
9522
|
+
let newDiagnostics = diagnostics2;
|
|
9523
|
+
if (parsedOptions.ignoreEffectSuggestionsInTscExitCode) {
|
|
9524
|
+
newDiagnostics = filter(
|
|
9525
|
+
newDiagnostics,
|
|
9526
|
+
(_) => !(_.source === "effect" && _.category === tsInstance.DiagnosticCategory.Message)
|
|
9527
|
+
);
|
|
9528
|
+
}
|
|
9529
|
+
if (parsedOptions.ignoreEffectWarningsInTscExitCode) {
|
|
9530
|
+
newDiagnostics = filter(
|
|
9531
|
+
newDiagnostics,
|
|
9532
|
+
(_) => !(_.source === "effect" && _.category === tsInstance.DiagnosticCategory.Warning)
|
|
9533
|
+
);
|
|
9534
|
+
}
|
|
9535
|
+
return newDiagnostics;
|
|
9536
|
+
}
|
|
9463
9537
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9464
9538
|
0 && (module.exports = {
|
|
9465
9539
|
appendMetadataRelationError,
|
|
9466
9540
|
checkSourceFileWorker,
|
|
9467
|
-
clearSourceFileEffectMetadata
|
|
9541
|
+
clearSourceFileEffectMetadata,
|
|
9542
|
+
extractDiagnosticsForExitStatus
|
|
9468
9543
|
});
|
|
9469
9544
|
//# sourceMappingURL=effect-lsp-patch-utils.js.map
|