@noego/trust 0.5.0-dev.3 → 0.5.0-dev.4

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.
@@ -17,6 +17,9 @@ import {
17
17
  REDUNDANT_GUARD_MESSAGES,
18
18
  REDUNDANT_GUARD_ORIGIN,
19
19
  REDUNDANT_GUARD_RULE,
20
+ RESULT_CONDITION_MESSAGE,
21
+ RESULT_CONDITION_ORIGIN,
22
+ RESULT_CONDITION_RULE,
20
23
  THROW_MESSAGES,
21
24
  THROW_ORIGIN,
22
25
  THROW_RULE,
@@ -44,7 +47,7 @@ import {
44
47
  realpathOrSelf,
45
48
  svelteFor,
46
49
  trustDirectivesIn
47
- } from "./chunk-PMIYTMMA.js";
50
+ } from "./chunk-6YBPW4NP.js";
48
51
 
49
52
  // src/core/guard.ts
50
53
  function unparen(ts, node) {
@@ -1530,6 +1533,9 @@ function conditionOperands(ts, node) {
1530
1533
  function isPromiseCondition(checker, operand) {
1531
1534
  return isAlwaysThenable(checker, checker.getTypeAtLocation(operand), operand);
1532
1535
  }
1536
+ function isResultCondition(checker, policy, operand) {
1537
+ return policy.isResultType(checker.getTypeAtLocation(operand));
1538
+ }
1533
1539
  function returnsThenable(checker, type, node) {
1534
1540
  return unionParts(type).some(
1535
1541
  (part) => part.getCallSignatures().some((signature) => isSometimesThenable(checker, signature.getReturnType(), node))
@@ -3154,6 +3160,9 @@ function checkSourceFileWithAccepted(options) {
3154
3160
  if (!acceptance) report(found.node, found.rule, found.origin, found.message);
3155
3161
  else accepted.push({ finding: findingAt(found.node.getStart(sourceFile), found.rule, found.origin, found.message), text: found.node.getText(sourceFile), acceptance });
3156
3162
  }
3163
+ for (const operand of conditionOperands(ts, node)) {
3164
+ if (isResultCondition(checker, policy, operand)) report(operand, RESULT_CONDITION_RULE, RESULT_CONDITION_ORIGIN, RESULT_CONDITION_MESSAGE);
3165
+ }
3157
3166
  if (claimContext) for (const claim2 of typeClaimsAt(node, claimContext)) reportClaim(claim2);
3158
3167
  const value = valueContext ? untrustedValueAt(node, valueContext) : null;
3159
3168
  if (value?.outcome === "finding") report(node, UNTRUSTED_VALUE_RULE, value.origin, untrustedValueMessage(value));
@@ -3234,4 +3243,4 @@ export {
3234
3243
  checkSourceFile,
3235
3244
  checkSourceFileWithAccepted
3236
3245
  };
3237
- //# sourceMappingURL=chunk-EPWU2Q4U.js.map
3246
+ //# sourceMappingURL=chunk-LJJDRFO7.js.map