@noego/trust 0.4.0 → 0.5.0-dev.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.
Files changed (143) hide show
  1. package/README.md +962 -14
  2. package/dist/baseline-Bkav9mS0.d.ts +380 -0
  3. package/dist/chunk-7PY2Q6OX.js +3016 -0
  4. package/dist/chunk-7PY2Q6OX.js.map +1 -0
  5. package/dist/chunk-UG6D3V4M.js +6990 -0
  6. package/dist/chunk-UG6D3V4M.js.map +1 -0
  7. package/dist/chunk-XXLWC5DB.js +112 -0
  8. package/dist/chunk-XXLWC5DB.js.map +1 -0
  9. package/dist/cli/index.js +1391 -65
  10. package/dist/cli/index.js.map +1 -1
  11. package/dist/cli/wasm-worker.js +257 -0
  12. package/dist/cli/wasm-worker.js.map +1 -0
  13. package/dist/core/index.d.ts +129 -0
  14. package/dist/core/index.js +115 -0
  15. package/dist/core/index.js.map +1 -0
  16. package/dist/eslint/index.d.ts +77 -167
  17. package/dist/eslint/index.js +320 -32
  18. package/dist/eslint/index.js.map +1 -1
  19. package/dist/licenses/@jridgewell__resolve-uri/LICENSE +19 -0
  20. package/dist/licenses/@jridgewell__sourcemap-codec/LICENSE +19 -0
  21. package/dist/licenses/@jridgewell__trace-mapping/LICENSE +19 -0
  22. package/dist/licenses/JS-DEPENDENCIES.json +83 -0
  23. package/dist/licenses/balanced-match/LICENSE.md +23 -0
  24. package/dist/licenses/brace-expansion/LICENSE +23 -0
  25. package/dist/licenses/dedent-js/LICENSE +19 -0
  26. package/dist/licenses/minimatch/LICENSE.md +55 -0
  27. package/dist/licenses/scule/LICENSE +21 -0
  28. package/dist/licenses/svelte2tsx/LICENSE +21 -0
  29. package/dist/native/licenses/CARGO-DEPENDENCIES.json +479 -0
  30. package/dist/native/licenses/LICENSE-trust.txt +15 -0
  31. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-0BSD +12 -0
  32. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-APACHE +201 -0
  33. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-MIT +23 -0
  34. package/dist/native/licenses/cargo/aho-corasick-1.1.5/COPYING +3 -0
  35. package/dist/native/licenses/cargo/aho-corasick-1.1.5/LICENSE-MIT +21 -0
  36. package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-APACHE +201 -0
  37. package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-MIT +25 -0
  38. package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-APACHE +201 -0
  39. package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-MIT +25 -0
  40. package/dist/native/licenses/cargo/bstr-1.13.1/COPYING +8 -0
  41. package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-APACHE +201 -0
  42. package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-MIT +21 -0
  43. package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-APACHE +201 -0
  44. package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-MIT +25 -0
  45. package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-APACHE +201 -0
  46. package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-MIT +25 -0
  47. package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-APACHE +202 -0
  48. package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-MIT +21 -0
  49. package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-APACHE +201 -0
  50. package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-MIT +25 -0
  51. package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-APACHE +201 -0
  52. package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-MIT +25 -0
  53. package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-APACHE +201 -0
  54. package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-MIT +25 -0
  55. package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-APACHE +201 -0
  56. package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-MIT +25 -0
  57. package/dist/native/licenses/cargo/globset-0.4.20/COPYING +3 -0
  58. package/dist/native/licenses/cargo/globset-0.4.20/LICENSE-MIT +21 -0
  59. package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-APACHE +201 -0
  60. package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-MIT +25 -0
  61. package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-APACHE +201 -0
  62. package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-MIT +25 -0
  63. package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-APACHE +176 -0
  64. package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-MIT +23 -0
  65. package/dist/native/licenses/cargo/jiff-0.2.37/COPYING +3 -0
  66. package/dist/native/licenses/cargo/jiff-0.2.37/LICENSE-MIT +21 -0
  67. package/dist/native/licenses/cargo/jiff-core-0.1.1/COPYING +3 -0
  68. package/dist/native/licenses/cargo/jiff-core-0.1.1/LICENSE-MIT +21 -0
  69. package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/COPYING +3 -0
  70. package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/LICENSE-MIT +21 -0
  71. package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/COPYING +3 -0
  72. package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/LICENSE-MIT +21 -0
  73. package/dist/native/licenses/cargo/log-0.4.34/LICENSE-APACHE +201 -0
  74. package/dist/native/licenses/cargo/log-0.4.34/LICENSE-MIT +25 -0
  75. package/dist/native/licenses/cargo/lzma-rust2-0.21.0/LICENSE +201 -0
  76. package/dist/native/licenses/cargo/memchr-2.8.2/COPYING +3 -0
  77. package/dist/native/licenses/cargo/memchr-2.8.2/LICENSE-MIT +21 -0
  78. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE +25 -0
  79. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-APACHE.md +177 -0
  80. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-MIT.md +24 -0
  81. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-ZLIB.md +14 -0
  82. package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-APACHE +201 -0
  83. package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-MIT +25 -0
  84. package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-APACHE +201 -0
  85. package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-MIT +25 -0
  86. package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-APACHE +201 -0
  87. package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-MIT +25 -0
  88. package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
  89. package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-MIT +23 -0
  90. package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-APACHE +176 -0
  91. package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-MIT +23 -0
  92. package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-APACHE +201 -0
  93. package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-MIT +25 -0
  94. package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-APACHE +201 -0
  95. package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-MIT +25 -0
  96. package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-APACHE +176 -0
  97. package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-MIT +23 -0
  98. package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-APACHE +176 -0
  99. package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-BOOST +23 -0
  100. package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-APACHE +176 -0
  101. package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-MIT +23 -0
  102. package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-APACHE +176 -0
  103. package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-MIT +23 -0
  104. package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-APACHE +176 -0
  105. package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-MIT +23 -0
  106. package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-APACHE +176 -0
  107. package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-MIT +23 -0
  108. package/dist/native/licenses/cargo/simd-adler32-0.3.10/LICENSE.md +21 -0
  109. package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-APACHE +201 -0
  110. package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-MIT +25 -0
  111. package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-APACHE +176 -0
  112. package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-MIT +23 -0
  113. package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-APACHE +176 -0
  114. package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-MIT +23 -0
  115. package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-APACHE +176 -0
  116. package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-MIT +23 -0
  117. package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-APACHE +176 -0
  118. package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-MIT +23 -0
  119. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-APACHE +176 -0
  120. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-MIT +23 -0
  121. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-UNICODE +39 -0
  122. package/dist/native/licenses/cargo/xxhash-rust-0.8.15/LICENSE +23 -0
  123. package/dist/native/licenses/cargo/zlib-rs-0.6.8/LICENSE +19 -0
  124. package/dist/native/licenses/cargo/zmij-1.0.23/LICENSE-MIT +23 -0
  125. package/dist/native/licenses/ts-rust/LICENSE +21 -0
  126. package/dist/native/licenses/ts-rust/NOTICE.md +53 -0
  127. package/dist/native/licenses/ts-rust/licenses/Go-LICENSE.txt +27 -0
  128. package/dist/native/licenses/ts-rust/licenses/TypeScript-LICENSE.txt +55 -0
  129. package/dist/native/licenses/ts-rust/licenses/TypeScript-NOTICE.txt +405 -0
  130. package/dist/native/licenses/ts-rust/licenses/Unicode-LICENSE.txt +39 -0
  131. package/dist/native/licenses/ts-rust/licenses/vscode-languageserver-node-LICENSE.txt +18 -0
  132. package/dist/native/licenses/typescript/LICENSE.txt +55 -0
  133. package/dist/native/licenses/typescript/ThirdPartyNoticeText.txt +193 -0
  134. package/dist/native/licenses/typescript/manifest.json +105 -0
  135. package/dist/native/trust_native_wasm.wasm +0 -0
  136. package/dist/svelte2tsx/index.cjs +7064 -0
  137. package/dist/svelte2tsx/svelte-jsx-v4.d.ts +230 -0
  138. package/dist/svelte2tsx/svelte-jsx.d.ts +1492 -0
  139. package/dist/svelte2tsx/svelte-shims-v4.d.ts +290 -0
  140. package/dist/svelte2tsx/svelte-shims.d.ts +305 -0
  141. package/package.json +31 -8
  142. package/dist/chunk-YJYGTNJD.js +0 -2168
  143. package/dist/chunk-YJYGTNJD.js.map +0 -1
