@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.
- package/README.md +962 -14
- package/dist/baseline-Bkav9mS0.d.ts +380 -0
- package/dist/chunk-7PY2Q6OX.js +3016 -0
- package/dist/chunk-7PY2Q6OX.js.map +1 -0
- package/dist/chunk-UG6D3V4M.js +6990 -0
- package/dist/chunk-UG6D3V4M.js.map +1 -0
- package/dist/chunk-XXLWC5DB.js +112 -0
- package/dist/chunk-XXLWC5DB.js.map +1 -0
- package/dist/cli/index.js +1391 -65
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/wasm-worker.js +257 -0
- package/dist/cli/wasm-worker.js.map +1 -0
- package/dist/core/index.d.ts +129 -0
- package/dist/core/index.js +115 -0
- package/dist/core/index.js.map +1 -0
- package/dist/eslint/index.d.ts +77 -167
- package/dist/eslint/index.js +320 -32
- package/dist/eslint/index.js.map +1 -1
- package/dist/licenses/@jridgewell__resolve-uri/LICENSE +19 -0
- package/dist/licenses/@jridgewell__sourcemap-codec/LICENSE +19 -0
- package/dist/licenses/@jridgewell__trace-mapping/LICENSE +19 -0
- package/dist/licenses/JS-DEPENDENCIES.json +83 -0
- package/dist/licenses/balanced-match/LICENSE.md +23 -0
- package/dist/licenses/brace-expansion/LICENSE +23 -0
- package/dist/licenses/dedent-js/LICENSE +19 -0
- package/dist/licenses/minimatch/LICENSE.md +55 -0
- package/dist/licenses/scule/LICENSE +21 -0
- package/dist/licenses/svelte2tsx/LICENSE +21 -0
- package/dist/native/licenses/CARGO-DEPENDENCIES.json +479 -0
- package/dist/native/licenses/LICENSE-trust.txt +15 -0
- package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-0BSD +12 -0
- package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/aho-corasick-1.1.5/COPYING +3 -0
- package/dist/native/licenses/cargo/aho-corasick-1.1.5/LICENSE-MIT +21 -0
- package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/bstr-1.13.1/COPYING +8 -0
- package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-MIT +21 -0
- package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-APACHE +202 -0
- package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-MIT +21 -0
- package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/globset-0.4.20/COPYING +3 -0
- package/dist/native/licenses/cargo/globset-0.4.20/LICENSE-MIT +21 -0
- package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/jiff-0.2.37/COPYING +3 -0
- package/dist/native/licenses/cargo/jiff-0.2.37/LICENSE-MIT +21 -0
- package/dist/native/licenses/cargo/jiff-core-0.1.1/COPYING +3 -0
- package/dist/native/licenses/cargo/jiff-core-0.1.1/LICENSE-MIT +21 -0
- package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/COPYING +3 -0
- package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/LICENSE-MIT +21 -0
- package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/COPYING +3 -0
- package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/LICENSE-MIT +21 -0
- package/dist/native/licenses/cargo/log-0.4.34/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/log-0.4.34/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/lzma-rust2-0.21.0/LICENSE +201 -0
- package/dist/native/licenses/cargo/memchr-2.8.2/COPYING +3 -0
- package/dist/native/licenses/cargo/memchr-2.8.2/LICENSE-MIT +21 -0
- package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE +25 -0
- package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-APACHE.md +177 -0
- package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-MIT.md +24 -0
- package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-ZLIB.md +14 -0
- package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-BOOST +23 -0
- package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/simd-adler32-0.3.10/LICENSE.md +21 -0
- package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-APACHE +201 -0
- package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-MIT +25 -0
- package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-APACHE +176 -0
- package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-MIT +23 -0
- package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-UNICODE +39 -0
- package/dist/native/licenses/cargo/xxhash-rust-0.8.15/LICENSE +23 -0
- package/dist/native/licenses/cargo/zlib-rs-0.6.8/LICENSE +19 -0
- package/dist/native/licenses/cargo/zmij-1.0.23/LICENSE-MIT +23 -0
- package/dist/native/licenses/ts-rust/LICENSE +21 -0
- package/dist/native/licenses/ts-rust/NOTICE.md +53 -0
- package/dist/native/licenses/ts-rust/licenses/Go-LICENSE.txt +27 -0
- package/dist/native/licenses/ts-rust/licenses/TypeScript-LICENSE.txt +55 -0
- package/dist/native/licenses/ts-rust/licenses/TypeScript-NOTICE.txt +405 -0
- package/dist/native/licenses/ts-rust/licenses/Unicode-LICENSE.txt +39 -0
- package/dist/native/licenses/ts-rust/licenses/vscode-languageserver-node-LICENSE.txt +18 -0
- package/dist/native/licenses/typescript/LICENSE.txt +55 -0
- package/dist/native/licenses/typescript/ThirdPartyNoticeText.txt +193 -0
- package/dist/native/licenses/typescript/manifest.json +105 -0
- package/dist/native/trust_native_wasm.wasm +0 -0
- package/dist/svelte2tsx/index.cjs +7064 -0
- package/dist/svelte2tsx/svelte-jsx-v4.d.ts +230 -0
- package/dist/svelte2tsx/svelte-jsx.d.ts +1492 -0
- package/dist/svelte2tsx/svelte-shims-v4.d.ts +290 -0
- package/dist/svelte2tsx/svelte-shims.d.ts +305 -0
- package/package.json +31 -8
- package/dist/chunk-YJYGTNJD.js +0 -2168
- package/dist/chunk-YJYGTNJD.js.map +0 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SvelteFileError,
|
|
3
|
+
createPrograms,
|
|
4
|
+
loadTypeScript,
|
|
5
|
+
realpathOrSelf,
|
|
6
|
+
relativeInside,
|
|
7
|
+
sourceFileOf,
|
|
8
|
+
svelteFor,
|
|
9
|
+
toPosix
|
|
10
|
+
} from "./chunk-UG6D3V4M.js";
|
|
11
|
+
|
|
12
|
+
// src/cli/source-files.ts
|
|
13
|
+
import { existsSync, readdirSync, statSync } from "fs";
|
|
14
|
+
import { join, resolve } from "path";
|
|
15
|
+
var SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist"]);
|
|
16
|
+
var MAX_LOGGED_ERRORS = 50;
|
|
17
|
+
function isSourceFile(name) {
|
|
18
|
+
return (name.endsWith(".ts") || name.endsWith(".tsx") || name.endsWith(".svelte")) && !name.endsWith(".d.ts");
|
|
19
|
+
}
|
|
20
|
+
function walk(directory, files) {
|
|
21
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
22
|
+
const full = join(directory, entry.name);
|
|
23
|
+
if (entry.isDirectory()) {
|
|
24
|
+
if (!SKIPPED_DIRECTORIES.has(entry.name)) walk(full, files);
|
|
25
|
+
} else if (entry.isFile() && isSourceFile(entry.name)) {
|
|
26
|
+
files.push(full);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function resolveFiles(cwd, paths) {
|
|
31
|
+
const files = [];
|
|
32
|
+
for (const path of paths) {
|
|
33
|
+
const absolute = resolve(cwd, path);
|
|
34
|
+
if (!existsSync(absolute)) return { missing: path };
|
|
35
|
+
if (statSync(absolute).isDirectory()) walk(absolute, files);
|
|
36
|
+
else files.push(absolute);
|
|
37
|
+
}
|
|
38
|
+
return { files: [...new Set(files)].sort() };
|
|
39
|
+
}
|
|
40
|
+
function relativeTo(rootDir, file) {
|
|
41
|
+
const real = realpathOrSelf(file);
|
|
42
|
+
return relativeInside(rootDir, real) ?? toPosix(real);
|
|
43
|
+
}
|
|
44
|
+
function syntaxErrors(ts, program, sourceFile) {
|
|
45
|
+
return program.getSyntacticDiagnostics(sourceFile).map((diagnostic) => {
|
|
46
|
+
const { line, character } = ts.getLineAndCharacterOfPosition(sourceFile, diagnostic.start ?? 0);
|
|
47
|
+
const message = `${sourceFile.fileName}:${line + 1}:${character + 1} ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`;
|
|
48
|
+
return svelteFor(program.getTypeChecker())?.error(message) ?? message;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function forEachSourceFile(cwd, files, programs, visit) {
|
|
52
|
+
if (files.length === 0) return { status: "ok" };
|
|
53
|
+
let ts;
|
|
54
|
+
let creation;
|
|
55
|
+
try {
|
|
56
|
+
ts = loadTypeScript(cwd);
|
|
57
|
+
creation = createPrograms(ts, cwd, files, programs.tsconfig, programs.mappings);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (error instanceof SvelteFileError) return { status: "file-errors", errors: [error.message] };
|
|
60
|
+
return { status: "setup-failed", message: error instanceof Error ? error.message : String(error) };
|
|
61
|
+
}
|
|
62
|
+
if (creation.kind !== "created") return { status: "setup-failed", message: creation.message };
|
|
63
|
+
const errors = [];
|
|
64
|
+
for (const group of creation.groups) {
|
|
65
|
+
for (const file of group.files) {
|
|
66
|
+
const sourceFile = sourceFileOf(group.program, file);
|
|
67
|
+
if (!sourceFile) {
|
|
68
|
+
errors.push(`${file}: could not be loaded into a TypeScript program (tsconfig: ${group.tsconfig ?? "none"})`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const syntax = syntaxErrors(ts, group.program, sourceFile);
|
|
72
|
+
if (syntax.length > 0) {
|
|
73
|
+
errors.push(...syntax);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
visit({ ts, program: group.program, sourceFile, file });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return errors.length > 0 ? { status: "file-errors", errors } : { status: "ok" };
|
|
80
|
+
}
|
|
81
|
+
function formatWalkFailure(label, walk2) {
|
|
82
|
+
if (walk2.status === "setup-failed") return [`${label}: could not set up TypeScript: ${walk2.message}`];
|
|
83
|
+
const header = `${label} could not check ${walk2.errors.length === 1 ? "a file" : "some files"}; fix these first:`;
|
|
84
|
+
return [header, ...walk2.errors.slice(0, MAX_LOGGED_ERRORS).map((line) => ` ${line}`)];
|
|
85
|
+
}
|
|
86
|
+
function logWalkFailure(log, command, walk2) {
|
|
87
|
+
for (const line of formatWalkFailure(`trust ${command}`, walk2)) log(line);
|
|
88
|
+
}
|
|
89
|
+
function logUnmatchedGlobs(log, command, config) {
|
|
90
|
+
for (const line of config.unmatchedGlobs) log(`trust ${command}: warning: ${line}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/core/report.ts
|
|
94
|
+
function compareFindings(a, b) {
|
|
95
|
+
if (a.file !== b.file) return a.file < b.file ? -1 : 1;
|
|
96
|
+
return a.line - b.line || a.column - b.column;
|
|
97
|
+
}
|
|
98
|
+
function formatFinding(finding) {
|
|
99
|
+
return `${finding.file}:${finding.line}:${finding.column} ${finding.rule} ${finding.severity === "warning" ? "warning: " : ""}${finding.message}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
resolveFiles,
|
|
104
|
+
relativeTo,
|
|
105
|
+
forEachSourceFile,
|
|
106
|
+
formatWalkFailure,
|
|
107
|
+
logWalkFailure,
|
|
108
|
+
logUnmatchedGlobs,
|
|
109
|
+
compareFindings,
|
|
110
|
+
formatFinding
|
|
111
|
+
};
|
|
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,MAAM,CAAC,KAAK,SAAS,OAAO;AAC9G;AAEA,SAAS,KAAK,WAAmB,OAAuB;AACtD,aAAW,SAAS,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC,GAAG;AACnE,UAAM,OAAO,KAAK,WAAW,MAAM,IAAI;AACvC,QAAI,MAAM,YAAY,GAAG;AACvB,UAAI,CAAC,oBAAoB,IAAI,MAAM,IAAI,EAAG,MAAK,MAAM,KAAK;AAAA,IAC5D,WAAW,MAAM,OAAO,KAAK,aAAa,MAAM,IAAI,GAAG;AACrD,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACF;AAGO,SAAS,aAAa,KAAa,OAAqE;AAC7G,QAAM,QAAkB,CAAC;AACzB,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAW,QAAQ,KAAK,IAAI;AAClC,QAAI,CAAC,WAAW,QAAQ,EAAG,QAAO,EAAE,SAAS,KAAK;AAClD,QAAI,SAAS,QAAQ,EAAE,YAAY,EAAG,MAAK,UAAU,KAAK;AAAA,QACrD,OAAM,KAAK,QAAQ;AAAA,EAC1B;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