@stateward/core 1.2.1 → 1.3.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/dist/analyses.d.ts +37 -0
- package/dist/analyses.js +57 -0
- package/dist/backend/program-record.d.ts +7 -0
- package/dist/backend/typescript6.d.ts +35 -32
- package/dist/backend/typescript6.js +3804 -163
- package/dist/baseline.d.ts +1 -1
- package/dist/baseline.js +14 -10
- package/dist/cache.d.ts +89 -5
- package/dist/cache.js +271 -40
- package/dist/checker.d.ts +11 -1
- package/dist/checker.js +32 -2
- package/dist/class-id.d.ts +34 -0
- package/dist/class-id.js +93 -0
- package/dist/code-text.d.ts +8 -0
- package/dist/code-text.js +66 -0
- package/dist/config-file.js +7 -5
- package/dist/config.d.ts +10 -2
- package/dist/config.js +541 -49
- package/dist/define.d.ts +8 -2
- package/dist/disk-cache.d.ts +2 -0
- package/dist/disk-cache.js +77 -11
- package/dist/engine.d.ts +51 -1
- package/dist/engine.js +517 -42
- package/dist/fact-lines.d.ts +31 -0
- package/dist/fact-lines.js +197 -0
- package/dist/facts-versions.d.ts +27 -0
- package/dist/facts-versions.js +99 -0
- package/dist/fixes.js +9 -4
- package/dist/guarantees.d.ts +63 -11
- package/dist/guarantees.js +151 -21
- package/dist/ignores.d.ts +11 -0
- package/dist/ignores.js +74 -27
- package/dist/implementation.d.ts +0 -6
- package/dist/implementation.js +0 -17
- package/dist/index.d.ts +10 -9
- package/dist/index.js +14 -7
- package/dist/internal.d.ts +9 -5
- package/dist/internal.js +6 -3
- package/dist/lazy.d.ts +8 -1
- package/dist/lazy.js +27 -2
- package/dist/ledger.d.ts +77 -0
- package/dist/ledger.js +423 -0
- package/dist/off-by-default.d.ts +13 -0
- package/dist/off-by-default.js +15 -0
- package/dist/options.d.ts +21 -5
- package/dist/options.js +22 -7
- package/dist/package-facts.d.ts +211 -17
- package/dist/package-facts.js +520 -38
- package/dist/plan.d.ts +1 -1
- package/dist/plan.js +7 -2
- package/dist/release.d.ts +12 -21
- package/dist/release.js +28 -38
- package/dist/renamed.d.ts +22 -3
- package/dist/renamed.js +50 -16
- package/dist/rollout.js +7 -4
- package/dist/safe-calls.d.ts +26 -0
- package/dist/safe-calls.js +345 -0
- package/dist/severity.d.ts +1 -1
- package/dist/severity.js +17 -3
- package/dist/stated.d.ts +37 -0
- package/dist/stated.js +123 -0
- package/dist/test-runner.d.ts +18 -0
- package/dist/test-runner.js +483 -0
- package/dist/testing-tsc.d.ts +16 -0
- package/dist/testing-tsc.js +86 -0
- package/dist/testing.d.ts +5 -4
- package/dist/testing.js +6 -6
- package/dist/timing.d.ts +15 -0
- package/dist/timing.js +41 -2
- package/dist/types.d.ts +1068 -16
- package/dist/unread.d.ts +90 -0
- package/dist/unread.js +405 -0
- package/dist/vocabulary.d.ts +1 -1
- package/dist/vocabulary.js +1 -1
- package/package.json +4 -2
package/dist/guarantees.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { compareFindings } from "./engine.js";
|
|
2
|
+
import { indexLedger } from "./ledger.js";
|
|
3
|
+
import { STATED_RULE_ID } from "./stated.js";
|
|
2
4
|
function sameStart(a, b) {
|
|
3
5
|
return a.file === b.file && a.start === b.start;
|
|
4
6
|
}
|
|
@@ -7,16 +9,26 @@ function compareStated(a, b) {
|
|
|
7
9
|
return a.location.file < b.location.file ? -1 : 1;
|
|
8
10
|
return a.location.start - b.location.start || (a.guarantee < b.guarantee ? -1 : 1);
|
|
9
11
|
}
|
|
12
|
+
function comparePlace(a, b) {
|
|
13
|
+
if (a.file !== b.file)
|
|
14
|
+
return a.file < b.file ? -1 : 1;
|
|
15
|
+
return a.start - b.start || a.end - b.end;
|
|
16
|
+
}
|
|
10
17
|
function contains(place, inner) {
|
|
11
18
|
return place.file === inner.file && inner.start >= place.start && inner.end <= place.end;
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
|
-
*
|
|
15
|
-
* at its declaration; or, when it has a note at no
|
|
16
|
-
* place the guarantee covers (a file rule notes only
|
|
17
|
-
* at a Provider in another file names the context by
|
|
21
|
+
* The guarantees a finding is about when no rule said (`Finding.guarantees` is absent): a problem
|
|
22
|
+
* of the guarantee's rule with a related note at its declaration; or, when it has a note at no
|
|
23
|
+
* declaration of that rule, one that lies in a place the guarantee covers (a file rule notes only
|
|
24
|
+
* declarations in its own file, so a finding at a Provider in another file names the context by
|
|
25
|
+
* where it is). A guarantee no plugin lists (`STATED_RULE_ID`) is the one a note of any rule is at.
|
|
26
|
+
* This is the fallback for a rule that does not link its findings (`ReportProblem.against`).
|
|
18
27
|
*/
|
|
19
|
-
function
|
|
28
|
+
function aboutByPlace(finding, guarantee, declarations) {
|
|
29
|
+
if (guarantee.ruleId === STATED_RULE_ID) {
|
|
30
|
+
return finding.related.some((note) => sameStart(note.location, guarantee.location));
|
|
31
|
+
}
|
|
20
32
|
if (finding.ruleId !== guarantee.ruleId)
|
|
21
33
|
return false;
|
|
22
34
|
if (finding.related.some((note) => sameStart(note.location, guarantee.location)))
|
|
@@ -25,26 +37,122 @@ function isAbout(finding, guarantee, declarations) {
|
|
|
25
37
|
finding.related.some((note) => sameStart(note.location, other.location)));
|
|
26
38
|
return (!namesAnother && guarantee.covered.some((place) => contains(place.location, finding.location)));
|
|
27
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Whether a finding is about a guarantee: it names its declaration (`Finding.guarantees`), or, when
|
|
42
|
+
* no rule linked it, it lies where the guarantee is stated or covered (`aboutByPlace`).
|
|
43
|
+
*/
|
|
44
|
+
function isAbout(finding, guarantee, declarations) {
|
|
45
|
+
return finding.guarantees === undefined
|
|
46
|
+
? aboutByPlace(finding, guarantee, declarations)
|
|
47
|
+
: names(finding, guarantee);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether a finding names the guarantee: its declaration's id, and the rule that proves it (one
|
|
51
|
+
* declaration may state several guarantees, each proven by its own rule); a guarantee no plugin
|
|
52
|
+
* lists is named by a finding of any rule.
|
|
53
|
+
*/
|
|
54
|
+
function names(finding, guarantee) {
|
|
55
|
+
return (finding.guarantees?.includes(guarantee.declaration) === true &&
|
|
56
|
+
(guarantee.ruleId === STATED_RULE_ID || finding.ruleId === guarantee.ruleId));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Whether a finding counts against a guarantee: any severity, if the rule says it is against one
|
|
60
|
+
* or names one (`Finding.guarantees`).
|
|
61
|
+
*/
|
|
62
|
+
function counts(finding) {
|
|
63
|
+
return (finding.against === true || (finding.guarantees?.length ?? 0) > 0 || finding.severity !== "info");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The text of a place not checked from an `unknown` finding: its message without "not checked: ",
|
|
67
|
+
* then what to write instead, from its hint (the first way, when it lists several), so the line
|
|
68
|
+
* `stateward guarantees` prints says both.
|
|
69
|
+
*/
|
|
70
|
+
function reasonOf(message, hint) {
|
|
71
|
+
const what = message.startsWith(NOT_CHECKED) ? message.slice(NOT_CHECKED.length) : message;
|
|
72
|
+
const lines = hint.split("\n");
|
|
73
|
+
const way = lines.find((line) => line.startsWith("- "))?.slice(2) ?? lines[0] ?? "";
|
|
74
|
+
return way === "" ? what : `${what}: ${way}`;
|
|
75
|
+
}
|
|
76
|
+
const NOT_CHECKED = "not checked: ";
|
|
77
|
+
/** The `unknown` findings that name a guarantee, with the places they leave unchecked. */
|
|
78
|
+
function unknownPlaces(finding, guarantee) {
|
|
79
|
+
if (finding.kind !== "unknown" || !names(finding, guarantee))
|
|
80
|
+
return [];
|
|
81
|
+
return [{ location: finding.location, reason: reasonOf(finding.message, finding.hint) }];
|
|
82
|
+
}
|
|
28
83
|
/**
|
|
29
84
|
* Each stated guarantee with its status, in file and offset order. `findings` are a check's
|
|
30
|
-
* (after ignore comments, before a baseline: an accepted error still leaves it unproven)
|
|
31
|
-
* `
|
|
32
|
-
*
|
|
33
|
-
*
|
|
85
|
+
* (after ignore comments, before a baseline: an accepted error still leaves it unproven), and
|
|
86
|
+
* `inputs.ignored` the ones ignore comments hid: a guarantee is proven only when no finding
|
|
87
|
+
* stands against it before ignores and settings. `active` the rules that check
|
|
88
|
+
* ran. A finding is about a guarantee when it names its declaration (`Finding.guarantees`), or,
|
|
89
|
+
* for a finding no rule linked, lies where the guarantee is stated or covered (`aboutByPlace`); it
|
|
90
|
+
* counts at any severity once linked, and unless it is a weaker signal the rule judged an info.
|
|
91
|
+
* An `unknown` finding that names a guarantee leaves it "not checked" at its place, whatever the
|
|
92
|
+
* config's `unknowns` setting shows of it. With the check's reference ledger (`inputs.ledger`), so
|
|
93
|
+
* does every reference to a marked declaration its rule did not read (unmarked, marked unchecked,
|
|
94
|
+
* or only handed on), and it is unused only when it has no reference.
|
|
34
95
|
*/
|
|
35
|
-
export function proveGuarantees(stated, findings, active) {
|
|
96
|
+
export function proveGuarantees(stated, findings, active, inputs = {}) {
|
|
36
97
|
const problems = findings
|
|
37
98
|
.filter((finding) => finding.kind === "problem")
|
|
38
|
-
.filter(
|
|
99
|
+
.filter(counts);
|
|
100
|
+
const hidden = (inputs.ignored ?? []).flatMap(({ finding, reason }) => finding.kind === "problem" && counts(finding) ? [{ finding, reason }] : []);
|
|
101
|
+
const unknowns = [...findings, ...(inputs.ignored ?? []).map(({ finding }) => finding)].filter((finding) => finding.kind === "unknown");
|
|
102
|
+
const ledger = inputs.ledger === undefined ? undefined : indexLedger(inputs.ledger);
|
|
39
103
|
return [...stated].sort(compareStated).map((guarantee) => {
|
|
40
|
-
if (!active.has(guarantee.ruleId))
|
|
41
|
-
return { stated: guarantee, status: { kind: "off" } };
|
|
104
|
+
if (guarantee.ruleId !== STATED_RULE_ID && !active.has(guarantee.ruleId)) {
|
|
105
|
+
return { stated: guarantee, status: { kind: "off", places: [] } };
|
|
106
|
+
}
|
|
42
107
|
const errors = problems
|
|
43
108
|
.filter((finding) => isAbout(finding, guarantee, stated))
|
|
44
109
|
.sort(compareFindings);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
110
|
+
const ignored = hidden
|
|
111
|
+
.filter(({ finding }) => isAbout(finding, guarantee, stated))
|
|
112
|
+
.sort((a, b) => compareFindings(a.finding, b.finding));
|
|
113
|
+
if (errors.length > 0 || ignored.length > 0) {
|
|
114
|
+
return { stated: guarantee, status: { kind: "unproven", errors, ignored } };
|
|
115
|
+
}
|
|
116
|
+
const off = [
|
|
117
|
+
...guarantee.covered
|
|
118
|
+
.filter((place) => inputs.ruleOffAt?.(guarantee.ruleId, place.location.file) === true)
|
|
119
|
+
.map((place) => place.location),
|
|
120
|
+
...(inputs.silenced ?? []).flatMap((finding) => finding.kind !== "failure" && names(finding, guarantee) ? [finding.location] : []),
|
|
121
|
+
];
|
|
122
|
+
if (off.length > 0)
|
|
123
|
+
return { stated: guarantee, status: { kind: "off", places: off } };
|
|
124
|
+
const own = guarantee.unchecked ?? [];
|
|
125
|
+
// A guarantee a marker states, of a trait the ledger lists: its references are all known.
|
|
126
|
+
const listed = ledger !== undefined &&
|
|
127
|
+
(guarantee.source === undefined ||
|
|
128
|
+
guarantee.source.kind === "marker" ||
|
|
129
|
+
guarantee.source.kind === "tag") &&
|
|
130
|
+
ledger.traits.has(guarantee.guarantee);
|
|
131
|
+
const refs = listed ? ledger.refsOf(guarantee.declaration, guarantee.guarantee) : [];
|
|
132
|
+
// Imports, exports and types run nothing: a declaration only they name is unused.
|
|
133
|
+
const importsOnly = refs.length > 0 &&
|
|
134
|
+
refs.every((ref) => ref.form === "import" || ref.form === "export" || ref.form === "type");
|
|
135
|
+
const known = [...own];
|
|
136
|
+
const more = [];
|
|
137
|
+
for (const place of [
|
|
138
|
+
...unknowns.flatMap((finding) => unknownPlaces(finding, guarantee)),
|
|
139
|
+
...(listed && !importsOnly ? ledger.uncheckedOf(guarantee, refs) : []),
|
|
140
|
+
]) {
|
|
141
|
+
if (known.some((one) => sameStart(one.location, place.location)))
|
|
142
|
+
continue;
|
|
143
|
+
known.push(place);
|
|
144
|
+
more.push(place);
|
|
145
|
+
}
|
|
146
|
+
const unchecked = more.length === 0
|
|
147
|
+
? own
|
|
148
|
+
: [...own, ...more].sort((a, b) => comparePlace(a.location, b.location));
|
|
149
|
+
if (unchecked.length > 0) {
|
|
150
|
+
return { stated: guarantee, status: { kind: "unchecked", places: unchecked } };
|
|
151
|
+
}
|
|
152
|
+
if (importsOnly)
|
|
153
|
+
return { stated: guarantee, status: { kind: "unused", importsOnly: true } };
|
|
154
|
+
const unused = listed ? refs.length === 0 : guarantee.covered.length === 0;
|
|
155
|
+
if (unused)
|
|
48
156
|
return { stated: guarantee, status: { kind: "unused" } };
|
|
49
157
|
return { stated: guarantee, status: { kind: "proven" } };
|
|
50
158
|
});
|
|
@@ -54,21 +162,43 @@ export function counted(count, noun) {
|
|
|
54
162
|
return `${String(count)} ${count === 1 ? noun.one : noun.many}`;
|
|
55
163
|
}
|
|
56
164
|
const ERROR = { one: "error", many: "errors" };
|
|
165
|
+
/** The reasons of the comments that hide findings, each once, in order: "lives as long as the app". */
|
|
166
|
+
function reasonsOf(ignored) {
|
|
167
|
+
const reasons = [
|
|
168
|
+
...new Set(ignored.map(({ reason }) => reason).filter((reason) => reason !== "")),
|
|
169
|
+
];
|
|
170
|
+
return reasons.length === 0 ? "" : ` — ${reasons.join("; ")}`;
|
|
171
|
+
}
|
|
57
172
|
/**
|
|
58
173
|
* The status in a few words, the same in `stateward guarantees` and the editor: "proven for 3
|
|
59
|
-
* readers", "not proven: 2 errors", "
|
|
174
|
+
* readers", "not proven: 2 errors", "not proven: 1 ignored — lives as long as the app", "unused:
|
|
175
|
+
* nothing reads it", "not checked: … is not on".
|
|
60
176
|
*/
|
|
61
177
|
export function describeStatus(proof) {
|
|
62
178
|
const { stated, status } = proof;
|
|
63
179
|
switch (status.kind) {
|
|
64
180
|
case "proven":
|
|
65
181
|
return `proven for ${counted(stated.covered.length, stated.covers)}`;
|
|
66
|
-
case "unproven":
|
|
67
|
-
|
|
182
|
+
case "unproven": {
|
|
183
|
+
const parts = [
|
|
184
|
+
...(status.errors.length > 0 ? [counted(status.errors.length, ERROR)] : []),
|
|
185
|
+
...(status.ignored.length > 0 ? [`${String(status.ignored.length)} ignored`] : []),
|
|
186
|
+
];
|
|
187
|
+
return `not proven: ${parts.join(", ")}${reasonsOf(status.ignored)}`;
|
|
188
|
+
}
|
|
189
|
+
case "unchecked": {
|
|
190
|
+
const [first] = status.places;
|
|
191
|
+
const more = status.places.length - 1;
|
|
192
|
+
return `not checked: ${first?.reason ?? "a place it cannot follow"}${more > 0 ? ` (and ${String(more)} more)` : ""}`;
|
|
193
|
+
}
|
|
68
194
|
case "unused":
|
|
69
|
-
return
|
|
195
|
+
return status.importsOnly === true
|
|
196
|
+
? "unused: referenced only by imports or types"
|
|
197
|
+
: `unused: no ${stated.covers.one}, so nothing to prove; use it or drop the marker`;
|
|
70
198
|
case "off":
|
|
71
|
-
return
|
|
199
|
+
return status.places.length === 0
|
|
200
|
+
? `not checked: ${stated.ruleId} is not on: turn it on in the config, or with \`stateward next\``
|
|
201
|
+
: `not checked: ${stated.ruleId} is off for ${counted(status.places.length, stated.covers)}: turn it on for them in the config`;
|
|
72
202
|
default: {
|
|
73
203
|
const unreachable = status;
|
|
74
204
|
return unreachable;
|
package/dist/ignores.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Renames } from "./renamed.js";
|
|
1
2
|
import type { RuleResult } from "./cache.js";
|
|
2
3
|
import type { ProjectUnit } from "./backend/typescript6.js";
|
|
3
4
|
import type { Finding, FixForm, IgnoreOptions, IgnoredFinding } from "./types.js";
|
|
@@ -52,6 +53,16 @@ export type IgnoreScope = {
|
|
|
52
53
|
ran: ReadonlySet<string>;
|
|
53
54
|
/** The config's `ignores`: whether a reason is required and how an unneeded comment is reported. */
|
|
54
55
|
options: IgnoreOptions;
|
|
56
|
+
/** The renamed rule ids the packs declare: a comment that names an old id still works. */
|
|
57
|
+
renames: Renames;
|
|
58
|
+
/** The rule ids a release removed: a comment that names one ignores nothing and is not needed. */
|
|
59
|
+
removed: ReadonlySet<string>;
|
|
60
|
+
/**
|
|
61
|
+
* By rule id, for the rules that ran: their options that report a kind of finding only when on
|
|
62
|
+
* and are off now (`hiddenCases` of `unions/non-exhaustive-switch`, a convention). A comment such
|
|
63
|
+
* a rule finds nothing under may be for that kind, so removing it is not safe.
|
|
64
|
+
*/
|
|
65
|
+
offOptions: ReadonlyMap<string, readonly string[]>;
|
|
55
66
|
};
|
|
56
67
|
/**
|
|
57
68
|
* Takes the findings that ignore comments cover out of `findings` and adds the findings about
|
package/dist/ignores.js
CHANGED
|
@@ -264,6 +264,10 @@ function closest(id, known) {
|
|
|
264
264
|
}
|
|
265
265
|
const MAX_HEADLINE = 100;
|
|
266
266
|
const MAX_HINT = 140;
|
|
267
|
+
/** The first of `texts` that fits `max`, else `shorter`. */
|
|
268
|
+
function firstFitting(texts, max, shorter) {
|
|
269
|
+
return texts.find((text) => text.length <= max) ?? shorter;
|
|
270
|
+
}
|
|
267
271
|
/** `text` when it fits `max`, else `shorter`. */
|
|
268
272
|
function fits(text, max, shorter) {
|
|
269
273
|
return text.length <= max ? text : shorter;
|
|
@@ -271,6 +275,10 @@ function fits(text, max, shorter) {
|
|
|
271
275
|
function names(ids) {
|
|
272
276
|
return ids.map((id) => `\`${id}\``).join(", ");
|
|
273
277
|
}
|
|
278
|
+
/** The verb for `ids` as its subject: `one` for one id, `many` for several. */
|
|
279
|
+
function verb(ids, one, many) {
|
|
280
|
+
return ids.length === 1 ? one : many;
|
|
281
|
+
}
|
|
274
282
|
function commentFinding(file, at, severity, message, hint, fixes) {
|
|
275
283
|
const location = { file, start: at.start, end: at.end };
|
|
276
284
|
return {
|
|
@@ -289,6 +297,60 @@ function rebuilt(directive, keep) {
|
|
|
289
297
|
const body = `stateward-ignore${directive.file ? "-file" : ""} ${keep.join(", ")}${reason}`;
|
|
290
298
|
return directive.block ? `/* ${body} */` : `// ${body}`;
|
|
291
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* The finding for an ignore comment that ignores nothing: its rules, `unused`, were removed from
|
|
302
|
+
* stateward or find nothing where it is. When a rule has an option that is off and reports a kind of
|
|
303
|
+
* finding only when on (`IgnoreScope.offOptions`), the comment may be for that kind: the message says it
|
|
304
|
+
* ignores nothing with the current config, names the option, and the removal is not a safe fix.
|
|
305
|
+
*/
|
|
306
|
+
function unusedFinding(file, directive, unused, scope, severity) {
|
|
307
|
+
const here = { start: directive.start, end: directive.end };
|
|
308
|
+
const everything = unused.length === directive.rules.length;
|
|
309
|
+
const keep = directive.rules.map((rule) => rule.id).filter((id) => !unused.includes(id));
|
|
310
|
+
const where = directive.file ? "in the file" : "in the code it covers";
|
|
311
|
+
// A rule a release removed finds nothing because it is gone, not because the code changed.
|
|
312
|
+
const removed = unused.filter((id) => !scope.known.has(id) && scope.removed.has(id));
|
|
313
|
+
const others = unused.filter((id) => !removed.includes(id));
|
|
314
|
+
const off = others.flatMap((id) => {
|
|
315
|
+
const options = scope.offOptions.get(id) ?? [];
|
|
316
|
+
return options.length === 0 ? [] : [{ id, options }];
|
|
317
|
+
});
|
|
318
|
+
const offOptions = off.flatMap((one) => one.options);
|
|
319
|
+
const headline = off.length > 0
|
|
320
|
+
? fits(`ignore comment ignores nothing in this config: ${off.map((one) => `\`${one.id}\` has ${names(one.options)} off`).join("; ")}`, MAX_HEADLINE, "ignore comment ignores nothing in this config: an option of its rule is off")
|
|
321
|
+
: others.length === 0
|
|
322
|
+
? fits(`ignore comment is not needed: ${names(removed)} ${verb(removed, "was", "were")} removed from stateward`, MAX_HEADLINE, "ignore comment is not needed: its rules were removed from stateward")
|
|
323
|
+
: removed.length > 0
|
|
324
|
+
? firstFitting([
|
|
325
|
+
`ignore comment is not needed: ${names(removed)} ${verb(removed, "was", "were")} removed from stateward, and ${names(others)} ${verb(others, "finds", "find")} nothing ${where}`,
|
|
326
|
+
`ignore comment is not needed: ${names(removed)} ${verb(removed, "was", "were")} removed from stateward`,
|
|
327
|
+
], MAX_HEADLINE, `ignore comment is not needed: its rules were removed from stateward or find nothing ${where}`)
|
|
328
|
+
: fits(`ignore comment is not needed: ${names(others)} ${verb(others, "finds", "find")} nothing ${where}`, MAX_HEADLINE, `ignore comment is not needed: ${String(others.length)} of its rules ${verb(others, "finds", "find")} nothing ${where}`);
|
|
329
|
+
const hint = off.length > 0
|
|
330
|
+
? fits(`if it is for what ${names(offOptions)} ${verb(offOptions, "reports", "report")}, keep it and turn ${verb(offOptions, "the option", "them")} on (\`conventions: true\` does); else remove it`, MAX_HINT, "if it is for what the option reports, keep it and turn the option on; else remove it")
|
|
331
|
+
: others.length === 0
|
|
332
|
+
? "remove it (quick fix)"
|
|
333
|
+
: removed.length > 0
|
|
334
|
+
? fits(`remove it (quick fix); ${names(others)} ${verb(others, "finds", "find")} nothing ${where} either`, MAX_HINT, `remove it (quick fix); its other rules find nothing ${where} either`)
|
|
335
|
+
: "remove it (quick fix); the code it covered is fixed, or has moved";
|
|
336
|
+
const fix = everything
|
|
337
|
+
? {
|
|
338
|
+
title: "Remove the ignore comment",
|
|
339
|
+
safe: off.length === 0,
|
|
340
|
+
edits: [
|
|
341
|
+
{
|
|
342
|
+
location: { file, start: directive.removeStart, end: directive.removeEnd },
|
|
343
|
+
newText: "",
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
}
|
|
347
|
+
: {
|
|
348
|
+
title: `Remove ${names(unused)} from the ignore comment`,
|
|
349
|
+
safe: off.length === 0,
|
|
350
|
+
edits: [{ location: { file, ...here }, newText: rebuilt(directive, keep) }],
|
|
351
|
+
};
|
|
352
|
+
return commentFinding(file, here, severity, headline, hint, [fix]);
|
|
353
|
+
}
|
|
292
354
|
/** The findings about one comment: no rule named, in the wrong place, unknown id, no reason, not needed. */
|
|
293
355
|
function judge(file, directive, used, scope) {
|
|
294
356
|
const here = { start: directive.start, end: directive.end };
|
|
@@ -309,9 +371,13 @@ function judge(file, directive, used, scope) {
|
|
|
309
371
|
if (rule.id === IGNORE_RULE_ID) {
|
|
310
372
|
found.push(commentFinding(file, rule, "error", "`stateward/ignore` findings cannot be ignored", "fix the comment the finding points at, or remove it", []));
|
|
311
373
|
}
|
|
312
|
-
else if (!scope.known.has(rule.id) &&
|
|
374
|
+
else if (!scope.known.has(rule.id) && scope.removed.has(rule.id)) {
|
|
375
|
+
// A removed rule finds nothing: the comment is not needed for it.
|
|
376
|
+
unused.push(rule.id);
|
|
377
|
+
}
|
|
378
|
+
else if (!scope.known.has(rule.id) && renamedRule(scope.renames, rule.id) !== undefined) {
|
|
313
379
|
// A renamed rule: the comment still works under the old id.
|
|
314
|
-
const now = renamedRule(rule.id) ?? rule.id;
|
|
380
|
+
const now = renamedRule(scope.renames, rule.id) ?? rule.id;
|
|
315
381
|
// One cause, one message: an ignore that is not needed is removed, not renamed; two fixes on
|
|
316
382
|
// one comment would also clash in `--fix`.
|
|
317
383
|
if (!used.has(now) && scope.ran.has(now)) {
|
|
@@ -344,28 +410,9 @@ function judge(file, directive, used, scope) {
|
|
|
344
410
|
unused.push(rule.id);
|
|
345
411
|
}
|
|
346
412
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
const where = directive.file ? "in the file" : "in the code it covers";
|
|
351
|
-
found.push(commentFinding(file, here, scope.options.reportUnused, fits(`ignore comment is not needed: ${names(unused)} finds nothing ${where}`, MAX_HEADLINE, `ignore comment is not needed: ${String(unused.length)} of its rules find nothing ${where}`), "remove it (quick fix); the code it covered is fixed, or has moved", [
|
|
352
|
-
everything
|
|
353
|
-
? {
|
|
354
|
-
title: "Remove the ignore comment",
|
|
355
|
-
safe: true,
|
|
356
|
-
edits: [
|
|
357
|
-
{
|
|
358
|
-
location: { file, start: directive.removeStart, end: directive.removeEnd },
|
|
359
|
-
newText: "",
|
|
360
|
-
},
|
|
361
|
-
],
|
|
362
|
-
}
|
|
363
|
-
: {
|
|
364
|
-
title: `Remove ${names(unused)} from the ignore comment`,
|
|
365
|
-
safe: true,
|
|
366
|
-
edits: [{ location: { file, ...here }, newText: rebuilt(directive, keep) }],
|
|
367
|
-
},
|
|
368
|
-
]));
|
|
413
|
+
const severity = scope.options.reportUnused;
|
|
414
|
+
if (unused.length > 0 && severity !== "off") {
|
|
415
|
+
found.push(unusedFinding(file, directive, unused, scope, severity));
|
|
369
416
|
}
|
|
370
417
|
if (directive.reason === "" && scope.options.requireReason) {
|
|
371
418
|
const first = directive.rules[0]?.id ?? "<rule>";
|
|
@@ -388,7 +435,7 @@ export function applyIgnores(findings, directives, scope) {
|
|
|
388
435
|
const { file, start } = finding.location;
|
|
389
436
|
const reason = finding.kind === "failure"
|
|
390
437
|
? undefined
|
|
391
|
-
: coveredBy(directives.get(file) ?? [], finding.ruleId, start, used);
|
|
438
|
+
: coveredBy(directives.get(file) ?? [], finding.ruleId, start, used, scope.renames);
|
|
392
439
|
if (reason === undefined)
|
|
393
440
|
kept.push(finding);
|
|
394
441
|
else
|
|
@@ -402,12 +449,12 @@ export function applyIgnores(findings, directives, scope) {
|
|
|
402
449
|
return { findings: kept, ignored };
|
|
403
450
|
}
|
|
404
451
|
/** The reason of the first comment that covers the finding (every one that does counts as used). */
|
|
405
|
-
function coveredBy(list, ruleId, start, used) {
|
|
452
|
+
function coveredBy(list, ruleId, start, used, renames) {
|
|
406
453
|
let reason;
|
|
407
454
|
for (const directive of list) {
|
|
408
455
|
if (directive.file && !directive.placed)
|
|
409
456
|
continue;
|
|
410
|
-
if (!directive.rules.some((rule) => (renamedRule(rule.id) ?? rule.id) === ruleId))
|
|
457
|
+
if (!directive.rules.some((rule) => (renamedRule(renames, rule.id) ?? rule.id) === ruleId))
|
|
411
458
|
continue;
|
|
412
459
|
const covers = directive.file || (directive.coverStart <= start && start <= directive.coverEnd);
|
|
413
460
|
if (!covers)
|
package/dist/implementation.d.ts
CHANGED
|
@@ -14,10 +14,4 @@ export declare function configLocalImports(configFile: string): readonly string[
|
|
|
14
14
|
export declare function foreignTypeScriptWarnings(configFile: string): readonly string[];
|
|
15
15
|
/** `computeImplementationId`, once per config file in this process: the code loaded does not change under it. */
|
|
16
16
|
export declare function implementationId(configFile: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* The id of the code of the package `moduleUrl` belongs to, with core's (as `computeImplementationId`
|
|
19
|
-
* hashes them): what a plugin computed and cached outside a project (the library facts cache) is
|
|
20
|
-
* read back only by the same code. Once per package and process.
|
|
21
|
-
*/
|
|
22
|
-
export declare function packageCodeId(moduleUrl: string): string;
|
|
23
17
|
//# sourceMappingURL=implementation.d.ts.map
|
package/dist/implementation.js
CHANGED
|
@@ -294,21 +294,4 @@ export function implementationId(configFile) {
|
|
|
294
294
|
}
|
|
295
295
|
return id;
|
|
296
296
|
}
|
|
297
|
-
const codeIds = new Map();
|
|
298
|
-
/**
|
|
299
|
-
* The id of the code of the package `moduleUrl` belongs to, with core's (as `computeImplementationId`
|
|
300
|
-
* hashes them): what a plugin computed and cached outside a project (the library facts cache) is
|
|
301
|
-
* read back only by the same code. Once per package and process.
|
|
302
|
-
*/
|
|
303
|
-
export function packageCodeId(moduleUrl) {
|
|
304
|
-
const root = packageRootOf(path.dirname(fileURLToPath(moduleUrl)));
|
|
305
|
-
const key = root ?? moduleUrl;
|
|
306
|
-
let id = codeIds.get(key);
|
|
307
|
-
if (id === undefined) {
|
|
308
|
-
const coreRoot = packageRootOf(path.dirname(fileURLToPath(import.meta.url)));
|
|
309
|
-
id = sha1([coreRoot, root].map((one) => (one === undefined ? "?" : packageHash(real(one)))).join("\n"));
|
|
310
|
-
codeIds.set(key, id);
|
|
311
|
-
}
|
|
312
|
-
return id;
|
|
313
|
-
}
|
|
314
297
|
//# sourceMappingURL=implementation.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { defaults, defineConfig, parseConfig } from "./config.js";
|
|
|
2
2
|
export { matchesFile, matchesName, option } from "./options.js";
|
|
3
3
|
export type { ConfigOptionsOf, GroupConfigsOf, RuleConfigsOf } from "./options.js";
|
|
4
4
|
export { defineRule, definePlugin } from "./define.js";
|
|
5
|
+
export { declarationId } from "./stated.js";
|
|
5
6
|
export { lazyRule, moduleLoader } from "./lazy.js";
|
|
6
7
|
export type { ModuleLoader } from "./lazy.js";
|
|
7
8
|
export { check, createChecker } from "./checker.js";
|
|
@@ -11,14 +12,14 @@ export type { Propagation, PropagationMemo } from "./graph.js";
|
|
|
11
12
|
export { highestUncovered, shortestPath } from "./tree.js";
|
|
12
13
|
export type { TreeEdge, Uncovered, WalkDown } from "./tree.js";
|
|
13
14
|
export { describeRelease, describeTraitSource, releaseCandidates, releaseTraitOf, } from "./release.js";
|
|
14
|
-
export {
|
|
15
|
+
export { classIdOf, declaredPackageOf, isPlatformDeclaration, packageNameOf } from "./class-id.js";
|
|
16
|
+
export { callFactOf, declarationFactOf, externalFactOf, factKeyOf, factLineOf, factLineText, factKeyText, factNeedOf, factSideOf, neededSides, pathOf, neverRejectsFactOf, reportWithheld, withheldFactOf, WILDCARD, } from "./package-facts.js";
|
|
17
|
+
export { followBounded, packageVersionOf, unread, unreadFinding, versionMajor, versionSatisfies, } from "./unread.js";
|
|
18
|
+
export type { FollowStep, Followed, PackageVersionRead, Unread } from "./unread.js";
|
|
19
|
+
export { codeOnOneLine } from "./code-text.js";
|
|
20
|
+
export { offByDefaultText } from "./off-by-default.js";
|
|
21
|
+
export { isSafePlatformCall, iteratesPlainly } from "./safe-calls.js";
|
|
15
22
|
export type { FactContext, PackageFact } from "./package-facts.js";
|
|
16
|
-
export type { ReleaseCandidate,
|
|
17
|
-
export {
|
|
18
|
-
export { readPackageCache, writePackageCache } from "./package-cache.js";
|
|
19
|
-
export type { PackageCacheKey } from "./package-cache.js";
|
|
20
|
-
export { findPackageRoot, reparsedWithJsDoc } from "./backend/package-source.js";
|
|
21
|
-
export { openPackageSource } from "./backend/typescript6.js";
|
|
22
|
-
export type { PackageSource } from "./backend/typescript6.js";
|
|
23
|
-
export type { BooleanOption, CheckNotes, CheckResult, Config, ConfigOverride, CoveredNoun, CoveredPlace, EditorAction, EditorContributions, EditorHint, ExtendedConfig, FileContext, FactSource, FileRule, Finding, FunctionFacts, LibraryTypes, LibraryUse, MissingTypes, PackageFactsConfig, Fix, FixForm, FixReview, FixSetReview, FixVerdict, RejectedFix, GroupIdOf, HiddenFindings, IgnoreOptions, IgnoredFinding, Json, Literal, NarrowedMembers, SignalParameter, StatedGuarantee, TraitSource, ReleaseFact, NoOptions, NumberOption, OptionSpec, RecordOption, SeveritiesOption, SeverityMap, StringListRecord, OptionSpecs, OptionValue, OptionValueOf, Options, OptionsOf, NarrowingTest, OverrideOf, Location, ParseResult, Plugin, PluginOf, PluginsOf, Preset, ProjectContext, ProjectRule, RelatedLocation, ReportProblem, LazyRule, PluginRule, Rule, RuleConfig, RuleDeclaration, RuleIdOf, RuleInfo, RuleMeta, RuleSelection, RuleSetting, RuleTier, Severity, StringOption, StringsOption, SymbolRef, AliasRef, TextEdit, TokenType, TypeQueries, UnknownsSetting, UserConfig, } from "./types.js";
|
|
23
|
+
export type { ReleaseCandidate, ReleaseTrait, ReleaseWay } from "./release.js";
|
|
24
|
+
export type { Analyses, AnalysisContext, BooleanOption, CheckNotes, CheckResult, Config, ConfigOverride, CoveredNoun, DecoratorMetadata, CoveredPlace, EditorAction, EditorContributions, EditorHint, ExtendedConfig, FileContext, FactKey, FactModule, FactNeed, FactSide, FactSource, FactTarget, FileRule, Finding, UnnamedFact, UnstatedPlace, FunctionFacts, LibraryTypes, LibraryUse, MissingTypes, PackageFactsConfig, PackageFactsInput, PackageFactsTable, VerifiedFacts, WithheldFacts, Fix, FixForm, FixReview, FixSetReview, FixVerdict, FlowKind, FlowVia, RejectedFix, GroupIdOf, HiddenFindings, IgnoreOptions, IgnoredFinding, Json, Ledger, LedgerMark, LedgerRef, Literal, BuiltinType, OffByDefault, NarrowedMembers, SignalParameter, StatedDeclaration, StatedGuarantee, StatedReference, UncheckedPlace, TraitSource, ReleaseFact, NoOptions, NumberOption, OptionSpec, RecordOption, SeveritiesOption, SeverityMap, StringListRecord, OptionSpecs, OptionValue, OptionValueOf, Options, OptionsOf, NarrowingTest, OverrideOf, Location, MetadataType, GenericBase, InstanceClasses, TypeArgument, PropertyTypeText, ParseResult, Plugin, PluginAnalysis, PluginOf, PluginsOf, Preset, ProjectContext, ProjectRule, RelatedLocation, ReadOutcome, ReferenceForm, ReportInput, ReportOutput, ReportPlace, ReportProblem, LazyRule, PluginReport, PluginRule, Rule, RuleConfig, RuleDeclaration, RuleIdOf, RuleInfo, RuleMeta, RuleProves, RuleSelection, RuleSetting, RuleTier, Severity, StringOption, StringsOption, SymbolRef, AliasRef, TextEdit, TokenType, TypeQueries, TypeShape, TypeShapeProperty, UnknownsSetting, UserConfig, } from "./types.js";
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -4,19 +4,26 @@
|
|
|
4
4
|
export { defaults, defineConfig, parseConfig } from "./config.js";
|
|
5
5
|
export { matchesFile, matchesName, option } from "./options.js";
|
|
6
6
|
export { defineRule, definePlugin } from "./define.js";
|
|
7
|
+
// The id of a stated declaration, which `StatedGuarantee.declaration` and `Finding.guarantees` name.
|
|
8
|
+
export { declarationId } from "./stated.js";
|
|
7
9
|
export { lazyRule, moduleLoader } from "./lazy.js";
|
|
8
10
|
// Running a check from code: what the testing helper (`@stateward/core/testing`) is built on.
|
|
9
11
|
export { check, createChecker } from "./checker.js";
|
|
10
12
|
// Helpers for project rules that follow calls across files.
|
|
11
13
|
export { createPropagationMemo, propagate } from "./graph.js";
|
|
12
14
|
export { highestUncovered, shortestPath } from "./tree.js";
|
|
13
|
-
// The release trait: where a call's result is stated to need releasing (type,
|
|
15
|
+
// The release trait: where a call's result is stated to need releasing (type, facts).
|
|
14
16
|
export { describeRelease, describeTraitSource, releaseCandidates, releaseTraitOf, } from "./release.js";
|
|
17
|
+
// How a class is named across packs: the project's symbol id, `builtin:<Name>` for the platform,
|
|
18
|
+
// `package:<name>#<Class>` for a package, and the package a declaration belongs to.
|
|
19
|
+
export { classIdOf, declaredPackageOf, isPlatformDeclaration, packageNameOf } from "./class-id.js";
|
|
15
20
|
// Facts about packages: the config's and the shipped lines, and the promises they say never reject.
|
|
16
|
-
export { neverRejectsFactOf } from "./package-facts.js";
|
|
17
|
-
// What a
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
|
|
21
|
-
export {
|
|
21
|
+
export { callFactOf, declarationFactOf, externalFactOf, factKeyOf, factLineOf, factLineText, factKeyText, factNeedOf, factSideOf, neededSides, pathOf, neverRejectsFactOf, reportWithheld, withheldFactOf, WILDCARD, } from "./package-facts.js";
|
|
22
|
+
// What a rule could not read, as a typed result that becomes a "not checked" finding: the
|
|
23
|
+
// bounded follow and the package version reader return it instead of a pass or a guess.
|
|
24
|
+
export { followBounded, packageVersionOf, unread, unreadFinding, versionMajor, versionSatisfies, } from "./unread.js";
|
|
25
|
+
// The platform calls that do not throw: the closed list the proofs share.
|
|
26
|
+
export { codeOnOneLine } from "./code-text.js";
|
|
27
|
+
export { offByDefaultText } from "./off-by-default.js";
|
|
28
|
+
export { isSafePlatformCall, iteratesPlainly } from "./safe-calls.js";
|
|
22
29
|
//# sourceMappingURL=index.js.map
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from "./index.js";
|
|
2
2
|
export { isMaxMemory, isPreset, MIN_MAX_MEMORY } from "./config.js";
|
|
3
|
+
export { FACT_CHOICES, applyConfigEdit, factChoiceTitle, factLineEdit, factLineFixes, factValueText, } from "./fact-lines.js";
|
|
4
|
+
export type { ConfigEdit, FactChoice, FactLineFix } from "./fact-lines.js";
|
|
5
|
+
export { PLACEHOLDER_CLASS } from "./package-facts.js";
|
|
3
6
|
export { CONFIG_FILE_NAMES, CONFIG_FILE_PATTERN, DEFAULT_CONFIG_FILE, DEFAULT_PRESET, PRESETS, RULE_TIERS, orList, } from "./vocabulary.js";
|
|
4
|
-
export { RuleDeclarationError, RuleLoadError, RuleNotLoadedError, loadAllRules, loadRules, } from "./lazy.js";
|
|
7
|
+
export { RuleDeclarationError, RuleLoadError, RuleNotLoadedError, RuleReadsError, loadAllRules, loadRules, } from "./lazy.js";
|
|
5
8
|
export { addonNames, groupIds, ruleIds, ruleIsOn, ruleSetting } from "./severity.js";
|
|
6
9
|
export { displayPath, slashed } from "./display-path.js";
|
|
7
10
|
export type { PathModule } from "./display-path.js";
|
|
@@ -16,15 +19,15 @@ export { LOOSE_NULLS_FIX, MAX_FINDINGS_PER_RULE_PER_FILE, STRICT_NULLS_REMEDY, a
|
|
|
16
19
|
export type { CheckProgress } from "./engine.js";
|
|
17
20
|
export { SLICE_MS } from "./checker.js";
|
|
18
21
|
export { counted, describeStatus, guaranteeAt, proveGuarantees } from "./guarantees.js";
|
|
19
|
-
export
|
|
22
|
+
export { STATED_RULE_ID } from "./stated.js";
|
|
23
|
+
export type { GuaranteeProof, GuaranteeStatus, IgnoredProblem, ProofInputs } from "./guarantees.js";
|
|
20
24
|
export type { LongestStep, SliceOptions, SlicedCheck } from "./checker.js";
|
|
21
25
|
export { IGNORE_FIX_TITLE, IGNORE_RULE_ID, ignoreFix } from "./ignores.js";
|
|
22
26
|
export { CACHE_FORMAT, emptyCache, parseSnapshot, toSnapshot } from "./cache.js";
|
|
23
27
|
export type { CacheSnapshot, ResultCache } from "./cache.js";
|
|
24
28
|
export { stronglyConnectedComponents } from "./graph.js";
|
|
25
29
|
export { computeImplementationId, configLocalImports, implementationId } from "./implementation.js";
|
|
26
|
-
export {
|
|
27
|
-
export type { PackageCacheClean, PackageCacheStats } from "./package-cache.js";
|
|
30
|
+
export { statewardVersion } from "./disk-cache.js";
|
|
28
31
|
export { NothingToCheckError, TsconfigError, TypeScriptLibMissingError, missingDefaultLib, toTypeScriptPath, tsconfigDirectory, } from "./backend/typescript6.js";
|
|
29
32
|
export { createTimingRecorder } from "./timing.js";
|
|
30
33
|
export { cacheEntries, dropLeastRecentlyUsed, limitBytes, markUsed } from "./disk-limits.js";
|
|
@@ -34,5 +37,6 @@ export type { CacheEntry } from "./disk-limits.js";
|
|
|
34
37
|
export type { RuleCost, RunTiming, TimingRecorder } from "./timing.js";
|
|
35
38
|
export { hintLines, hintWithoutExamples, laidOutHint } from "./hint-lines.js";
|
|
36
39
|
export type { HintLine } from "./hint-lines.js";
|
|
37
|
-
export { renameNotice, renamedIdsIn, renamedRule } from "./renamed.js";
|
|
40
|
+
export { quotedIdLine, removedNotice, removedOf, renameNotice, renamedIdsIn, renamedRule, renamesOf, } from "./renamed.js";
|
|
41
|
+
export type { Renames } from "./renamed.js";
|
|
38
42
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
//. It holds the public API too, so one import is enough.
|
|
4
4
|
export * from "./index.js";
|
|
5
5
|
export { isMaxMemory, isPreset, MIN_MAX_MEMORY } from "./config.js";
|
|
6
|
+
export { FACT_CHOICES, applyConfigEdit, factChoiceTitle, factLineEdit, factLineFixes, factValueText, } from "./fact-lines.js";
|
|
7
|
+
export { PLACEHOLDER_CLASS } from "./package-facts.js";
|
|
6
8
|
export { CONFIG_FILE_NAMES, CONFIG_FILE_PATTERN, DEFAULT_CONFIG_FILE, DEFAULT_PRESET, PRESETS, RULE_TIERS, orList, } from "./vocabulary.js";
|
|
7
|
-
export { RuleDeclarationError, RuleLoadError, RuleNotLoadedError, loadAllRules, loadRules, } from "./lazy.js";
|
|
9
|
+
export { RuleDeclarationError, RuleLoadError, RuleNotLoadedError, RuleReadsError, loadAllRules, loadRules, } from "./lazy.js";
|
|
8
10
|
export { addonNames, groupIds, ruleIds, ruleIsOn, ruleSetting } from "./severity.js";
|
|
9
11
|
export { displayPath, slashed } from "./display-path.js";
|
|
10
12
|
export { matchingOverrides } from "./overrides.js";
|
|
@@ -15,15 +17,16 @@ export { findConfigFile, findConfigUpward, loadConfig, loadConfigFile, reloadsLo
|
|
|
15
17
|
export { LOOSE_NULLS_FIX, MAX_FINDINGS_PER_RULE_PER_FILE, STRICT_NULLS_REMEDY, activeRuleIds, compareFindings, explain, limitFindings, } from "./engine.js";
|
|
16
18
|
export { SLICE_MS } from "./checker.js";
|
|
17
19
|
export { counted, describeStatus, guaranteeAt, proveGuarantees } from "./guarantees.js";
|
|
20
|
+
export { STATED_RULE_ID } from "./stated.js";
|
|
18
21
|
export { IGNORE_FIX_TITLE, IGNORE_RULE_ID, ignoreFix } from "./ignores.js";
|
|
19
22
|
export { CACHE_FORMAT, emptyCache, parseSnapshot, toSnapshot } from "./cache.js";
|
|
20
23
|
export { stronglyConnectedComponents } from "./graph.js";
|
|
21
24
|
export { computeImplementationId, configLocalImports, implementationId } from "./implementation.js";
|
|
22
|
-
export {
|
|
25
|
+
export { statewardVersion } from "./disk-cache.js";
|
|
23
26
|
export { NothingToCheckError, TsconfigError, TypeScriptLibMissingError, missingDefaultLib, toTypeScriptPath, tsconfigDirectory, } from "./backend/typescript6.js";
|
|
24
27
|
export { createTimingRecorder } from "./timing.js";
|
|
25
28
|
export { cacheEntries, dropLeastRecentlyUsed, limitBytes, markUsed } from "./disk-limits.js";
|
|
26
29
|
export { CACHE_SUBDIR, PROJECT_CACHE_DIR, RESULTS_CACHE_DEFAULT_MB, cleanResultsCache, defaultCacheDir, userCacheDir, openDiskCache, resultsCacheLimit, resultsCacheStats, } from "./disk-cache.js";
|
|
27
30
|
export { hintLines, hintWithoutExamples, laidOutHint } from "./hint-lines.js";
|
|
28
|
-
export { renameNotice, renamedIdsIn, renamedRule } from "./renamed.js";
|
|
31
|
+
export { quotedIdLine, removedNotice, removedOf, renameNotice, renamedIdsIn, renamedRule, renamesOf, } from "./renamed.js";
|
|
29
32
|
//# sourceMappingURL=internal.js.map
|
package/dist/lazy.d.ts
CHANGED
|
@@ -28,6 +28,13 @@ export declare class RuleNotLoadedError extends Error {
|
|
|
28
28
|
export declare class RuleDeclarationError extends Error {
|
|
29
29
|
constructor(ruleId: string, what: string);
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* A rule's `reads` is malformed, or names an analysis that the publisher in the config does not
|
|
33
|
+
* publish: what the config check says of a rule given directly, found once a lazy rule's code loads.
|
|
34
|
+
*/
|
|
35
|
+
export declare class RuleReadsError extends Error {
|
|
36
|
+
constructor(message: string);
|
|
37
|
+
}
|
|
31
38
|
/** A rule's module could not be imported (a broken install). */
|
|
32
39
|
export declare class RuleLoadError extends Error {
|
|
33
40
|
constructor(ruleId: string, reason: string);
|
|
@@ -36,7 +43,7 @@ export declare class RuleLoadError extends Error {
|
|
|
36
43
|
export declare function codeOf(ruleId: string, rule: PluginRule): Rule;
|
|
37
44
|
/** Loads one lazy rule and checks it against its declaration. */
|
|
38
45
|
export declare function loadRule(ruleId: string, rule: PluginRule): Promise<Rule>;
|
|
39
|
-
type Settings = Pick<Config, "plugins" | "preset" | "addons" | "rules" | "groups"> & Partial<Pick<Config, "overrides">>;
|
|
46
|
+
type Settings = Pick<Config, "plugins" | "preset" | "addons" | "rules" | "groups"> & Partial<Pick<Config, "overrides" | "conventions">>;
|
|
40
47
|
/**
|
|
41
48
|
* Loads the code of every lazy rule that is on somewhere (in the config or in an override), so a
|
|
42
49
|
* check can run them. A rule that is off everywhere is not loaded. Rejects with a `RuleLoadError`
|