@@ -1,103 +1,20 @@
1
1
  import * as eslint from 'eslint';
2
- import { ESLint, Linter } from 'eslint';
2
+ import { Linter, ESLint } from 'eslint';
3
+ import { g as Zones, O as OriginResolver, C as TrustRuleSettings, T as TypeScript, D as TrustConfig, E as OriginInfo, G as CatchProblem } from '../baseline-Bkav9mS0.js';
4
+ export { H as ACCEPT_DIRECTIVE, I as ACCEPT_DIRECTIVE_MESSAGES, B as BaselineCounts, b as BaselineDelta, d as BaselineScope, J as CATCH_ORIGIN, K as DEFAULT_RULE_SETTINGS, L as DIRECTIVE_ORIGIN, M as DROPPED_RESULT_MESSAGES, N as DROPPED_RESULT_RULE, P as DroppedResultOrigin, F as Finding, Q as LoadTrustConfigOptions, R as OptInRule, S as REDUNDANT_GUARD_MESSAGES, U as REDUNDANT_GUARD_ORIGIN, V as REDUNDANT_GUARD_RULE, X as RuleSwitch, Y as THROW_MESSAGES, _ as THROW_RULE, $ as TYPE_CLAIM_KINDS, a0 as TYPE_CLAIM_MESSAGES, a1 as TYPE_CLAIM_RULE, a2 as TrustConfigError, a3 as TrustEntry, a4 as TrustLevel, a as TsconfigMapping, a5 as TypeClaimOrigin, a6 as UNANALYZABLE_ORIGIN, a7 as UNTRUSTED_CALL_MESSAGES, a8 as UNTRUSTED_CALL_RULE, a9 as UNTRUSTED_VALUE_MESSAGES, aa as UNTRUSTED_VALUE_RULE, ab as UntrustedCallbacks, ac as UntrustedEntry, ad as VALIDATOR_DIRECTIVE, W as WHOLE_BASELINE, f as Zone, Z as ZoneGroup, h as compareToBaseline, i as countFindings, ae as effectiveTrustList, af as effectiveTypeTrustList, ag as isInsideValidator, ah as isMarkedValidator, ai as isRuleEnabled, aj as loadTrustConfig, ak as normalizeOrigin, u as parseBaseline, y as serializeBaseline, A as updateBaseline } from '../baseline-Bkav9mS0.js';
3
5
  import * as TS from 'typescript';
