@noego/trust 0.5.0-dev.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 (142) hide show
  1. package/README.md +44 -9
  2. package/dist/{baseline-B0AplCuF.d.ts → baseline-Bkav9mS0.d.ts} +22 -4
  3. package/dist/{chunk-V72KWVWP.js → chunk-7PY2Q6OX.js} +212 -16
  4. package/dist/chunk-7PY2Q6OX.js.map +1 -0
  5. package/dist/{chunk-NG4KYWVW.js → chunk-UG6D3V4M.js} +877 -41
  6. package/dist/chunk-UG6D3V4M.js.map +1 -0
  7. package/dist/{chunk-OSSITT3R.js → chunk-XXLWC5DB.js} +17 -61
  8. package/dist/chunk-XXLWC5DB.js.map +1 -0
  9. package/dist/cli/index.js +341 -92
  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 +5 -3
  14. package/dist/core/index.js +7 -7
  15. package/dist/eslint/index.d.ts +6 -2
  16. package/dist/eslint/index.js +2 -2
  17. package/dist/licenses/@jridgewell__resolve-uri/LICENSE +19 -0
  18. package/dist/licenses/@jridgewell__sourcemap-codec/LICENSE +19 -0
  19. package/dist/licenses/@jridgewell__trace-mapping/LICENSE +19 -0
  20. package/dist/licenses/JS-DEPENDENCIES.json +83 -0
  21. package/dist/licenses/balanced-match/LICENSE.md +23 -0
  22. package/dist/licenses/brace-expansion/LICENSE +23 -0
  23. package/dist/licenses/dedent-js/LICENSE +19 -0
  24. package/dist/licenses/minimatch/LICENSE.md +55 -0
  25. package/dist/licenses/scule/LICENSE +21 -0
  26. package/dist/licenses/svelte2tsx/LICENSE +21 -0
  27. package/dist/native/licenses/CARGO-DEPENDENCIES.json +479 -0
  28. package/dist/native/licenses/LICENSE-trust.txt +15 -0
  29. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-0BSD +12 -0
  30. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-APACHE +201 -0
  31. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-MIT +23 -0
  32. package/dist/native/licenses/cargo/aho-corasick-1.1.5/COPYING +3 -0
  33. package/dist/native/licenses/cargo/aho-corasick-1.1.5/LICENSE-MIT +21 -0
  34. package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-APACHE +201 -0
  35. package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-MIT +25 -0
  36. package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-APACHE +201 -0
  37. package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-MIT +25 -0
  38. package/dist/native/licenses/cargo/bstr-1.13.1/COPYING +8 -0
  39. package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-APACHE +201 -0
  40. package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-MIT +21 -0
  41. package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-APACHE +201 -0
  42. package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-MIT +25 -0
  43. package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-APACHE +201 -0
  44. package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-MIT +25 -0
  45. package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-APACHE +202 -0
  46. package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-MIT +21 -0
  47. package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-APACHE +201 -0
  48. package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-MIT +25 -0
  49. package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-APACHE +201 -0
  50. package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-MIT +25 -0
  51. package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-APACHE +201 -0
  52. package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-MIT +25 -0
  53. package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-APACHE +201 -0
  54. package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-MIT +25 -0
  55. package/dist/native/licenses/cargo/globset-0.4.20/COPYING +3 -0
  56. package/dist/native/licenses/cargo/globset-0.4.20/LICENSE-MIT +21 -0
  57. package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-APACHE +201 -0
  58. package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-MIT +25 -0
  59. package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-APACHE +201 -0
  60. package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-MIT +25 -0
  61. package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-APACHE +176 -0
  62. package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-MIT +23 -0
  63. package/dist/native/licenses/cargo/jiff-0.2.37/COPYING +3 -0
  64. package/dist/native/licenses/cargo/jiff-0.2.37/LICENSE-MIT +21 -0
  65. package/dist/native/licenses/cargo/jiff-core-0.1.1/COPYING +3 -0
  66. package/dist/native/licenses/cargo/jiff-core-0.1.1/LICENSE-MIT +21 -0
  67. package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/COPYING +3 -0
  68. package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/LICENSE-MIT +21 -0
  69. package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/COPYING +3 -0
  70. package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/LICENSE-MIT +21 -0
  71. package/dist/native/licenses/cargo/log-0.4.34/LICENSE-APACHE +201 -0
  72. package/dist/native/licenses/cargo/log-0.4.34/LICENSE-MIT +25 -0
  73. package/dist/native/licenses/cargo/lzma-rust2-0.21.0/LICENSE +201 -0
  74. package/dist/native/licenses/cargo/memchr-2.8.2/COPYING +3 -0
  75. package/dist/native/licenses/cargo/memchr-2.8.2/LICENSE-MIT +21 -0
  76. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE +25 -0
  77. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-APACHE.md +177 -0
  78. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-MIT.md +24 -0
  79. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-ZLIB.md +14 -0
  80. package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-APACHE +201 -0
  81. package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-MIT +25 -0
  82. package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-APACHE +201 -0
  83. package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-MIT +25 -0
  84. package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-APACHE +201 -0
  85. package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-MIT +25 -0
  86. package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
  87. package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-MIT +23 -0
  88. package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-APACHE +176 -0
  89. package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-MIT +23 -0
  90. package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-APACHE +201 -0
  91. package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-MIT +25 -0
  92. package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-APACHE +201 -0
  93. package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-MIT +25 -0
  94. package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-APACHE +176 -0
  95. package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-MIT +23 -0
  96. package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-APACHE +176 -0
  97. package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-BOOST +23 -0
  98. package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-APACHE +176 -0
  99. package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-MIT +23 -0
  100. package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-APACHE +176 -0
  101. package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-MIT +23 -0
  102. package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-APACHE +176 -0
  103. package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-MIT +23 -0
  104. package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-APACHE +176 -0
  105. package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-MIT +23 -0
  106. package/dist/native/licenses/cargo/simd-adler32-0.3.10/LICENSE.md +21 -0
  107. package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-APACHE +201 -0
  108. package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-MIT +25 -0
  109. package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-APACHE +176 -0
  110. package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-MIT +23 -0
  111. package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-APACHE +176 -0
  112. package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-MIT +23 -0
  113. package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-APACHE +176 -0
  114. package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-MIT +23 -0
  115. package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-APACHE +176 -0
  116. package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-MIT +23 -0
  117. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-APACHE +176 -0
  118. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-MIT +23 -0
  119. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-UNICODE +39 -0
  120. package/dist/native/licenses/cargo/xxhash-rust-0.8.15/LICENSE +23 -0
  121. package/dist/native/licenses/cargo/zlib-rs-0.6.8/LICENSE +19 -0
  122. package/dist/native/licenses/cargo/zmij-1.0.23/LICENSE-MIT +23 -0
  123. package/dist/native/licenses/ts-rust/LICENSE +21 -0
  124. package/dist/native/licenses/ts-rust/NOTICE.md +53 -0
  125. package/dist/native/licenses/ts-rust/licenses/Go-LICENSE.txt +27 -0
  126. package/dist/native/licenses/ts-rust/licenses/TypeScript-LICENSE.txt +55 -0
  127. package/dist/native/licenses/ts-rust/licenses/TypeScript-NOTICE.txt +405 -0
  128. package/dist/native/licenses/ts-rust/licenses/Unicode-LICENSE.txt +39 -0
  129. package/dist/native/licenses/ts-rust/licenses/vscode-languageserver-node-LICENSE.txt +18 -0
  130. package/dist/native/licenses/typescript/LICENSE.txt +55 -0
  131. package/dist/native/licenses/typescript/ThirdPartyNoticeText.txt +193 -0
  132. package/dist/native/licenses/typescript/manifest.json +105 -0
  133. package/dist/native/trust_native_wasm.wasm +0 -0
  134. package/dist/svelte2tsx/index.cjs +7064 -0
  135. package/dist/svelte2tsx/svelte-jsx-v4.d.ts +230 -0
  136. package/dist/svelte2tsx/svelte-jsx.d.ts +1492 -0
  137. package/dist/svelte2tsx/svelte-shims-v4.d.ts +290 -0
  138. package/dist/svelte2tsx/svelte-shims.d.ts +305 -0
  139. package/package.json +25 -5
  140. package/dist/chunk-NG4KYWVW.js.map +0 -1
  141. package/dist/chunk-OSSITT3R.js.map +0 -1
  142. package/dist/chunk-V72KWVWP.js.map +0 -1
