@effect/language-service 0.26.0 → 0.27.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 +2 -1
- package/cli.js +74 -2
- package/cli.js.map +1 -1
- package/index.js +127 -5
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +74 -2
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
|
|
|
32
32
|
### Quickinfo
|
|
33
33
|
|
|
34
34
|
- Show the extended type of the current Effect
|
|
35
|
-
- Hovering `yield
|
|
35
|
+
- Hovering `yield*` of `Effect.gen` will show the Effect type parameters
|
|
36
36
|
- Hovering a variable assignment of a type Layer, will show info on how each service got involved
|
|
37
37
|
- Hovering a layer, will attempt to produce a graph
|
|
38
38
|
|
|
@@ -56,6 +56,7 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
|
|
|
56
56
|
- Autocomplete `Effect.fn` with the span name given by the exported member
|
|
57
57
|
- Completions for DurationInput string millis/seconds/etc...
|
|
58
58
|
- Allow to configure packages to be imported with namespace style `import * as Effect from "effect"`
|
|
59
|
+
- Suggest brand when using `Schema.brand`
|
|
59
60
|
- Effect comment directives
|
|
60
61
|
|
|
61
62
|
### Refactors
|
package/cli.js
CHANGED
|
@@ -30284,7 +30284,11 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
30284
30284
|
const diagnostics2 = [];
|
|
30285
30285
|
const codeFixes = [];
|
|
30286
30286
|
const ruleNameLowered = rule.name.toLowerCase();
|
|
30287
|
+
const defaultLevel = pluginOptions.diagnosticSeverity[ruleNameLowered] || rule.severity;
|
|
30287
30288
|
if (skippedRules.indexOf(ruleNameLowered) > -1) return { diagnostics: diagnostics2, codeFixes };
|
|
30289
|
+
if (defaultLevel === "off" && (lineOverrides[ruleNameLowered] || sectionOverrides[ruleNameLowered] || []).length === 0) {
|
|
30290
|
+
return { diagnostics: diagnostics2, codeFixes };
|
|
30291
|
+
}
|
|
30288
30292
|
const fixByDisableNextLine = (_) => ({
|
|
30289
30293
|
fixName: rule.name + "_skipNextLine",
|
|
30290
30294
|
description: "Disable " + rule.name + " for this line",
|
|
@@ -30325,7 +30329,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
30325
30329
|
});
|
|
30326
30330
|
});
|
|
30327
30331
|
for (const emitted of applicableDiagnostics.slice(0)) {
|
|
30328
|
-
let newLevel =
|
|
30332
|
+
let newLevel = defaultLevel;
|
|
30329
30333
|
const lineOverride = (lineOverrides[ruleNameLowered] || []).find(
|
|
30330
30334
|
(_) => _.pos < emitted.node.getStart(sourceFile) && _.end >= emitted.node.getEnd()
|
|
30331
30335
|
);
|
|
@@ -32410,6 +32414,73 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
32410
32414
|
})
|
|
32411
32415
|
});
|
|
32412
32416
|
|
|
32417
|
+
// src/diagnostics/strictBooleanExpressions.ts
|
|
32418
|
+
var strictBooleanExpressions = createDiagnostic({
|
|
32419
|
+
name: "strictBooleanExpressions",
|
|
32420
|
+
code: 17,
|
|
32421
|
+
severity: "off",
|
|
32422
|
+
apply: fn("strictBooleanExpressions.apply")(function* (sourceFile, report) {
|
|
32423
|
+
const ts2 = yield* service2(TypeScriptApi);
|
|
32424
|
+
const typeChecker = yield* service2(TypeCheckerApi);
|
|
32425
|
+
const conditionChecks = /* @__PURE__ */ new WeakMap();
|
|
32426
|
+
const nodeToVisit = [];
|
|
32427
|
+
const appendNodeToVisit = (node) => {
|
|
32428
|
+
nodeToVisit.push(node);
|
|
32429
|
+
return void 0;
|
|
32430
|
+
};
|
|
32431
|
+
ts2.forEachChild(sourceFile, appendNodeToVisit);
|
|
32432
|
+
while (nodeToVisit.length > 0) {
|
|
32433
|
+
const node = nodeToVisit.shift();
|
|
32434
|
+
ts2.forEachChild(node, appendNodeToVisit);
|
|
32435
|
+
const nodes = [];
|
|
32436
|
+
if (ts2.isIfStatement(node)) {
|
|
32437
|
+
conditionChecks.set(node, true);
|
|
32438
|
+
nodes.push(node.expression);
|
|
32439
|
+
} else if (ts2.isWhileStatement(node)) {
|
|
32440
|
+
conditionChecks.set(node, true);
|
|
32441
|
+
nodes.push(node.expression);
|
|
32442
|
+
} else if (ts2.isConditionalExpression(node)) {
|
|
32443
|
+
conditionChecks.set(node, true);
|
|
32444
|
+
nodes.push(node.condition);
|
|
32445
|
+
} else if (ts2.isPrefixUnaryExpression(node) && node.operator === ts2.SyntaxKind.ExclamationToken) {
|
|
32446
|
+
conditionChecks.set(node, true);
|
|
32447
|
+
nodes.push(node.operand);
|
|
32448
|
+
} else if (ts2.isBinaryExpression(node) && node.operatorToken.kind === ts2.SyntaxKind.BarBarToken) {
|
|
32449
|
+
if (conditionChecks.has(node.parent)) conditionChecks.set(node, true);
|
|
32450
|
+
nodes.push(node.left);
|
|
32451
|
+
nodes.push(node.right);
|
|
32452
|
+
} else if (ts2.isBinaryExpression(node) && node.operatorToken.kind === ts2.SyntaxKind.AmpersandAmpersandToken) {
|
|
32453
|
+
if (conditionChecks.has(node.parent)) conditionChecks.set(node, true);
|
|
32454
|
+
nodes.push(node.left);
|
|
32455
|
+
nodes.push(node.right);
|
|
32456
|
+
}
|
|
32457
|
+
for (const nodeToCheck of nodes) {
|
|
32458
|
+
if (!nodeToCheck) continue;
|
|
32459
|
+
if (!conditionChecks.has(nodeToCheck.parent)) continue;
|
|
32460
|
+
const nodeType = typeChecker.getTypeAtLocation(nodeToCheck);
|
|
32461
|
+
const constrainedType = typeChecker.getBaseConstraintOfType(nodeType);
|
|
32462
|
+
let typesToCheck = [constrainedType || nodeType];
|
|
32463
|
+
while (typesToCheck.length > 0) {
|
|
32464
|
+
const type2 = typesToCheck.pop();
|
|
32465
|
+
if (type2.isUnion()) {
|
|
32466
|
+
typesToCheck = typesToCheck.concat(type2.types);
|
|
32467
|
+
continue;
|
|
32468
|
+
}
|
|
32469
|
+
if (type2.flags & ts2.TypeFlags.Boolean) continue;
|
|
32470
|
+
if (type2.flags & ts2.TypeFlags.Never) continue;
|
|
32471
|
+
if (type2.flags & ts2.TypeFlags.BooleanLiteral) continue;
|
|
32472
|
+
const typeName = typeChecker.typeToString(type2);
|
|
32473
|
+
report({
|
|
32474
|
+
node: nodeToCheck,
|
|
32475
|
+
messageText: `Unexpected \`${typeName}\` type in condition, expected strictly a boolean instead.`,
|
|
32476
|
+
fixes: []
|
|
32477
|
+
});
|
|
32478
|
+
}
|
|
32479
|
+
}
|
|
32480
|
+
}
|
|
32481
|
+
})
|
|
32482
|
+
});
|
|
32483
|
+
|
|
32413
32484
|
// src/diagnostics/tryCatchInEffectGen.ts
|
|
32414
32485
|
var tryCatchInEffectGen = createDiagnostic({
|
|
32415
32486
|
name: "tryCatchInEffectGen",
|
|
@@ -32634,7 +32705,8 @@ var diagnostics = [
|
|
|
32634
32705
|
importFromBarrel,
|
|
32635
32706
|
scopeInLayerEffect,
|
|
32636
32707
|
effectInVoidSuccess,
|
|
32637
|
-
unnecessaryPipeChain
|
|
32708
|
+
unnecessaryPipeChain,
|
|
32709
|
+
strictBooleanExpressions
|
|
32638
32710
|
];
|
|
32639
32711
|
|
|
32640
32712
|
// src/cli.ts
|