4
6
 
5
- type Zone = 'checked' | 'passthrough' | 'ignore' | 'external';
6
- interface ZoneGroup {
7
- /** Config file that declared the patterns (for error messages). */
8
- readonly source: string;
9
- /** Realpath of the directory the patterns are relative to. */
10
- readonly baseDir: string;
11
- readonly patterns: readonly string[];
12
- }
13
- declare class Zones {
14
- /** Realpath of the project root (directory of the leaf trust config). */
15
- readonly rootDir: string;
16
- private readonly passthrough;
17
- private readonly ignore;
18
- private readonly cache;
19
- constructor(
20
- /** Realpath of the project root (directory of the leaf trust config). */
21
- rootDir: string, passthrough: readonly ZoneGroup[], ignore: readonly ZoneGroup[]);
22
- /** Zone of a file. Ignore wins over passthrough; files outside the root or in node_modules are external. */
23
- zoneOf(fileName: string): Zone;
24
- /** Project-relative posix path (for `local:` origins and baselines), or the absolute path when outside. */
25
- relativePath(fileName: string): string;
26
- private compute;
27
- }
28
-
29
- type TrustEntry = string | {
30
- readonly origin: string;
31
- readonly reason?: string;
32
- };
33
- interface TrustLevel {
34
- /** Config file path or `preset:<name>`. */
35
- readonly source: string;
36
- readonly trust: readonly string[];
37
- readonly distrust: readonly string[];
38
- }
39
- interface TrustConfig {
40
- /** Absolute path of the leaf config file. */
41
- readonly file: string;
42
- /** Realpath of the leaf config file's directory: the project root for zones and `local:` origins. */
43
- readonly rootDir: string;
44
- /** Leaf first, root preset last. */
45
- readonly levels: readonly TrustLevel[];
46
- readonly passthrough: readonly ZoneGroup[];
47
- readonly ignore: readonly ZoneGroup[];
48
- }
49
- interface LoadTrustConfigOptions {
50
- /** Check that every glob matches at least one file (default true). */
51
- readonly validateGlobs?: boolean;
52
- }
53
- declare class TrustConfigError extends Error {
54
- readonly name = "TrustConfigError";
55
- }
56
- /**
57
- * Trust entries are matched exactly as written. Origin namespaces:
58
- * js:JSON.parse JavaScript built-ins (TypeScript lib)
59
- * node:fs.existsSync Node built-in modules (the `node:` import specifier)
60
- * node:global.process.cwd Node globals
61
- * zod.object, @scope/pkg.fn npm packages (bare package name)
62
- */
63
- declare function normalizeOrigin(origin: string): string;
64
- /** Loads and validates a trust config file and its `extend` chain. Throws TrustConfigError. */
65
- declare function loadTrustConfig(configFile: string, options?: LoadTrustConfigOptions): TrustConfig;
66
- /** Union of every trust entry in the chain (for tooling and tests). */
67
- declare function effectiveTrustList(config: TrustConfig): string[];
68
-
69
7
  interface PresetDefinition {
70
8
  readonly $comment?: string;
71
- readonly extend?: string;
9
+ /** A preset name, or preset names applied left to right (a later one overrides an earlier one). */
10
+ readonly extend?: string | readonly string[];
72
11
  readonly trust?: readonly string[];
73
12
  readonly distrust?: readonly string[];
13
+ readonly trust_type?: readonly string[];
14
+ readonly distrust_type?: readonly string[];
74
15
  }