@@ -1,67 +1,21 @@
1
1
  import {
2
- groupMatches,
2
+ SvelteFileError,
3
+ createPrograms,
3
4
  loadTypeScript,
4
5
  realpathOrSelf,
5
6
  relativeInside,
7
+ sourceFileOf,
8
+ svelteFor,
6
9
  toPosix
7
- } from "./chunk-NG4KYWVW.js";
8
-
9
- // src/core/program.ts
10
- import { dirname, resolve } from "path";
11
- function readTsconfig(ts, tsconfig) {
12
- if (!tsconfig) return { options: { allowJs: true, strict: true, noEmit: true }, declarationFiles: [] };
13
- const parsed = ts.getParsedCommandLineOfConfigFile(tsconfig, {}, {
14
- ...ts.sys,
15
- onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
16
- throw new Error(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
17
- }
18
- });
19
- return {
20
- options: { ...parsed?.options, noEmit: true },
21
- declarationFiles: (parsed?.fileNames ?? []).filter((name) => /\.d\.[cm]?ts$/.test(name))
22
- };
23
- }
24
- function missingMappedTsconfig(mapping, file) {
25
- const files = mapping.patterns.length === 1 ? JSON.stringify(mapping.patterns[0]) : JSON.stringify(mapping.patterns);
26
- return {
27
- kind: "missing-mapped-tsconfig",
28
- message: `trust config ${mapping.source}: "tsconfig[${mapping.index}]" (files ${files}) maps ${file} to ${mapping.tsconfig}, which does not exist`
29
- };
30
- }
31
- function groupByTsconfig(ts, cwd, files, tsconfig, mappings = []) {
32
- const override = tsconfig ? resolve(cwd, tsconfig) : void 0;
33
- const groups = /* @__PURE__ */ new Map();
34
- for (const file of files) {
35
- const mapping = override === void 0 ? mappings.find((entry) => groupMatches(entry, realpathOrSelf(file))) : void 0;
36
- if (mapping && !ts.sys.fileExists(mapping.tsconfig)) return missingMappedTsconfig(mapping, file);
37
- const owner = override ?? mapping?.tsconfig ?? ts.findConfigFile(dirname(file), ts.sys.fileExists);
38
- const list = groups.get(owner) ?? [];
39
- list.push(file);
40
- groups.set(owner, list);
41
- }
42
- return { kind: "grouped", groups };
43
- }
44
- function createPrograms(ts, cwd, files, tsconfig, mappings = []) {
45
- const grouping = groupByTsconfig(ts, cwd, files, tsconfig, mappings);
46
- if (grouping.kind !== "grouped") return grouping;
47
- const groups = [...grouping.groups].map(([owner, groupFiles]) => {
48
- const settings = readTsconfig(ts, owner);
49
- const rootNames = [.../* @__PURE__ */ new Set([...groupFiles, ...settings.declarationFiles])];
50
- return { tsconfig: owner, files: groupFiles, program: ts.createProgram({ rootNames, options: settings.options }) };
51
- });
52
- return { kind: "created", groups };
53
- }
54
- function sourceFileOf(program, file) {
55
- return program.getSourceFile(file) ?? program.getSourceFile(realpathOrSelf(file));
56
- }
10
+ } from "./chunk-UG6D3V4M.js";
57
11
 
