@noego/trust 0.5.0-dev.5 → 0.5.0-dev.6

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.
@@ -80,6 +80,12 @@ interface TrustConfig {
80
80
  }
81
81
  /** An opt-in rule's switch. */
82
82
  type RuleSwitch = 'on' | 'off';
83
+ /**
84
+ * `result-lookalike`'s setting: `strict` (default) reports only in strict files (`trust check --strict`, or the
85
+ * config's `strict` globs), as errors; `on` reports in every checked file (an error where the file is strict, a
86
+ * warning elsewhere); `off` reports nothing.
87
+ */
88
+ type ResultLookalikeSetting = 'off' | 'strict' | 'on';
83
89
  /** Which callback parameters are untrusted-value sources (see the file comment). */
84
90
  type UntrustedCallbacks = 'off' | 'inline' | 'all';
85
91
  /** The rules that are off unless a config turns them on. */
@@ -89,6 +95,7 @@ interface TrustRuleSettings {
89
95
  readonly 'untrusted-value': RuleSwitch;
90
96
  readonly 'dropped-result': RuleSwitch;
91
97
  readonly 'redundant-guard': RuleSwitch;
98
+ readonly 'result-lookalike': ResultLookalikeSetting;
92
99
  readonly untrustedCallbacks: UntrustedCallbacks;
93
100
  }
94
101
  /** What a config that sets nothing gets: the opt-in rules off, callbacks as today. */
@@ -47,10 +47,11 @@ import {
47
47
  isTrustPackageFile,
48
48
  nodeBelow,
49
49
  realpathOrSelf,
50
+ reportsResultLookalikes,
50
51
  resultLookalikeMessage,
51
52
  svelteFor,
52
53
  trustDirectivesIn
53
- } from "./chunk-GJUWPZZJ.js";
54
+ } from "./chunk-RVTPDLEW.js";
54
55
 
55
56
  // src/core/guard.ts
56
57
  function unparen(ts, node) {
@@ -3213,9 +3214,11 @@ function checkSourceFileWithAccepted(options) {
3213
3214
  };
3214
3215
  visit(sourceFile);
3215
3216
  const strict = options.strict ?? isStrictByConfig(config, sourceFile.fileName);
3216
- for (const lookalike of resultLookalikesIn(ts, sourceFile)) {
3217
- const finding = findingAt(lookalike.start, RESULT_LOOKALIKE_RULE, RESULT_LOOKALIKE_ORIGIN, resultLookalikeMessage(lookalike.name));
3218
- findings.push(strict ? finding : { ...finding, severity: "warning" });
3217
+ if (reportsResultLookalikes(config, strict)) {
3218
+ for (const lookalike of resultLookalikesIn(ts, sourceFile)) {
3219
+ const finding = findingAt(lookalike.start, RESULT_LOOKALIKE_RULE, RESULT_LOOKALIKE_ORIGIN, resultLookalikeMessage(lookalike.name));
3220
+ findings.push(strict ? finding : { ...finding, severity: "warning" });
3221
+ }
3219
3222
  }
3220
3223
  if (isRuleEnabled(config, DROPPED_RESULT_RULE)) {
3221
3224
  for (const dropped of droppedResultsIn(sourceFile, droppedResultContext(ts, checker, policy))) {
@@ -3287,4 +3290,4 @@ export {
3287
3290
  checkSourceFile,
3288
3291
  checkSourceFileWithAccepted
3289
3292
  };
3290
- //# sourceMappingURL=chunk-EJ4O7BCA.js.map
3293
+ //# sourceMappingURL=chunk-BHBYQYJJ.js.map