75
16
  declare const PRESETS: Readonly<Record<string, PresetDefinition>>;
76
17
 
77
- type TypeScript = typeof TS;
78
-
79
- type OriginInfo = {
80
- readonly kind: 'external';
81
- readonly origin: string;
82
- readonly base: string;
83
- readonly fileName: string;
84
- } | {
85
- readonly kind: 'local';
86
- readonly zone: Exclude<Zone, 'external'>;
87
- readonly origin: string;
88
- readonly fileName: string;
89
- };
90
- declare class OriginResolver {
91
- private readonly ts;
92
- private readonly zones;
93
- constructor(ts: TypeScript, zones: Zones);
94
- originOf(declaration: TS.Node): OriginInfo;
95
- /** Named containers from the module down to (and including) the declaration. */
96
- memberPath(declaration: TS.Node): string[];
97
- private containerName;
98
- private ambientModuleName;
99
- }
100
-
101
18
  interface MatchedEntry {
102
19
  readonly source: string;
103
20
  readonly entry: string;
@@ -123,8 +40,38 @@ type Verdict = {
123
40
  readonly origin: OriginInfo;
124
41
  };
125
42
  /**
126
- * `entry` covers `origin` itself, its subpaths (`fs` → `fs/promises`) and members (`builtin:JSON` →
127
- * `builtin:JSON.parse`). When the origin's `base` (package/module part) is known, an entry that stops
43
+ * Are the types a declaration states true at runtime? Type trust is separate from throw trust (`Verdict`):
44
+ * it is decided by the `trust_type` / `distrust_type` lists only.
45
+ * first-party declared in a checked file: its types are checked themselves
46
+ * trust-package declared by @noego/trust: Result, Trust and friends are this tool's own contract
47
+ * type-trusted a `trust_type` entry covers the origin
48
+ * type-untrusted nothing does, or a `distrust_type` entry removed it
49
+ */
50
+ type TypeVerdict = {
51
+ readonly kind: 'first-party';
52
+ readonly origin: OriginInfo;
53
+ } | {
54
+ readonly kind: 'trust-package';
55
+ readonly origin: OriginInfo;
56
+ } | {
57
+ readonly kind: 'type-trusted';
58
+ readonly origin: OriginInfo;
59
+ readonly by: MatchedEntry;
60
+ } | {
61
+ readonly kind: 'type-untrusted';
62
+ readonly origin: OriginInfo;
63
+ readonly distrustedBy?: MatchedEntry;
64
+ };
65
+ type Decision = {
66
+ trusted: true;
67
+ by: MatchedEntry;
68
+ } | {
69
+ trusted: false;
70
+ distrustedBy?: MatchedEntry;
71
+ };
72
+ /**
73
+ * `entry` covers `origin` itself, its subpaths (`fs` → `fs/promises`) and members (`js:JSON` →
74
+ * `js:JSON.parse`). When the origin's `base` (package/module part) is known, an entry that stops
128
75
  * inside the base may only continue with `/`, so `lodash` does not cover the package `lodash.merge`.
129
76
  */
130
77
  declare function entryMatches(entry: string, origin: string, base?: string): boolean;
@@ -133,21 +80,30 @@ declare class TrustPolicy {
133
80
  private readonly checker;
134
81
  readonly zones: Zones;
135
82
  readonly origins: OriginResolver;
83
+ /** The config's per-rule settings (`rules`): which opt-in rules run and which callbacks are sources. */
84
+ readonly rules: TrustRuleSettings;
136
85
  private readonly levels;
137
86
  constructor(ts: TypeScript, checker: TS.TypeChecker, config: TrustConfig, extraTrust?: readonly string[]);
87
+ /** Throw trust of an origin: the `trust` / `distrust` lists of the chain (see `decide`). */
88
+ lookup(origin: string, base?: string): Decision;
89
+ /** Type trust of an origin: the `trust_type` / `distrust_type` lists of the chain, resolved the same way. */
90
+ lookupType(origin: string, base?: string): Decision;
138
91
  /**
139
- * Walks leaf → root; the first level with a matching entry decides. Within a level the most specific
140
- * entry wins (`distrust @noego/wood` + `trust @noego/wood.TraceProvider` trusts only the tracer);
141
- * on equal specificity distrust wins.
92
+ * The `trust_type` entry of the project's own config files that type-trusts `declaration` (member or
93
+ * package level), else null. Entries of built-in presets (`preset:<name>` levels: js, node, web,
94
+ * web_strict, svelte) never count, and a `distrust_type` that wins along the chain takes it back. Only
95
+ * this unlocks a caller-chosen generic return (`container.get<Foo>('x')`, type-claims.ts): a broad preset
96
+ * entry such as `js:Array` must not silently bless a cast. Checked code is looked up too, so a user entry
97
+ * naming a first-party origin (`local:ui/scope.ts#resolveSyncInScope`) unlocks its generic returns.
142
98
  */
143
- lookup(origin: string, base?: string): {
144
- trusted: true;
145
- by: MatchedEntry;
146
- } | {
147
- trusted: false;
148
- distrustedBy?: MatchedEntry;
149
- };
99
+ userTypeTrustOf(declaration: TS.Node): MatchedEntry | null;
100
+ /** Whether the types `declaration` states are trusted (see TypeVerdict). */
101
+ typeVerdictOf(declaration: TS.Node): TypeVerdict;
150
102
  classify(node: TS.CallExpression | TS.NewExpression): Verdict;
103
+ /** Pick by origin, never compiler-internal union order (JavaScript compares UTF-16 units). */
104
+ choose_origin_declaration(candidates: readonly TS.Declaration[]): TS.Declaration | undefined;
105
+ /** Equal-origin overloads keep the existing declaration; distinct origins select the minimum. */
106
+ symbol_declaration(symbol: TS.Symbol | undefined, fallback?: TS.Declaration | undefined): TS.Declaration | undefined;
151
107
  calleeDeclaration(node: TS.CallExpression | TS.NewExpression): {
152
108
  declaration: TS.Node;
153
109
  signature?: TS.Signature;
@@ -163,13 +119,6 @@ declare class TrustPolicy {
163
119
  trustFunctionName(node: TS.CallExpression): string | null;
164
120
  }
165
121
 
166
- /** Minimal ESTree node shape (avoids coupling to a specific @types/estree version). */
167
- interface AstNode {
168
- readonly type: string;
169
- parent?: AstNode;
170
- readonly [key: string]: unknown;
171
- }
172
- type CatchProblem = 'rethrow' | 'notResultErr' | 'rawCatchValue' | 'notAllPaths';
173
122
  type Guard = {
174
123
  readonly status: 'unguarded';
175
124
  } | {
@@ -180,69 +129,20 @@ type Guard = {
180
129
  readonly problem: CatchProblem;
181
130
  };
182
131
  interface GuardContext {
132
+ readonly ts: TypeScript;
183
133
  /** The returned expression is an `Err` (typed: by declaration; untyped: `Result.err(...)`/`err(...)` by name). */
184
- isResultErr(expression: AstNode): boolean;
134
+ isResultErr(expression: TS.Expression): boolean;
185
135
  /** The call is `Result.err(...)` / `err(...)` itself (for the raw-caught-value check). */
186
- isErrCall(expression: AstNode): boolean;
136
+ isErrCall(call: TS.CallExpression): boolean;
187
137
  /** 'sync' for Trust.try, 'async' for Trust.tryAsync, else null. */
188
- trustTryKind(call: AstNode): 'sync' | 'async' | null;
138
+ trustTryKind(call: TS.CallExpression): 'sync' | 'async' | null;
189
139
  }
190
140
  /** Every path through `statement` ends in return (or throw). */
191
- declare function alwaysExits(statement: AstNode | null | undefined): boolean;
141
+ declare function alwaysExits(ts: TypeScript, statement: TS.Statement | undefined): boolean;
192
142
  /** Null when the catch clause returns Result.err(...) on every path, else the problem. */
193
- declare function catchProblem(handler: AstNode, context: GuardContext): CatchProblem | null;
143
+ declare function catchProblem(handler: TS.CatchClause, context: GuardContext): CatchProblem | null;
194
144
  /** Innermost guard of `node` within its own function. */
195
- declare function guardOf(node: AstNode, context: GuardContext): Guard;
196
-
197
- declare const UNTRUSTED_CALL_RULE = "untrusted-call-must-return-result";
198
- declare const THROW_RULE = "throw-must-return-result";
199
- interface Finding {
200
- readonly file: string;
201
- readonly rule: string;
202
- readonly origin: string;
203
- readonly line: number;
204
- readonly column: number;
205
- readonly message: string;
206
- }
207
- /** file → rule → origin → count */
208
- type BaselineCounts = Record<string, Record<string, Record<string, number>>>;
209
- interface BaselineDelta {
210
- readonly file: string;
211
- readonly rule: string;
212
- readonly origin: string;
213
- readonly allowed: number;
214
- readonly found: number;
215
- readonly findings: readonly Finding[];
216
- }
217
- /** The origin a baselined rule message is about ("throw" for the throw rule, messageId for promise rules). */
218
- declare function originFromMessage(rule: string, messageId: string | undefined, message: string): string;
219
- /** Trust-rule findings from ESLint results, with paths relative to `rootDir`. */
220
- declare function findingsFromResults(results: readonly ESLint.LintResult[], rootDir: string): Finding[];
221
- declare function countFindings(findings: readonly Finding[]): BaselineCounts;
222
- declare function compareToBaseline(findings: readonly Finding[], baseline: BaselineCounts): {
223
- readonly added: BaselineDelta[];
224
- readonly stale: BaselineDelta[];
225
- };
226
- declare function serializeBaseline(counts: BaselineCounts): string;
227
- declare function parseBaseline(text: string, source: string): BaselineCounts;
228
-
229
- declare const THROW_MESSAGES: {
230
- readonly escapes: "`throw` must be inside a `try` (same function) whose `catch` returns Result.err(...), or inside Trust.try/tryAsync.";
231
- readonly rethrow: string;
232
- readonly notResultErr: string;
233
- readonly rawCatchValue: string;
234
- readonly notAllPaths: string;
235
- };
236
-
237
- declare const UNTRUSTED_CALL_MESSAGES: {
238
- readonly unguarded: "Call into untrusted \"{{origin}}\" must be inside a `try` (same function) whose `catch` returns Result.err(...), or inside Trust.try/tryAsync. If \"{{origin}}\" cannot fail, trust it in trust.config.json.";
239
- readonly notAwaited: "Async call into untrusted \"{{origin}}\" must be awaited inside the guard, or its rejection escapes the catch.";
240
- readonly callsIgnored: "Call into \"{{origin}}\" is trusted only because its file is ignored. List that file under \"passthrough\" instead of \"ignore\" so calls into it must be handled.";
241
- readonly rethrow: string;
242
- readonly notResultErr: string;
243
- readonly rawCatchValue: string;
244
- readonly notAllPaths: string;
245
- };
145
+ declare function guardOf(node: TS.Node, context: GuardContext): Guard;
246
146
 
247
147
  interface TrustRuleOptions {
248
148
  /** trust.config.json path, relative to the ESLint cwd. */
@@ -254,6 +154,10 @@ interface TrustRuleOptions {
254
154
  declare const rules: {
255
155
  'untrusted-call-must-return-result': eslint.Rule.RuleModule;
256
156
  'throw-must-return-result': eslint.Rule.RuleModule;
157
+ 'type-claim': eslint.Rule.RuleModule;
158
+ 'untrusted-value': eslint.Rule.RuleModule;
159
+ 'dropped-result': eslint.Rule.RuleModule;
160
+ 'redundant-guard': eslint.Rule.RuleModule;
257
161
  };
258
162
  interface TypedConfigOptions {
259
163
  /** Files to check (flat-config globs). They must be in a tsconfig the project service can find. */
@@ -265,7 +169,13 @@ interface TypedConfigOptions {
265
169
  }
266
170
  declare const plugin: ESLint.Plugin;
267
171
 
268
- /** Flat config that registers the plugin as `trust` and enables both rules for `files`. Needs typed linting. */
172
+ /**
173
+ * Flat config that registers the plugin as `trust` and enables its rules (the two trust rules, `type-claim`,
174
+ * `untrusted-value` and `dropped-result`) for `files`. Needs typed linting. `type-claim`, `untrusted-value` and
175
+ * `dropped-result` are opt-in: they report only when the trust config turns them on
176
+ * (`"rules": { "type-claim": "on", "untrusted-value": "on", "dropped-result": "on" }`), the same settings
177
+ * `trust check` / `trust baseline` honour, so ESLint and the CLI always agree.
178
+ */
269
179
  declare function typedConfig(options: TypedConfigOptions): Linter.Config[];
270
180
 
271
- export { type BaselineCounts, type BaselineDelta, type CatchProblem, type Finding, type Guard, type GuardContext, type LoadTrustConfigOptions, type MatchedEntry, type OriginInfo, OriginResolver, PRESETS, type PresetDefinition, THROW_MESSAGES, THROW_RULE, type TrustConfig, TrustConfigError, type TrustEntry, type TrustLevel, TrustPolicy, type TrustRuleOptions, type TypedConfigOptions, UNTRUSTED_CALL_MESSAGES, UNTRUSTED_CALL_RULE, type Verdict, type Zone, type ZoneGroup, Zones, alwaysExits, catchProblem, compareToBaseline, countFindings, plugin as default, effectiveTrustList, entryMatches, findingsFromResults, guardOf, loadTrustConfig, normalizeOrigin, originFromMessage, parseBaseline, rules, serializeBaseline, typedConfig };
181
+ export { CatchProblem, type Guard, type GuardContext, type MatchedEntry, OriginInfo, OriginResolver, PRESETS, type PresetDefinition, TrustConfig, TrustPolicy, type TrustRuleOptions, TrustRuleSettings, type TypeVerdict, type TypedConfigOptions, type Verdict, Zones, alwaysExits, catchProblem, plugin as default, entryMatches, guardOf, rules, typedConfig };