58
12
  // src/cli/source-files.ts
59
13
  import { existsSync, readdirSync, statSync } from "fs";
60
- import { join, resolve as resolve2 } from "path";
14
+ import { join, resolve } from "path";
61
15
  var SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist"]);
62
16
  var MAX_LOGGED_ERRORS = 50;
63
17
  function isSourceFile(name) {
64
- return (name.endsWith(".ts") || name.endsWith(".tsx")) && !name.endsWith(".d.ts");
18
+ return (name.endsWith(".ts") || name.endsWith(".tsx") || name.endsWith(".svelte")) && !name.endsWith(".d.ts");
65
19
  }
66
20
  function walk(directory, files) {
67
21
  for (const entry of readdirSync(directory, { withFileTypes: true })) {
@@ -76,7 +30,7 @@ function walk(directory, files) {
76
30
  function resolveFiles(cwd, paths) {
77
31
  const files = [];
78
32
  for (const path of paths) {
79
- const absolute = resolve2(cwd, path);
33
+ const absolute = resolve(cwd, path);
80
34
  if (!existsSync(absolute)) return { missing: path };
81
35
  if (statSync(absolute).isDirectory()) walk(absolute, files);
82
36
  else files.push(absolute);
@@ -90,7 +44,8 @@ function relativeTo(rootDir, file) {
90
44
  function syntaxErrors(ts, program, sourceFile) {
91
45
  return program.getSyntacticDiagnostics(sourceFile).map((diagnostic) => {
92
46
  const { line, character } = ts.getLineAndCharacterOfPosition(sourceFile, diagnostic.start ?? 0);
93
- return `${sourceFile.fileName}:${line + 1}:${character + 1} ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`;
47
+ const message = `${sourceFile.fileName}:${line + 1}:${character + 1} ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`;
48
+ return svelteFor(program.getTypeChecker())?.error(message) ?? message;
94
49
  });
95
50
  }
96
51
  function forEachSourceFile(cwd, files, programs, visit) {
@@ -101,6 +56,7 @@ function forEachSourceFile(cwd, files, programs, visit) {
101
56
  ts = loadTypeScript(cwd);
102
57
  creation = createPrograms(ts, cwd, files, programs.tsconfig, programs.mappings);
103
58
  } catch (error) {
59
+ if (error instanceof SvelteFileError) return { status: "file-errors", errors: [error.message] };
104
60
  return { status: "setup-failed", message: error instanceof Error ? error.message : String(error) };
105
61
  }
106
62
  if (creation.kind !== "created") return { status: "setup-failed", message: creation.message };
@@ -130,6 +86,9 @@ function formatWalkFailure(label, walk2) {
130
86
  function logWalkFailure(log, command, walk2) {
131
87
  for (const line of formatWalkFailure(`trust ${command}`, walk2)) log(line);
132
88
  }
89
+ function logUnmatchedGlobs(log, command, config) {
90
+ for (const line of config.unmatchedGlobs) log(`trust ${command}: warning: ${line}`);
91
+ }
133
92
 
134
93
  // src/core/report.ts
135
94
  function compareFindings(a, b) {
@@ -137,20 +96,17 @@ function compareFindings(a, b) {
137
96
  return a.line - b.line || a.column - b.column;
138
97
  }
139
98
  function formatFinding(finding) {
140
- return `${finding.file}:${finding.line}:${finding.column} ${finding.rule} ${finding.message}`;
99
+ return `${finding.file}:${finding.line}:${finding.column} ${finding.rule} ${finding.severity === "warning" ? "warning: " : ""}${finding.message}`;
141
100
  }
142
101
 
143
102
  export {
144
- readTsconfig,
145
- groupByTsconfig,
146
- createPrograms,
147
- sourceFileOf,
148
103
  resolveFiles,
149
104
  relativeTo,
150
105
  forEachSourceFile,
151
106
  formatWalkFailure,
152
107
  logWalkFailure,
108
+ logUnmatchedGlobs,
153
109
  compareFindings,
154
110
  formatFinding
155
111
  };
156
- //# sourceMappingURL=chunk-OSSITT3R.js.map
112
+ //# sourceMappingURL=chunk-XXLWC5DB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/source-files.ts","../src/core/report.ts"],"sourcesContent":["// Shared by `trust check` and `trust baseline`: which files to check (named files as-is, directories\n// walked for .ts/.tsx, node_modules/dist/.d.ts skipped), and one walk over their TypeScript programs\n// that stops when a file cannot be loaded or parsed. No ESLint.\nimport { SvelteFileError, svelteFor } from '../core/svelte.js';\nimport { existsSync, readdirSync, statSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport type * as TS from 'typescript';\nimport { createPrograms, sourceFileOf } from '../core/program.js';\nimport type { TrustConfig, TsconfigMapping } from '../eslint/config.js';\nimport { loadTypeScript, type TypeScript } from '../eslint/typescript.js';\nimport { relativeInside, realpathOrSelf, toPosix } from '../eslint/zones.js';\n\nconst SKIPPED_DIRECTORIES = new Set(['node_modules', 'dist']);\nconst MAX_LOGGED_ERRORS = 50;\n\nfunction isSourceFile(name: string): boolean {\n return (name.endsWith('.ts') || name.endsWith('.tsx') || name.endsWith('.svelte')) && !name.endsWith('.d.ts');\n}\n\nfunction walk(directory: string, files: string[]): void {\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n const full = join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!SKIPPED_DIRECTORIES.has(entry.name)) walk(full, files);\n } else if (entry.isFile() && isSourceFile(entry.name)) {\n files.push(full);\n }\n }\n}\n\n/** Absolute paths, sorted and deduplicated: named files as-is, directories walked for .ts/.tsx. */\nexport function resolveFiles(cwd: string, paths: readonly string[]): { files: string[] } | { missing: string } {\n const files: string[] = [];\n for (const path of paths) {\n const absolute = resolve(cwd, path);\n if (!existsSync(absolute)) return { missing: path };\n if (statSync(absolute).isDirectory()) walk(absolute, files);\n else files.push(absolute);\n }\n return { files: [...new Set(files)].sort() };\n}\n\nexport function relativeTo(rootDir: string, file: string): string {\n const real = realpathOrSelf(file);\n return relativeInside(rootDir, real) ?? toPosix(real);\n}\n\nfunction syntaxErrors(ts: TypeScript, program: TS.Program, sourceFile: TS.SourceFile): string[] {\n return program.getSyntacticDiagnostics(sourceFile).map((diagnostic) => {\n const { line, character } = ts.getLineAndCharacterOfPosition(sourceFile, diagnostic.start ?? 0);\n const message = `${sourceFile.fileName}:${line + 1}:${character + 1} ${ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n')}`;\n return svelteFor(program.getTypeChecker())?.error(message) ?? message;\n });\n}\n\nexport interface LoadedFile {\n readonly ts: TypeScript;\n readonly program: TS.Program;\n readonly sourceFile: TS.SourceFile;\n /** Absolute path as resolved from the command line. */\n readonly file: string;\n}\n\nexport type ProgramWalk =\n | { readonly status: 'ok' }\n /** TypeScript could not be resolved, a tsconfig could not be read, or a mapped tsconfig is missing. */\n | { readonly status: 'setup-failed'; readonly message: string }\n /** Files no program could load, or with syntax errors. */\n | { readonly status: 'file-errors'; readonly errors: readonly string[] };\n\n/** Which tsconfig compiles each file: `tsconfig` (relative to cwd) for all, else `mappings`, else the nearest one. */\nexport interface ProgramOptions {\n readonly tsconfig: string | undefined;\n readonly mappings: readonly TsconfigMapping[];\n}\n\n/**\n * Builds one program per owning tsconfig and calls `visit` for every file that loads and parses.\n * Files with errors are collected instead; callers must not trust findings when the walk is not ok.\n */\nexport function forEachSourceFile(cwd: string, files: readonly string[], programs: ProgramOptions, visit: (loaded: LoadedFile) => void): ProgramWalk {\n if (files.length === 0) return { status: 'ok' };\n let ts: TypeScript;\n let creation: ReturnType<typeof createPrograms>;\n try {\n ts = loadTypeScript(cwd);\n creation = createPrograms(ts, cwd, files, programs.tsconfig, programs.mappings);\n } catch (error) {\n if (error instanceof SvelteFileError) return { status: 'file-errors', errors: [error.message] };\n return { status: 'setup-failed', message: error instanceof Error ? error.message : String(error) };\n }\n if (creation.kind !== 'created') return { status: 'setup-failed', message: creation.message };\n const errors: string[] = [];\n for (const group of creation.groups) {\n for (const file of group.files) {\n const sourceFile = sourceFileOf(group.program, file);\n if (!sourceFile) {\n errors.push(`${file}: could not be loaded into a TypeScript program (tsconfig: ${group.tsconfig ?? 'none'})`);\n continue;\n }\n const syntax = syntaxErrors(ts, group.program, sourceFile);\n if (syntax.length > 0) {\n errors.push(...syntax);\n continue;\n }\n visit({ ts, program: group.program, sourceFile, file });\n }\n }\n return errors.length > 0 ? { status: 'file-errors', errors } : { status: 'ok' };\n}\n\n/** Why the walk failed, as lines headed by `label` (`trust check`, `ioc check`); at most 50 file errors. */\nexport function formatWalkFailure(label: string, walk: Exclude<ProgramWalk, { status: 'ok' }>): string[] {\n if (walk.status === 'setup-failed') return [`${label}: could not set up TypeScript: ${walk.message}`];\n const header = `${label} could not check ${walk.errors.length === 1 ? 'a file' : 'some files'}; fix these first:`;\n return [header, ...walk.errors.slice(0, MAX_LOGGED_ERRORS).map((line) => ` ${line}`)];\n}\n\n/** Logs why the walk failed, under `trust <command>`. */\nexport function logWalkFailure(log: (line: string) => void, command: string, walk: Exclude<ProgramWalk, { status: 'ok' }>): void {\n for (const line of formatWalkFailure(`trust ${command}`, walk)) log(line);\n}\n\n/**\n * Prints each config glob that matched no file. The run continues: a glob can match nothing for a\n * legitimate moment (generated files absent in a worktree), but a typo should still be visible.\n */\nexport function logUnmatchedGlobs(log: (line: string) => void, command: string, config: Pick<TrustConfig, 'unmatchedGlobs'>): void {\n for (const line of config.unmatchedGlobs) log(`trust ${command}: warning: ${line}`);\n}\n","// How a finding is printed by `trust check` (and by sibling checkers built on `@noego/trust/core`):\n// one line `file:line:col rule message`, files in path order, then line and column.\nimport type { Finding } from './messages.js';\n\n/** What a printed finding needs. */\nexport type ReportFinding = Pick<Finding, 'file' | 'line' | 'column' | 'rule' | 'message'> & { readonly severity?: 'error' | 'warning' };\n\n/** Sort order of printed findings: file, then line, then column. */\nexport function compareFindings(a: ReportFinding, b: ReportFinding): number {\n if (a.file !== b.file) return a.file < b.file ? -1 : 1;\n return a.line - b.line || a.column - b.column;\n}\n\n/** `file:line:col rule message`. */\nexport function formatFinding(finding: ReportFinding): string {\n return `${finding.file}:${finding.line}:${finding.column} ${finding.rule} ${finding.severity === 'warning' ? 'warning: ' : ''}${finding.message}`;\n}\n"],"mappings":";;;;;;;;;;;;AAIA,SAAS,YAAY,aAAa,gBAAgB;AAClD,SAAS,MAAM,eAAe;AAO9B,IAAM,sBAAsB,oBAAI,IAAI,CAAC,gBAAgB,MAAM,CAAC;AAC5D,IAAM,oBAAoB;AAE1B,SAAS,aAAa,MAAuB;AAC3C,UAAQ,KAAK,SAAS,KAAK,KAAK,KAAK,SAAS,MAAM,KAAK,KAAK,SAAS,SAAS,MAA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