@effect/language-service 0.26.0 → 0.27.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/cli.js CHANGED
@@ -32410,6 +32410,73 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
32410
32410
  })
32411
32411
  });
32412
32412
 
32413
+ // src/diagnostics/strictBooleanExpressions.ts
32414
+ var strictBooleanExpressions = createDiagnostic({
32415
+ name: "strictBooleanExpressions",
32416
+ code: 17,
32417
+ severity: "off",
32418
+ apply: fn("strictBooleanExpressions.apply")(function* (sourceFile, report) {
32419
+ const ts2 = yield* service2(TypeScriptApi);
32420
+ const typeChecker = yield* service2(TypeCheckerApi);
32421
+ const conditionChecks = /* @__PURE__ */ new WeakMap();
32422
+ const nodeToVisit = [];
32423
+ const appendNodeToVisit = (node) => {
32424
+ nodeToVisit.push(node);
32425
+ return void 0;
32426
+ };
32427
+ ts2.forEachChild(sourceFile, appendNodeToVisit);
32428
+ while (nodeToVisit.length > 0) {
32429
+ const node = nodeToVisit.shift();
32430
+ ts2.forEachChild(node, appendNodeToVisit);
32431
+ const nodes = [];
32432
+ if (ts2.isIfStatement(node)) {
32433
+ conditionChecks.set(node, true);
32434
+ nodes.push(node.expression);
32435
+ } else if (ts2.isWhileStatement(node)) {
32436
+ conditionChecks.set(node, true);
32437
+ nodes.push(node.expression);
32438
+ } else if (ts2.isConditionalExpression(node)) {
32439
+ conditionChecks.set(node, true);
32440
+ nodes.push(node.condition);
32441
+ } else if (ts2.isPrefixUnaryExpression(node) && node.operator === ts2.SyntaxKind.ExclamationToken) {
32442
+ conditionChecks.set(node, true);
32443
+ nodes.push(node.operand);
32444
+ } else if (ts2.isBinaryExpression(node) && node.operatorToken.kind === ts2.SyntaxKind.BarBarToken) {
32445
+ if (conditionChecks.has(node.parent)) conditionChecks.set(node, true);
32446
+ nodes.push(node.left);
32447
+ nodes.push(node.right);
32448
+ } else if (ts2.isBinaryExpression(node) && node.operatorToken.kind === ts2.SyntaxKind.AmpersandAmpersandToken) {
32449
+ if (conditionChecks.has(node.parent)) conditionChecks.set(node, true);
32450
+ nodes.push(node.left);
32451
+ nodes.push(node.right);
32452
+ }
32453
+ for (const nodeToCheck of nodes) {
32454
+ if (!nodeToCheck) continue;
32455
+ if (!conditionChecks.has(nodeToCheck.parent)) continue;
32456
+ const nodeType = typeChecker.getTypeAtLocation(nodeToCheck);
32457
+ const constrainedType = typeChecker.getBaseConstraintOfType(nodeType);
32458
+ let typesToCheck = [constrainedType || nodeType];
32459
+ while (typesToCheck.length > 0) {
32460
+ const type2 = typesToCheck.pop();
32461
+ if (type2.isUnion()) {
32462
+ typesToCheck = typesToCheck.concat(type2.types);
32463
+ continue;
32464
+ }
32465
+ if (type2.flags & ts2.TypeFlags.Boolean) continue;
32466
+ if (type2.flags & ts2.TypeFlags.Never) continue;
32467
+ if (type2.flags & ts2.TypeFlags.BooleanLiteral) continue;
32468
+ const typeName = typeChecker.typeToString(type2);
32469
+ report({
32470
+ node: nodeToCheck,
32471
+ messageText: `Unexpected \`${typeName}\` type in condition, expected strictly a boolean instead.`,
32472
+ fixes: []
32473
+ });
32474
+ }
32475
+ }
32476
+ }
32477
+ })
32478
+ });
32479
+
32413
32480
  // src/diagnostics/tryCatchInEffectGen.ts
32414
32481
  var tryCatchInEffectGen = createDiagnostic({
32415
32482
  name: "tryCatchInEffectGen",
@@ -32634,7 +32701,8 @@ var diagnostics = [
32634
32701
  importFromBarrel,
32635
32702
  scopeInLayerEffect,
32636
32703
  effectInVoidSuccess,
32637
- unnecessaryPipeChain
32704
+ unnecessaryPipeChain,
32705
+ strictBooleanExpressions
32638
32706
  ];
32639
32707
 
32640
32708
  // src/cli.ts