@noego/trust 0.1.0
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 +91 -0
- package/dist/chunk-2KNNLUSN.js +1084 -0
- package/dist/chunk-2KNNLUSN.js.map +1 -0
- package/dist/cli/index.js +220 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/eslint/index.d.ts +271 -0
- package/dist/eslint/index.js +114 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/index.cjs +59 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +42 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import * as eslint from 'eslint';
|
|
2
|
+
import { ESLint, Linter } from 'eslint';
|
|
3
|
+
import * as TS from 'typescript';
|
|
4
|
+
|
|
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
|
+
interface PresetDefinition {
|
|
70
|
+
readonly $comment?: string;
|
|
71
|
+
readonly extend?: string;
|
|
72
|
+
readonly trust?: readonly string[];
|
|
73
|
+
readonly distrust?: readonly string[];
|
|
74
|
+
}
|
|
75
|
+
declare const PRESETS: Readonly<Record<string, PresetDefinition>>;
|
|
76
|
+
|
|
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
|
+
interface MatchedEntry {
|
|
102
|
+
readonly source: string;
|
|
103
|
+
readonly entry: string;
|
|
104
|
+
}
|
|
105
|
+
type Verdict = {
|
|
106
|
+
readonly kind: 'unresolved';
|
|
107
|
+
} | {
|
|
108
|
+
readonly kind: 'first-party';
|
|
109
|
+
readonly origin: OriginInfo;
|
|
110
|
+
} | {
|
|
111
|
+
readonly kind: 'returns-result';
|
|
112
|
+
readonly origin: OriginInfo;
|
|
113
|
+
} | {
|
|
114
|
+
readonly kind: 'trusted';
|
|
115
|
+
readonly origin: OriginInfo;
|
|
116
|
+
readonly by: MatchedEntry;
|
|
117
|
+
} | {
|
|
118
|
+
readonly kind: 'untrusted';
|
|
119
|
+
readonly origin: OriginInfo;
|
|
120
|
+
readonly distrustedBy?: MatchedEntry;
|
|
121
|
+
} | {
|
|
122
|
+
readonly kind: 'calls-ignored';
|
|
123
|
+
readonly origin: OriginInfo;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
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
|
|
128
|
+
* inside the base may only continue with `/`, so `lodash` does not cover the package `lodash.merge`.
|
|
129
|
+
*/
|
|
130
|
+
declare function entryMatches(entry: string, origin: string, base?: string): boolean;
|
|
131
|
+
declare class TrustPolicy {
|
|
132
|
+
private readonly ts;
|
|
133
|
+
private readonly checker;
|
|
134
|
+
readonly zones: Zones;
|
|
135
|
+
readonly origins: OriginResolver;
|
|
136
|
+
private readonly levels;
|
|
137
|
+
constructor(ts: TypeScript, checker: TS.TypeChecker, config: TrustConfig, extraTrust?: readonly string[]);
|
|
138
|
+
/**
|
|
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.
|
|
142
|
+
*/
|
|
143
|
+
lookup(origin: string, base?: string): {
|
|
144
|
+
trusted: true;
|
|
145
|
+
by: MatchedEntry;
|
|
146
|
+
} | {
|
|
147
|
+
trusted: false;
|
|
148
|
+
distrustedBy?: MatchedEntry;
|
|
149
|
+
};
|
|
150
|
+
classify(node: TS.CallExpression | TS.NewExpression): Verdict;
|
|
151
|
+
calleeDeclaration(node: TS.CallExpression | TS.NewExpression): {
|
|
152
|
+
declaration: TS.Node;
|
|
153
|
+
signature?: TS.Signature;
|
|
154
|
+
} | null;
|
|
155
|
+
/** Declared return type is Result / Promise<Result> from @noego/trust (every union member is Ok or Err). */
|
|
156
|
+
returnsResult(signature: TS.Signature): boolean;
|
|
157
|
+
isResultType(type: TS.Type): boolean;
|
|
158
|
+
/** True when every member of the type is an `Err` from @noego/trust. */
|
|
159
|
+
isErrType(type: TS.Type): boolean;
|
|
160
|
+
/** 'ok' | 'err' when the type is @noego/trust's Ok/Err (by the declaration of its `ok` property). */
|
|
161
|
+
resultVariant(type: TS.Type): 'ok' | 'err' | null;
|
|
162
|
+
/** Name of the @noego/trust function a call resolves to (`err`, `tryResult`, …), else null. */
|
|
163
|
+
trustFunctionName(node: TS.CallExpression): string | null;
|
|
164
|
+
}
|
|
165
|
+
|
|
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
|
+
type Guard = {
|
|
174
|
+
readonly status: 'unguarded';
|
|
175
|
+
} | {
|
|
176
|
+
readonly status: 'guarded';
|
|
177
|
+
readonly via: 'try' | 'sync-callback' | 'async-callback';
|
|
178
|
+
} | {
|
|
179
|
+
readonly status: 'badCatch';
|
|
180
|
+
readonly problem: CatchProblem;
|
|
181
|
+
};
|
|
182
|
+
interface GuardContext {
|
|
183
|
+
/** The returned expression is an `Err` (typed: by declaration; untyped: `Result.err(...)`/`err(...)` by name). */
|
|
184
|
+
isResultErr(expression: AstNode): boolean;
|
|
185
|
+
/** The call is `Result.err(...)` / `err(...)` itself (for the raw-caught-value check). */
|
|
186
|
+
isErrCall(expression: AstNode): boolean;
|
|
187
|
+
/** 'sync' for Result.try, 'async' for Result.tryAsync, else null. */
|
|
188
|
+
trustTryKind(call: AstNode): 'sync' | 'async' | null;
|
|
189
|
+
}
|
|
190
|
+
/** Every path through `statement` ends in return (or throw). */
|
|
191
|
+
declare function alwaysExits(statement: AstNode | null | undefined): boolean;
|
|
192
|
+
/** Null when the catch clause returns Result.err(...) on every path, else the problem. */
|
|
193
|
+
declare function catchProblem(handler: AstNode, context: GuardContext): CatchProblem | null;
|
|
194
|
+
/** 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 Result.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 Result.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
|
+
};
|
|
246
|
+
|
|
247
|
+
interface TrustRuleOptions {
|
|
248
|
+
/** trust.config.json path, relative to the ESLint cwd. */
|
|
249
|
+
readonly configFile?: string;
|
|
250
|
+
/** Extra trusted origins (applied before the config chain). */
|
|
251
|
+
readonly trust?: readonly string[];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare const rules: {
|
|
255
|
+
'untrusted-call-must-return-result': eslint.Rule.RuleModule;
|
|
256
|
+
'throw-must-return-result': eslint.Rule.RuleModule;
|
|
257
|
+
};
|
|
258
|
+
interface TypedConfigOptions {
|
|
259
|
+
/** Files to check (flat-config globs). They must be in a tsconfig the project service can find. */
|
|
260
|
+
readonly files: readonly string[];
|
|
261
|
+
readonly ignores?: readonly string[];
|
|
262
|
+
/** trust.config.json path relative to the ESLint cwd (default "trust.config.json"). */
|
|
263
|
+
readonly configFile?: string;
|
|
264
|
+
readonly severity?: Linter.RuleSeverity;
|
|
265
|
+
}
|
|
266
|
+
declare const plugin: ESLint.Plugin;
|
|
267
|
+
|
|
268
|
+
/** Flat config that registers the plugin as `trust` and enables both rules for `files`. Needs typed linting. */
|
|
269
|
+
declare function typedConfig(options: TypedConfigOptions): Linter.Config[];
|
|
270
|
+
|
|
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 };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CATCH_MESSAGES,
|
|
3
|
+
OPTIONS_SCHEMA,
|
|
4
|
+
OriginResolver,
|
|
5
|
+
PRESETS,
|
|
6
|
+
THROW_RULE,
|
|
7
|
+
TrustConfigError,
|
|
8
|
+
TrustPolicy,
|
|
9
|
+
UNTRUSTED_CALL_MESSAGES,
|
|
10
|
+
UNTRUSTED_CALL_RULE,
|
|
11
|
+
Zones,
|
|
12
|
+
alwaysExits,
|
|
13
|
+
catchProblem,
|
|
14
|
+
compareToBaseline,
|
|
15
|
+
countFindings,
|
|
16
|
+
effectiveTrustList,
|
|
17
|
+
entryMatches,
|
|
18
|
+
findingsFromResults,
|
|
19
|
+
guardOf,
|
|
20
|
+
loadTrustConfig,
|
|
21
|
+
normalizeOrigin,
|
|
22
|
+
originFromMessage,
|
|
23
|
+
parseBaseline,
|
|
24
|
+
serializeBaseline,
|
|
25
|
+
setupRule,
|
|
26
|
+
untrusted_call_must_return_result_default
|
|
27
|
+
} from "../chunk-2KNNLUSN.js";
|
|
28
|
+
|
|
29
|
+
// src/eslint/rules/throw-must-return-result.ts
|
|
30
|
+
function forThrow(template) {
|
|
31
|
+
return template.replace("{{target}}", "this `throw`");
|
|
32
|
+
}
|
|
33
|
+
var THROW_MESSAGES = {
|
|
34
|
+
escapes: "`throw` must be inside a `try` (same function) whose `catch` returns Result.err(...), or inside Result.try/tryAsync.",
|
|
35
|
+
rethrow: forThrow(CATCH_MESSAGES.rethrow),
|
|
36
|
+
notResultErr: forThrow(CATCH_MESSAGES.notResultErr),
|
|
37
|
+
rawCatchValue: forThrow(CATCH_MESSAGES.rawCatchValue),
|
|
38
|
+
notAllPaths: forThrow(CATCH_MESSAGES.notAllPaths)
|
|
39
|
+
};
|
|
40
|
+
var rule = {
|
|
41
|
+
meta: {
|
|
42
|
+
type: "problem",
|
|
43
|
+
docs: { description: "Require every throw to be caught locally and returned as Result.err." },
|
|
44
|
+
schema: OPTIONS_SCHEMA,
|
|
45
|
+
messages: THROW_MESSAGES
|
|
46
|
+
},
|
|
47
|
+
create(context) {
|
|
48
|
+
const setup = setupRule(context);
|
|
49
|
+
if (setup.zone !== "checked") return {};
|
|
50
|
+
return {
|
|
51
|
+
ThrowStatement(node) {
|
|
52
|
+
const guard = guardOf(node, setup.guardContext);
|
|
53
|
+
if (guard.status === "unguarded") context.report({ node, messageId: "escapes" });
|
|
54
|
+
else if (guard.status === "badCatch") context.report({ node, messageId: guard.problem });
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var throw_must_return_result_default = rule;
|
|
60
|
+
|
|
61
|
+
// src/eslint/index.ts
|
|
62
|
+
var rules = {
|
|
63
|
+
"untrusted-call-must-return-result": untrusted_call_must_return_result_default,
|
|
64
|
+
"throw-must-return-result": throw_must_return_result_default
|
|
65
|
+
};
|
|
66
|
+
var plugin = {
|
|
67
|
+
meta: { name: "@noego/trust" },
|
|
68
|
+
rules
|
|
69
|
+
};
|
|
70
|
+
var eslint_default = plugin;
|
|
71
|
+
function typedConfig(options) {
|
|
72
|
+
const severity = options.severity ?? "warn";
|
|
73
|
+
const ruleOptions = { configFile: options.configFile ?? "trust.config.json" };
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
name: "@noego/trust/typed",
|
|
77
|
+
files: [...options.files],
|
|
78
|
+
ignores: [...options.ignores ?? []],
|
|
79
|
+
plugins: { trust: plugin },
|
|
80
|
+
rules: {
|
|
81
|
+
"trust/untrusted-call-must-return-result": [severity, ruleOptions],
|
|
82
|
+
"trust/throw-must-return-result": [severity, ruleOptions]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
OriginResolver,
|
|
89
|
+
PRESETS,
|
|
90
|
+
THROW_MESSAGES,
|
|
91
|
+
THROW_RULE,
|
|
92
|
+
TrustConfigError,
|
|
93
|
+
TrustPolicy,
|
|
94
|
+
UNTRUSTED_CALL_MESSAGES,
|
|
95
|
+
UNTRUSTED_CALL_RULE,
|
|
96
|
+
Zones,
|
|
97
|
+
alwaysExits,
|
|
98
|
+
catchProblem,
|
|
99
|
+
compareToBaseline,
|
|
100
|
+
countFindings,
|
|
101
|
+
eslint_default as default,
|
|
102
|
+
effectiveTrustList,
|
|
103
|
+
entryMatches,
|
|
104
|
+
findingsFromResults,
|
|
105
|
+
guardOf,
|
|
106
|
+
loadTrustConfig,
|
|
107
|
+
normalizeOrigin,
|
|
108
|
+
originFromMessage,
|
|
109
|
+
parseBaseline,
|
|
110
|
+
rules,
|
|
111
|
+
serializeBaseline,
|
|
112
|
+
typedConfig
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/eslint/rules/throw-must-return-result.ts","../../src/eslint/index.ts"],"sourcesContent":["// Every `throw` in checked code must be guarded: inside a `try` (same function) whose `catch`\n// returns Result.err(...) on every path, or inside a Result.try / Result.tryAsync callback.\n// Works with or without type information; with it, Result.err is recognised by declaration.\nimport type { Rule } from 'eslint';\nimport { CATCH_MESSAGES, guardOf, type AstNode, type CatchProblem } from '../guard.js';\nimport { OPTIONS_SCHEMA, setupRule } from '../rule-setup.js';\n\nfunction forThrow(template: string): string {\n return template.replace('{{target}}', 'this `throw`');\n}\n\nexport const THROW_MESSAGES = {\n escapes: '`throw` must be inside a `try` (same function) whose `catch` returns Result.err(...), or inside Result.try/tryAsync.',\n rethrow: forThrow(CATCH_MESSAGES.rethrow),\n notResultErr: forThrow(CATCH_MESSAGES.notResultErr),\n rawCatchValue: forThrow(CATCH_MESSAGES.rawCatchValue),\n notAllPaths: forThrow(CATCH_MESSAGES.notAllPaths),\n} as const satisfies Record<string, string> & Record<CatchProblem, string>;\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: { description: 'Require every throw to be caught locally and returned as Result.err.' },\n schema: OPTIONS_SCHEMA as unknown as Rule.RuleMetaData['schema'],\n messages: THROW_MESSAGES,\n },\n create(context) {\n const setup = setupRule(context);\n if (setup.zone !== 'checked') return {};\n return {\n ThrowStatement(node) {\n const guard = guardOf(node as unknown as AstNode, setup.guardContext);\n if (guard.status === 'unguarded') context.report({ node, messageId: 'escapes' });\n else if (guard.status === 'badCatch') context.report({ node, messageId: guard.problem });\n },\n };\n },\n};\n\nexport default rule;\n","// @noego/trust/eslint — ESLint plugin, trust config loader, and policy.\n//\n// import { typedConfig } from '@noego/trust/eslint';\n// export default [\n// ...typedConfig({ files: ['server/**/*.ts'], configFile: 'trust.config.json' }),\n// ];\nimport type { ESLint, Linter } from 'eslint';\nimport throwMustReturnResult from './rules/throw-must-return-result.js';\nimport untrustedCallMustReturnResult from './rules/untrusted-call-must-return-result.js';\n\nexport const rules = {\n 'untrusted-call-must-return-result': untrustedCallMustReturnResult,\n 'throw-must-return-result': throwMustReturnResult,\n};\n\nexport interface TypedConfigOptions {\n /** Files to check (flat-config globs). They must be in a tsconfig the project service can find. */\n readonly files: readonly string[];\n readonly ignores?: readonly string[];\n /** trust.config.json path relative to the ESLint cwd (default \"trust.config.json\"). */\n readonly configFile?: string;\n readonly severity?: Linter.RuleSeverity;\n}\n\nconst plugin: ESLint.Plugin = {\n meta: { name: '@noego/trust' },\n rules,\n};\n\nexport default plugin;\n\n/** Flat config that registers the plugin as `trust` and enables both rules for `files`. Needs typed linting. */\nexport function typedConfig(options: TypedConfigOptions): Linter.Config[] {\n const severity = options.severity ?? 'warn';\n const ruleOptions = { configFile: options.configFile ?? 'trust.config.json' };\n return [\n {\n name: '@noego/trust/typed',\n files: [...options.files],\n ignores: [...(options.ignores ?? [])],\n plugins: { trust: plugin },\n rules: {\n 'trust/untrusted-call-must-return-result': [severity, ruleOptions],\n 'trust/throw-must-return-result': [severity, ruleOptions],\n },\n },\n ];\n}\n\nexport {\n effectiveTrustList,\n loadTrustConfig,\n normalizeOrigin,\n TrustConfigError,\n type LoadTrustConfigOptions,\n type TrustConfig,\n type TrustEntry,\n type TrustLevel,\n} from './config.js';\nexport { PRESETS, type PresetDefinition } from './presets.js';\nexport { entryMatches, TrustPolicy, type MatchedEntry, type Verdict } from './policy.js';\nexport { OriginResolver, type OriginInfo } from './origin.js';\nexport { Zones, type Zone, type ZoneGroup } from './zones.js';\nexport { alwaysExits, catchProblem, guardOf, type CatchProblem, type Guard, type GuardContext } from './guard.js';\nexport {\n compareToBaseline,\n countFindings,\n findingsFromResults,\n originFromMessage,\n parseBaseline,\n serializeBaseline,\n THROW_RULE,\n UNTRUSTED_CALL_RULE,\n type BaselineCounts,\n type BaselineDelta,\n type Finding,\n} from './baseline.js';\nexport { THROW_MESSAGES } from './rules/throw-must-return-result.js';\nexport { UNTRUSTED_CALL_MESSAGES } from './rules/untrusted-call-must-return-result.js';\nexport type { TrustRuleOptions } from './rule-setup.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAS,SAAS,UAA0B;AAC1C,SAAO,SAAS,QAAQ,cAAc,cAAc;AACtD;AAEO,IAAM,iBAAiB;AAAA,EAC5B,SAAS;AAAA,EACT,SAAS,SAAS,eAAe,OAAO;AAAA,EACxC,cAAc,SAAS,eAAe,YAAY;AAAA,EAClD,eAAe,SAAS,eAAe,aAAa;AAAA,EACpD,aAAa,SAAS,eAAe,WAAW;AAClD;AAEA,IAAM,OAAwB;AAAA,EAC5B,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM,EAAE,aAAa,uEAAuE;AAAA,IAC5F,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,OAAO,SAAS;AACd,UAAM,QAAQ,UAAU,OAAO;AAC/B,QAAI,MAAM,SAAS,UAAW,QAAO,CAAC;AACtC,WAAO;AAAA,MACL,eAAe,MAAM;AACnB,cAAM,QAAQ,QAAQ,MAA4B,MAAM,YAAY;AACpE,YAAI,MAAM,WAAW,YAAa,SAAQ,OAAO,EAAE,MAAM,WAAW,UAAU,CAAC;AAAA,iBACtE,MAAM,WAAW,WAAY,SAAQ,OAAO,EAAE,MAAM,WAAW,MAAM,QAAQ,CAAC;AAAA,MACzF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,mCAAQ;;;AC7BR,IAAM,QAAQ;AAAA,EACnB,qCAAqC;AAAA,EACrC,4BAA4B;AAC9B;AAWA,IAAM,SAAwB;AAAA,EAC5B,MAAM,EAAE,MAAM,eAAe;AAAA,EAC7B;AACF;AAEA,IAAO,iBAAQ;AAGR,SAAS,YAAY,SAA8C;AACxE,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,cAAc,EAAE,YAAY,QAAQ,cAAc,oBAAoB;AAC5E,SAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,OAAO,CAAC,GAAG,QAAQ,KAAK;AAAA,MACxB,SAAS,CAAC,GAAI,QAAQ,WAAW,CAAC,CAAE;AAAA,MACpC,SAAS,EAAE,OAAO,OAAO;AAAA,MACzB,OAAO;AAAA,QACL,2CAA2C,CAAC,UAAU,WAAW;AAAA,QACjE,kCAAkC,CAAC,UAAU,WAAW;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Result: () => Result,
|
|
24
|
+
err: () => err,
|
|
25
|
+
ok: () => ok,
|
|
26
|
+
tryResult: () => tryResult,
|
|
27
|
+
tryResultAsync: () => tryResultAsync
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
function ok(value) {
|
|
31
|
+
return { ok: true, value };
|
|
32
|
+
}
|
|
33
|
+
function err(error) {
|
|
34
|
+
return { ok: false, error };
|
|
35
|
+
}
|
|
36
|
+
function tryResult(fn, onError) {
|
|
37
|
+
try {
|
|
38
|
+
return ok(fn());
|
|
39
|
+
} catch (cause) {
|
|
40
|
+
return err(onError(cause));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function tryResultAsync(fn, onError) {
|
|
44
|
+
try {
|
|
45
|
+
return ok(await fn());
|
|
46
|
+
} catch (cause) {
|
|
47
|
+
return err(onError(cause));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var Result = { ok, err, try: tryResult, tryAsync: tryResultAsync };
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
Result,
|
|
54
|
+
err,
|
|
55
|
+
ok,
|
|
56
|
+
tryResult,
|
|
57
|
+
tryResultAsync
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Closed result primitive: expected failures are values, not exceptions.\n *\n * `Result<T, E>` is `Ok<T> | Err<E>`, discriminated by `ok`. This module has no\n * imports so it is safe in any bundle (Node, Electron main, renderer, browser).\n *\n * The `@noego/trust/eslint` rules recognise these declarations by identity (not by\n * name): a call whose declared return type is a `Result` from this module is\n * trusted, and a `catch` is accepted when it returns an `Err` from this module.\n */\nexport type Ok<T> = { readonly ok: true; readonly value: T };\nexport type Err<E> = { readonly ok: false; readonly error: E };\nexport type Result<T, E> = Ok<T> | Err<E>;\n\n/** Wraps a success value. */\nexport function ok<T>(value: T): Ok<T> {\n return { ok: true, value };\n}\n\n/** Wraps a failure value. Pass a typed error, not a raw caught value. */\nexport function err<E>(error: E): Err<E> {\n return { ok: false, error };\n}\n\n/**\n * Runs `fn` and converts anything it throws into `Err` via `onError`.\n * Calls made directly inside `fn` count as guarded for the trust lint rules.\n */\nexport function tryResult<T, E>(fn: () => T, onError: (cause: unknown) => E): Result<T, E> {\n try {\n return ok(fn());\n } catch (cause) {\n return err(onError(cause));\n }\n}\n\n/**\n * Awaits `fn` and converts a throw or rejection into `Err` via `onError`.\n * Calls made directly inside `fn` count as guarded for the trust lint rules.\n */\nexport async function tryResultAsync<T, E>(\n fn: () => T | PromiseLike<T>,\n onError: (cause: unknown) => E,\n): Promise<Result<T, E>> {\n try {\n return ok(await fn());\n } catch (cause) {\n return err(onError(cause));\n }\n}\n\n/** Namespace form: `Result.ok`, `Result.err`, `Result.try`, `Result.tryAsync`. */\nexport const Result: {\n readonly ok: typeof ok;\n readonly err: typeof err;\n readonly try: typeof tryResult;\n readonly tryAsync: typeof tryResultAsync;\n} = { ok, err, try: tryResult, tryAsync: tryResultAsync };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,GAAM,OAAiB;AACrC,SAAO,EAAE,IAAI,MAAM,MAAM;AAC3B;AAGO,SAAS,IAAO,OAAkB;AACvC,SAAO,EAAE,IAAI,OAAO,MAAM;AAC5B;AAMO,SAAS,UAAgB,IAAa,SAA8C;AACzF,MAAI;AACF,WAAO,GAAG,GAAG,CAAC;AAAA,EAChB,SAAS,OAAO;AACd,WAAO,IAAI,QAAQ,KAAK,CAAC;AAAA,EAC3B;AACF;AAMA,eAAsB,eACpB,IACA,SACuB;AACvB,MAAI;AACF,WAAO,GAAG,MAAM,GAAG,CAAC;AAAA,EACtB,SAAS,OAAO;AACd,WAAO,IAAI,QAAQ,KAAK,CAAC;AAAA,EAC3B;AACF;AAGO,IAAM,SAKT,EAAE,IAAI,KAAK,KAAK,WAAW,UAAU,eAAe;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Closed result primitive: expected failures are values, not exceptions.
|
|
3
|
+
*
|
|
4
|
+
* `Result<T, E>` is `Ok<T> | Err<E>`, discriminated by `ok`. This module has no
|
|
5
|
+
* imports so it is safe in any bundle (Node, Electron main, renderer, browser).
|
|
6
|
+
*
|
|
7
|
+
* The `@noego/trust/eslint` rules recognise these declarations by identity (not by
|
|
8
|
+
* name): a call whose declared return type is a `Result` from this module is
|
|
9
|
+
* trusted, and a `catch` is accepted when it returns an `Err` from this module.
|
|
10
|
+
*/
|
|
11
|
+
type Ok<T> = {
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly value: T;
|
|
14
|
+
};
|
|
15
|
+
type Err<E> = {
|
|
16
|
+
readonly ok: false;
|
|
17
|
+
readonly error: E;
|
|
18
|
+
};
|
|
19
|
+
/** Wraps a success value. */
|
|
20
|
+
declare function ok<T>(value: T): Ok<T>;
|
|
21
|
+
/** Wraps a failure value. Pass a typed error, not a raw caught value. */
|
|
22
|
+
declare function err<E>(error: E): Err<E>;
|
|
23
|
+
/**
|
|
24
|
+
* Runs `fn` and converts anything it throws into `Err` via `onError`.
|
|
25
|
+
* Calls made directly inside `fn` count as guarded for the trust lint rules.
|
|
26
|
+
*/
|
|
27
|
+
declare function tryResult<T, E>(fn: () => T, onError: (cause: unknown) => E): Result<T, E>;
|
|
28
|
+
/**
|
|
29
|
+
* Awaits `fn` and converts a throw or rejection into `Err` via `onError`.
|
|
30
|
+
* Calls made directly inside `fn` count as guarded for the trust lint rules.
|
|
31
|
+
*/
|
|
32
|
+
declare function tryResultAsync<T, E>(fn: () => T | PromiseLike<T>, onError: (cause: unknown) => E): Promise<Result<T, E>>;
|
|
33
|
+
type Result<T, E> = Ok<T> | Err<E>;
|
|
34
|
+
/** Namespace form: `Result.ok`, `Result.err`, `Result.try`, `Result.tryAsync`. */
|
|
35
|
+
declare const Result: {
|
|
36
|
+
readonly ok: typeof ok;
|
|
37
|
+
readonly err: typeof err;
|
|
38
|
+
readonly try: typeof tryResult;
|
|
39
|
+
readonly tryAsync: typeof tryResultAsync;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { type Err, type Ok, Result, err, ok, tryResult, tryResultAsync };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Closed result primitive: expected failures are values, not exceptions.
|
|
3
|
+
*
|
|
4
|
+
* `Result<T, E>` is `Ok<T> | Err<E>`, discriminated by `ok`. This module has no
|
|
5
|
+
* imports so it is safe in any bundle (Node, Electron main, renderer, browser).
|
|
6
|
+
*
|
|
7
|
+
* The `@noego/trust/eslint` rules recognise these declarations by identity (not by
|
|
8
|
+
* name): a call whose declared return type is a `Result` from this module is
|
|
9
|
+
* trusted, and a `catch` is accepted when it returns an `Err` from this module.
|
|
10
|
+
*/
|
|
11
|
+
type Ok<T> = {
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly value: T;
|
|
14
|
+
};
|
|
15
|
+
type Err<E> = {
|
|
16
|
+
readonly ok: false;
|
|
17
|
+
readonly error: E;
|
|
18
|
+
};
|
|
19
|
+
/** Wraps a success value. */
|
|
20
|
+
declare function ok<T>(value: T): Ok<T>;
|
|
21
|
+
/** Wraps a failure value. Pass a typed error, not a raw caught value. */
|
|
22
|
+
declare function err<E>(error: E): Err<E>;
|
|
23
|
+
/**
|
|
24
|
+
* Runs `fn` and converts anything it throws into `Err` via `onError`.
|
|
25
|
+
* Calls made directly inside `fn` count as guarded for the trust lint rules.
|
|
26
|
+
*/
|
|
27
|
+
declare function tryResult<T, E>(fn: () => T, onError: (cause: unknown) => E): Result<T, E>;
|
|
28
|
+
/**
|
|
29
|
+
* Awaits `fn` and converts a throw or rejection into `Err` via `onError`.
|
|
30
|
+
* Calls made directly inside `fn` count as guarded for the trust lint rules.
|
|
31
|
+
*/
|
|
32
|
+
declare function tryResultAsync<T, E>(fn: () => T | PromiseLike<T>, onError: (cause: unknown) => E): Promise<Result<T, E>>;
|
|
33
|
+
type Result<T, E> = Ok<T> | Err<E>;
|
|
34
|
+
/** Namespace form: `Result.ok`, `Result.err`, `Result.try`, `Result.tryAsync`. */
|
|
35
|
+
declare const Result: {
|
|
36
|
+
readonly ok: typeof ok;
|
|
37
|
+
readonly err: typeof err;
|
|
38
|
+
readonly try: typeof tryResult;
|
|
39
|
+
readonly tryAsync: typeof tryResultAsync;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { type Err, type Ok, Result, err, ok, tryResult, tryResultAsync };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function ok(value) {
|
|
3
|
+
return { ok: true, value };
|
|
4
|
+
}
|
|
5
|
+
function err(error) {
|
|
6
|
+
return { ok: false, error };
|
|
7
|
+
}
|
|
8
|
+
function tryResult(fn, onError) {
|
|
9
|
+
try {
|
|
10
|
+
return ok(fn());
|
|
11
|
+
} catch (cause) {
|
|
12
|
+
return err(onError(cause));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function tryResultAsync(fn, onError) {
|
|
16
|
+
try {
|
|
17
|
+
return ok(await fn());
|
|
18
|
+
} catch (cause) {
|
|
19
|
+
return err(onError(cause));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
var Result = { ok, err, try: tryResult, tryAsync: tryResultAsync };
|
|
23
|
+
export {
|
|
24
|
+
Result,
|
|
25
|
+
err,
|
|
26
|
+
ok,
|
|
27
|
+
tryResult,
|
|
28
|
+
tryResultAsync
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Closed result primitive: expected failures are values, not exceptions.\n *\n * `Result<T, E>` is `Ok<T> | Err<E>`, discriminated by `ok`. This module has no\n * imports so it is safe in any bundle (Node, Electron main, renderer, browser).\n *\n * The `@noego/trust/eslint` rules recognise these declarations by identity (not by\n * name): a call whose declared return type is a `Result` from this module is\n * trusted, and a `catch` is accepted when it returns an `Err` from this module.\n */\nexport type Ok<T> = { readonly ok: true; readonly value: T };\nexport type Err<E> = { readonly ok: false; readonly error: E };\nexport type Result<T, E> = Ok<T> | Err<E>;\n\n/** Wraps a success value. */\nexport function ok<T>(value: T): Ok<T> {\n return { ok: true, value };\n}\n\n/** Wraps a failure value. Pass a typed error, not a raw caught value. */\nexport function err<E>(error: E): Err<E> {\n return { ok: false, error };\n}\n\n/**\n * Runs `fn` and converts anything it throws into `Err` via `onError`.\n * Calls made directly inside `fn` count as guarded for the trust lint rules.\n */\nexport function tryResult<T, E>(fn: () => T, onError: (cause: unknown) => E): Result<T, E> {\n try {\n return ok(fn());\n } catch (cause) {\n return err(onError(cause));\n }\n}\n\n/**\n * Awaits `fn` and converts a throw or rejection into `Err` via `onError`.\n * Calls made directly inside `fn` count as guarded for the trust lint rules.\n */\nexport async function tryResultAsync<T, E>(\n fn: () => T | PromiseLike<T>,\n onError: (cause: unknown) => E,\n): Promise<Result<T, E>> {\n try {\n return ok(await fn());\n } catch (cause) {\n return err(onError(cause));\n }\n}\n\n/** Namespace form: `Result.ok`, `Result.err`, `Result.try`, `Result.tryAsync`. */\nexport const Result: {\n readonly ok: typeof ok;\n readonly err: typeof err;\n readonly try: typeof tryResult;\n readonly tryAsync: typeof tryResultAsync;\n} = { ok, err, try: tryResult, tryAsync: tryResultAsync };\n"],"mappings":";AAeO,SAAS,GAAM,OAAiB;AACrC,SAAO,EAAE,IAAI,MAAM,MAAM;AAC3B;AAGO,SAAS,IAAO,OAAkB;AACvC,SAAO,EAAE,IAAI,OAAO,MAAM;AAC5B;AAMO,SAAS,UAAgB,IAAa,SAA8C;AACzF,MAAI;AACF,WAAO,GAAG,GAAG,CAAC;AAAA,EAChB,SAAS,OAAO;AACd,WAAO,IAAI,QAAQ,KAAK,CAAC;AAAA,EAC3B;AACF;AAMA,eAAsB,eACpB,IACA,SACuB;AACvB,MAAI;AACF,WAAO,GAAG,MAAM,GAAG,CAAC;AAAA,EACtB,SAAS,OAAO;AACd,WAAO,IAAI,QAAQ,KAAK,CAAC;AAAA,EAC3B;AACF;AAGO,IAAM,SAKT,EAAE,IAAI,KAAK,KAAK,WAAW,UAAU,eAAe;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@noego/trust",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Result type plus type-aware ESLint rules that make failure handling explicit: untrusted calls and throws must be caught locally and returned as Result.err.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"trust": "dist/cli/index.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup",
|
|
14
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"test:watch": "vitest",
|
|
17
|
+
"prepublishOnly": "npm run typecheck && npm test && npm run build"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"require": "./dist/index.cjs",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./eslint": {
|
|
27
|
+
"types": "./dist/eslint/index.d.ts",
|
|
28
|
+
"import": "./dist/eslint/index.js",
|
|
29
|
+
"default": "./dist/eslint/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"author": "Shavauhn Gabay",
|
|
37
|
+
"license": "ISC",
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=20"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"minimatch": "^10.0.3"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"eslint": ">=9",
|
|
49
|
+
"typescript": ">=5",
|
|
50
|
+
"typescript-eslint": ">=8"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"eslint": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"typescript": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"typescript-eslint": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^22.10.0",
|
|
65
|
+
"eslint": "^10.1.0",
|
|
66
|
+
"tsup": "^8.5.0",
|
|
67
|
+
"typescript": "~5.9.3",
|
|
68
|
+
"typescript-eslint": "^8.57.1",
|
|
69
|
+
"vitest": "~4.0.18"
|
|
70
|
+
}
|
|
71
|
+
}
|