@stateward/core 1.2.2 → 1.3.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/dist/analyses.d.ts +37 -0
- package/dist/analyses.js +57 -0
- package/dist/backend/fingerprints.d.ts +3 -1
- package/dist/backend/fingerprints.js +198 -9
- package/dist/backend/program-record.d.ts +7 -0
- package/dist/backend/program-size.d.ts +32 -0
- package/dist/backend/program-size.js +166 -0
- package/dist/backend/typescript6.d.ts +62 -32
- package/dist/backend/typescript6.js +1615 -164
- package/dist/baseline.d.ts +1 -1
- package/dist/baseline.js +14 -10
- package/dist/cache.d.ts +92 -4
- package/dist/cache.js +257 -68
- package/dist/checker.d.ts +28 -3
- package/dist/checker.js +42 -8
- 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 +490 -48
- package/dist/define.d.ts +8 -2
- package/dist/disk-cache.d.ts +34 -2
- package/dist/disk-cache.js +82 -15
- package/dist/engine.d.ts +64 -3
- package/dist/engine.js +474 -59
- 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 +4 -1
- 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 +9 -9
- package/dist/index.js +12 -7
- package/dist/internal.d.ts +13 -6
- package/dist/internal.js +7 -3
- package/dist/journal.d.ts +40 -0
- package/dist/journal.js +197 -0
- package/dist/lazy.d.ts +8 -1
- package/dist/lazy.js +27 -2
- package/dist/ledger.d.ts +2 -2
- package/dist/ledger.js +2 -2
- package/dist/memory-plan.d.ts +121 -0
- package/dist/memory-plan.js +174 -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 +26 -38
- package/dist/renamed.d.ts +22 -3
- package/dist/renamed.js +50 -16
- package/dist/rollout.js +7 -4
- package/dist/severity.d.ts +1 -1
- package/dist/severity.js +17 -3
- package/dist/test-runner.d.ts +18 -0
- package/dist/test-runner.js +483 -0
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +5 -5
- package/dist/timing.d.ts +17 -7
- package/dist/timing.js +60 -38
- package/dist/types.d.ts +704 -20
- 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/define.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { EditorContributions, FileRule, Json, NoOptions, OptionSpecs, PackageFactsConfig, PluginOf, ProjectRule, PluginRule } from "./types.js";
|
|
1
|
+
import type { Analyses, EditorContributions, FileRule, Json, NoOptions, OptionSpecs, PackageFactsConfig, PluginAnalysis, PluginOf, ProjectRule, PluginReport, PluginRule, VerifiedFacts } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Identity helpers: they return what they are given, so TypeScript can infer the rule's options
|
|
4
4
|
* from `meta.options` and type `ctx.options` in `check`. A rule without `meta.options` takes no
|
|
5
5
|
* options, and a config that gives it some does not compile.
|
|
6
6
|
*/
|
|
7
7
|
export declare function defineRule<S extends OptionSpecs = NoOptions, G extends string = string>(rule: FileRule<S, G>): FileRule<S, G>;
|
|
8
|
-
export declare function defineRule<Summary extends Json, S extends OptionSpecs = NoOptions, G extends string = string>(rule: ProjectRule<Summary, S, G>): ProjectRule<Summary, S, G>;
|
|
8
|
+
export declare function defineRule<Summary extends Json, S extends OptionSpecs = NoOptions, G extends string = string, A extends Analyses = Analyses>(rule: ProjectRule<Summary, S, G, A>): ProjectRule<Summary, S, G, A>;
|
|
9
9
|
/** Keeps the plugin's name, rule keys and rule groups as literal types, so config rule and group ids can be completed. */
|
|
10
10
|
export declare function definePlugin<const N extends string, const R extends Readonly<Record<string, PluginRule>>>(plugin: {
|
|
11
11
|
name: N;
|
|
@@ -13,5 +13,11 @@ export declare function definePlugin<const N extends string, const R extends Rea
|
|
|
13
13
|
rules: R;
|
|
14
14
|
editor?: EditorContributions;
|
|
15
15
|
facts?: PackageFactsConfig;
|
|
16
|
+
factsVerified?: Readonly<Record<string, VerifiedFacts>>;
|
|
17
|
+
reports?: Readonly<Record<string, PluginReport>>;
|
|
18
|
+
analyses?: Readonly<Record<string, PluginAnalysis>>;
|
|
19
|
+
defaultExclude?: readonly string[];
|
|
20
|
+
renamed?: Readonly<Record<string, string>>;
|
|
21
|
+
removed?: readonly string[];
|
|
16
22
|
}): PluginOf<N, R>;
|
|
17
23
|
//# sourceMappingURL=define.d.ts.map
|
package/dist/disk-cache.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ResultCache } from "./cache.js";
|
|
2
|
+
/** The stateward version (core's): a new release reads nothing an older one wrote. */
|
|
3
|
+
export declare function statewardVersion(): string;
|
|
2
4
|
/**
|
|
3
5
|
* The results of earlier runs on disk, read and written by the CLI (`stateward check`) and the
|
|
4
6
|
* language server alike: one JSON file per project and implementation in the cache folder, keyed
|
|
@@ -41,11 +43,41 @@ export declare const RESULTS_CACHE_DEFAULT_MB = 200;
|
|
|
41
43
|
export declare function resultsCacheLimit(env: {
|
|
42
44
|
STATEWARD_CACHE_MAX_MB?: string | undefined;
|
|
43
45
|
}): number;
|
|
46
|
+
/**
|
|
47
|
+
* What a save did. `over-limit`: the run's own results were written whole although they pass the
|
|
48
|
+
* folder's limit (`bytes` against `limit`); only older results, and other projects' files, are
|
|
49
|
+
* dropped for the limit, never what the run wrote or used.
|
|
50
|
+
*/
|
|
51
|
+
export type SaveOutcome = {
|
|
52
|
+
readonly kind: "unchanged";
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: "saved";
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: "over-limit";
|
|
57
|
+
readonly bytes: number;
|
|
58
|
+
readonly limit: number;
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: "failed";
|
|
61
|
+
readonly error: Error;
|
|
62
|
+
};
|
|
44
63
|
export type DiskCache = {
|
|
45
64
|
readonly cache: ResultCache;
|
|
46
|
-
/**
|
|
47
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Writes the cache if it changed since it was read or last saved; a failure is returned, not
|
|
67
|
+
* thrown. Once written, the journal (`keepProgress`) is folded in and removed.
|
|
68
|
+
*/
|
|
69
|
+
save(): SaveOutcome;
|
|
70
|
+
/**
|
|
71
|
+
* Appends each file's results to the journal beside the cache as the check finishes them
|
|
72
|
+
* (journal.ts), so a run that dies keeps them for the next. A failure to open is thrown; a
|
|
73
|
+
* failure to write later ends the journal and is given to `onError`.
|
|
74
|
+
*/
|
|
75
|
+
keepProgress(onError: (error: Error) => void): void;
|
|
76
|
+
/** The journal's path (`journalPath`). */
|
|
77
|
+
readonly journal: string;
|
|
48
78
|
};
|
|
79
|
+
/** The journal of the results file `file`. */
|
|
80
|
+
export declare function journalPath(file: string): string;
|
|
49
81
|
/**
|
|
50
82
|
* Opens the cache of `project` (an absolute folder) in `dir`. A cache written by other code (another
|
|
51
83
|
* stateward version, or another build of core or of a plugin the config loads: `implementationId`)
|
package/dist/disk-cache.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { createHash, randomBytes } from "node:crypto";
|
|
2
|
-
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, rmdirSync, unlinkSync,
|
|
3
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, rmdirSync, unlinkSync, writeSync, } from "node:fs";
|
|
3
4
|
import { homedir } from "node:os";
|
|
4
5
|
import path from "node:path";
|
|
5
|
-
import { emptyCache, parseSnapshot,
|
|
6
|
+
import { emptyCache, parseSnapshot, pruneUnused, snapshotChunks } from "./cache.js";
|
|
6
7
|
import { cacheEntries, dropLeastRecentlyUsed, limitBytes, markUsed } from "./disk-limits.js";
|
|
7
8
|
import { implementationId } from "./implementation.js";
|
|
8
|
-
import {
|
|
9
|
+
import { openJournal, readJournal, removeJournal } from "./journal.js";
|
|
10
|
+
let version;
|
|
11
|
+
/** The stateward version (core's): a new release reads nothing an older one wrote. */
|
|
12
|
+
export function statewardVersion() {
|
|
13
|
+
if (version === undefined) {
|
|
14
|
+
const read = createRequire(import.meta.url)("../package.json");
|
|
15
|
+
const field = typeof read === "object" && read !== null ? Reflect.get(read, "version") : undefined;
|
|
16
|
+
version = typeof field === "string" ? field : "unknown";
|
|
17
|
+
}
|
|
18
|
+
return version;
|
|
19
|
+
}
|
|
9
20
|
/**
|
|
10
21
|
* The results of earlier runs on disk, read and written by the CLI (`stateward check`) and the
|
|
11
22
|
* language server alike: one JSON file per project and implementation in the cache folder, keyed
|
|
@@ -70,6 +81,8 @@ export function resultsCacheLimit(env) {
|
|
|
70
81
|
}
|
|
71
82
|
/** A results file of the folder: one per project (`check-<key>.json`). */
|
|
72
83
|
const RESULTS_FILE = /^check-[0-9a-f]+\.json$/;
|
|
84
|
+
/** A journal a check keeps beside its results file (journal.ts). */
|
|
85
|
+
const JOURNAL_FILE = /^check-[0-9a-f]+\.journal$/;
|
|
73
86
|
/** A temporary file a writer left (it died between writing and renaming). */
|
|
74
87
|
const TEMPORARY_FILE = /^check-[0-9a-f]+\.json\..*\.tmp$/;
|
|
75
88
|
/** Error codes of a rename that Windows refuses while another process has the target open. */
|
|
@@ -95,6 +108,10 @@ function renameWithRetry(rename, from, to, wait) {
|
|
|
95
108
|
}
|
|
96
109
|
}
|
|
97
110
|
}
|
|
111
|
+
/** The journal of the results file `file`. */
|
|
112
|
+
export function journalPath(file) {
|
|
113
|
+
return file.replace(/\.json$/, ".journal");
|
|
114
|
+
}
|
|
98
115
|
/**
|
|
99
116
|
* Opens the cache of `project` (an absolute folder) in `dir`. A cache written by other code (another
|
|
100
117
|
* stateward version, or another build of core or of a plugin the config loads: `implementationId`)
|
|
@@ -116,43 +133,93 @@ io = {}) {
|
|
|
116
133
|
const file = path.join(dir, `check-${key}.json`);
|
|
117
134
|
const version = statewardVersion();
|
|
118
135
|
const cache = readCache(file, { version, implementation, project });
|
|
136
|
+
const owner = { version, implementation, project };
|
|
137
|
+
const journal = journalPath(file);
|
|
138
|
+
// What a run that did not finish left: newer than the file, so it wins.
|
|
139
|
+
const left = readJournal(journal, owner);
|
|
140
|
+
for (const [name, entry] of left?.entries ?? [])
|
|
141
|
+
cache.files.set(name, entry);
|
|
142
|
+
if (left !== undefined && left.entries.size > 0)
|
|
143
|
+
cache.changed = true;
|
|
144
|
+
/** Whether this cache owns the journal: it read one, or keeps one. */
|
|
145
|
+
let journaled = left !== undefined;
|
|
146
|
+
let open;
|
|
119
147
|
// Used now: when the folder is over its limit, the files used longest ago go first.
|
|
120
148
|
if (cache.files.size > 0)
|
|
121
149
|
markUsed(file);
|
|
150
|
+
const head = JSON.stringify({ stateward: version, implementation, project });
|
|
151
|
+
const write = (to) => writeWhole(to, `${head.slice(0, -1)},"snapshot":`, snapshotChunks(cache), "}");
|
|
152
|
+
/** The journal's results are in the file now (or were never more than it holds): it goes. */
|
|
153
|
+
const settle = () => {
|
|
154
|
+
open?.close();
|
|
155
|
+
open = undefined;
|
|
156
|
+
if (journaled)
|
|
157
|
+
removeJournal(journal);
|
|
158
|
+
journaled = false;
|
|
159
|
+
};
|
|
122
160
|
return {
|
|
123
161
|
cache,
|
|
162
|
+
journal,
|
|
163
|
+
keepProgress(onError) {
|
|
164
|
+
mkdirSync(dir, { recursive: true });
|
|
165
|
+
open?.close();
|
|
166
|
+
open = openJournal(journal, owner, cache, onError);
|
|
167
|
+
journaled = true;
|
|
168
|
+
},
|
|
124
169
|
save() {
|
|
125
|
-
if (!cache.changed)
|
|
126
|
-
|
|
170
|
+
if (!cache.changed) {
|
|
171
|
+
settle();
|
|
172
|
+
return { kind: "unchanged" };
|
|
173
|
+
}
|
|
127
174
|
const temporary = `${file}.${String(process.pid)}.${randomBytes(4).toString("hex")}.tmp`;
|
|
128
175
|
try {
|
|
129
176
|
mkdirSync(dir, { recursive: true });
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}));
|
|
177
|
+
pruneUnused(cache);
|
|
178
|
+
let bytes = write(temporary);
|
|
179
|
+
// Over the limit: the results of rules no longer run go before any of this run's.
|
|
180
|
+
if (bytes > limit && pruneUnused(cache, 1))
|
|
181
|
+
bytes = write(temporary);
|
|
136
182
|
renameWithRetry(io.rename ?? renameSync, temporary, file, io.wait ?? sleep);
|
|
137
183
|
// Saved: a later save (after fixes were tried) writes only what changes after this one.
|
|
138
184
|
cache.changed = false;
|
|
185
|
+
settle();
|
|
139
186
|
pruneResults(dir, file, version, limit);
|
|
140
|
-
return
|
|
187
|
+
return bytes > limit ? { kind: "over-limit", bytes, limit } : { kind: "saved" };
|
|
141
188
|
}
|
|
142
189
|
catch (error) {
|
|
143
190
|
rmSync(temporary, { force: true });
|
|
144
|
-
return error instanceof Error ? error : new Error(String(error));
|
|
191
|
+
return { kind: "failed", error: error instanceof Error ? error : new Error(String(error)) };
|
|
145
192
|
}
|
|
146
193
|
},
|
|
147
194
|
};
|
|
148
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Writes `head`, the chunks and `tail` to `file`, one chunk at a time, so no string holds the
|
|
198
|
+
* whole text, and returns its size in bytes. Every file's results are written: the folder's limit
|
|
199
|
+
* never drops what a run checked, which would check it again on every run.
|
|
200
|
+
*/
|
|
201
|
+
function writeWhole(file, head, chunks, tail) {
|
|
202
|
+
const fd = openSync(file, "w");
|
|
203
|
+
try {
|
|
204
|
+
let bytes = writeSync(fd, head);
|
|
205
|
+
for (const chunk of chunks)
|
|
206
|
+
bytes += writeSync(fd, chunk);
|
|
207
|
+
return bytes + writeSync(fd, tail);
|
|
208
|
+
}
|
|
209
|
+
finally {
|
|
210
|
+
closeSync(fd);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
149
213
|
function readCache(file, expected) {
|
|
214
|
+
// Another version's file is not parsed: it may be large, and it is never used.
|
|
215
|
+
if (writtenBy(file) !== expected.version)
|
|
216
|
+
return emptyCache();
|
|
150
217
|
let parsed;
|
|
151
218
|
try {
|
|
152
219
|
parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
153
220
|
}
|
|
154
221
|
catch {
|
|
155
|
-
// Missing, unreadable or
|
|
222
|
+
// Missing, unreadable, not JSON, or more than one string can hold: a cold run.
|
|
156
223
|
return emptyCache();
|
|
157
224
|
}
|
|
158
225
|
if (typeof parsed !== "object" || parsed === null)
|
|
@@ -206,7 +273,7 @@ function pruneResults(dir, file, version, limit) {
|
|
|
206
273
|
dropLeastRecentlyUsed(current, limit, new Set([file]));
|
|
207
274
|
}
|
|
208
275
|
function resultsFiles(dir) {
|
|
209
|
-
return cacheEntries(dir, (name) => RESULTS_FILE.test(name) || TEMPORARY_FILE.test(name)).filter((entry) => path.dirname(entry.file) === dir);
|
|
276
|
+
return cacheEntries(dir, (name) => RESULTS_FILE.test(name) || TEMPORARY_FILE.test(name) || JOURNAL_FILE.test(name)).filter((entry) => path.dirname(entry.file) === dir);
|
|
210
277
|
}
|
|
211
278
|
export function resultsCacheStats(dir, limit) {
|
|
212
279
|
const files = resultsFiles(dir).filter((entry) => entry.file.endsWith(".json"));
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { CachedSummary, ResultCache } from "./cache.js";
|
|
2
2
|
import type { IgnoreDirective } from "./ignores.js";
|
|
3
|
+
import type { FactsGate } from "./facts-versions.js";
|
|
3
4
|
import type { ProjectUnit } from "./backend/typescript6.js";
|
|
4
5
|
import type { TimingRecorder } from "./timing.js";
|
|
5
|
-
import type { PackageFactsConfig, CheckNotes, CheckResult, Config, Finding, HiddenFindings, Json, Ledger, Location, Options, Rule, RuleSelection, RuleSetting, Severity, StatedDeclaration } from "./types.js";
|
|
6
|
+
import type { PackageFactsConfig, CheckNotes, CheckResult, Config, Finding, HiddenFindings, Json, Ledger, Location, Options, PluginAnalysis, Rule, RuleSelection, RuleSetting, Severity, StatedDeclaration } from "./types.js";
|
|
6
7
|
/** More findings of one rule in one file than this are counted, not listed. */
|
|
7
8
|
export declare const MAX_FINDINGS_PER_RULE_PER_FILE = 20;
|
|
8
9
|
/**
|
|
@@ -32,6 +33,8 @@ type ActiveRule = {
|
|
|
32
33
|
facts: PackageFactsConfig;
|
|
33
34
|
/** The facts the loaded plugins ship (`Plugin.facts`): part of its cache key too. */
|
|
34
35
|
shippedFacts: PackageFactsConfig;
|
|
36
|
+
/** Both sets as they hold for a file's project versions (`"@versions"`, `factsVerified`). */
|
|
37
|
+
gate: FactsGate;
|
|
35
38
|
};
|
|
36
39
|
/**
|
|
37
40
|
* The rules a run uses, with the settings of the files they run on. A rule that is on in the
|
|
@@ -41,13 +44,30 @@ type ActiveRule = {
|
|
|
41
44
|
*/
|
|
42
45
|
type RuleSets = {
|
|
43
46
|
anywhere: readonly RuleEntry[];
|
|
47
|
+
/** The analyses the rules of `anywhere` read and the config's plugins publish, by id. */
|
|
48
|
+
analyses: readonly AnalysisRun[];
|
|
44
49
|
/** What to run on `file`: the project rules (for their summaries) and the file rules that are on there. */
|
|
45
50
|
forFile(file: string): readonly RuleEntry[];
|
|
46
51
|
/** Whether findings need to be judged by the file they are in. */
|
|
47
52
|
perFile: boolean;
|
|
53
|
+
/** The facts of each file, as they hold for its project's versions. */
|
|
54
|
+
gate: FactsGate;
|
|
48
55
|
/** The setting of a rule at a file, "off" when it is not on there. */
|
|
49
56
|
settingAt(ruleId: string, file: string): RuleSetting;
|
|
50
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* An analysis a rule that runs reads (`ProjectRule.reads`): run once per check, on every file,
|
|
60
|
+
* whether or not its publisher's rules are on. `key` is its cache key (`analysisKey`); `readers`
|
|
61
|
+
* are the rules that read it, sorted (the first is named on a failure of its file side).
|
|
62
|
+
*/
|
|
63
|
+
type AnalysisRun = {
|
|
64
|
+
id: string;
|
|
65
|
+
analysis: PluginAnalysis;
|
|
66
|
+
key: string;
|
|
67
|
+
readers: readonly string[];
|
|
68
|
+
/** As `FileContext.facts`, `shippedFacts` and `withheldFacts`, for each file. */
|
|
69
|
+
gate: FactsGate;
|
|
70
|
+
};
|
|
51
71
|
export declare function compareFindings(a: Finding, b: Finding): number;
|
|
52
72
|
/**
|
|
53
73
|
* A rule with its cache key. `quiet`: the config turns the rule off for this file, but the rule
|
|
@@ -58,6 +78,11 @@ type RuleEntry = ActiveRule & {
|
|
|
58
78
|
key: string;
|
|
59
79
|
quiet?: true;
|
|
60
80
|
};
|
|
81
|
+
/** Where an analysis's file side first threw in this check, and what. */
|
|
82
|
+
type AnalysisFailure = {
|
|
83
|
+
readonly file: string;
|
|
84
|
+
readonly error: unknown;
|
|
85
|
+
};
|
|
61
86
|
/**
|
|
62
87
|
* What the rules' file sides leave for their project sides: findings, summaries and what the
|
|
63
88
|
* result's statistics need, and nothing of the programs, so a caller that needs no more of them
|
|
@@ -67,6 +92,13 @@ export type FilePhase = {
|
|
|
67
92
|
readonly sets: RuleSets;
|
|
68
93
|
readonly findings: Finding[];
|
|
69
94
|
readonly summaries: ReadonlyMap<string, ReadonlyMap<string, CachedSummary>>;
|
|
95
|
+
/** The summaries of each analysis the rules read (`RuleSets.analyses`), by id, then by file. */
|
|
96
|
+
readonly analysisSummaries: ReadonlyMap<string, ReadonlyMap<string, CachedSummary>>;
|
|
97
|
+
/**
|
|
98
|
+
* The analyses whose `summarize` threw on a file, by id: incomplete, so the rules that read
|
|
99
|
+
* them do not run and each reports the failure.
|
|
100
|
+
*/
|
|
101
|
+
readonly analysisFailures: ReadonlyMap<string, AnalysisFailure>;
|
|
70
102
|
readonly directives: ReadonlyMap<string, readonly IgnoreDirective[]>;
|
|
71
103
|
readonly fileCount: number;
|
|
72
104
|
/** Test files checked by pattern, when the config's `exclude` replaces the default list. */
|
|
@@ -99,7 +131,7 @@ export type FilePhase = {
|
|
|
99
131
|
* from it, and a project rule whose summaries are all unchanged reuses its last findings; the
|
|
100
132
|
* cache is then updated with this run (cache.ts). Results that include a failure are not kept.
|
|
101
133
|
*/
|
|
102
|
-
export declare function runFilePhase(config: Config, cwd: string, units: readonly
|
|
134
|
+
export declare function runFilePhase(config: Config, cwd: string, units: readonly UnitSource[], selection?: RuleSelection, cache?: ResultCache, ignores?: boolean, timing?: TimingRecorder): FilePhase;
|
|
103
135
|
/**
|
|
104
136
|
* Where a check stands at a point where it can pause: after a rule that ran on a file, after a
|
|
105
137
|
* file of the file phase, after a project rule of the project phase. `file` and `rule` name what
|
|
@@ -124,8 +156,37 @@ export type PhaseRun<T> = {
|
|
|
124
156
|
};
|
|
125
157
|
/** Runs `steps` to the end, with no pause: the synchronous check. */
|
|
126
158
|
export declare function drain<T>(steps: Generator<CheckProgress, T, undefined>): T;
|
|
159
|
+
/**
|
|
160
|
+
* How many own files of a project share one type checker: after that many files the project
|
|
161
|
+
* starts a new checker on the same parsed program (`ProjectUnit.renewChecker`), so what the old
|
|
162
|
+
* one computed can be collected. The slices follow the file list, so the same input gives the same
|
|
163
|
+
* slices.
|
|
164
|
+
*/
|
|
165
|
+
export type CheckerSlicing = {
|
|
166
|
+
/** Files per checker in the project of `tsconfig`; undefined keeps one checker for the project. */
|
|
167
|
+
readonly filesPerChecker: (tsconfig: string) => number | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* For tests only: the projects and their files in reverse order, to show that what a rule
|
|
170
|
+
* reports on a file does not depend on what the checker answered before.
|
|
171
|
+
*/
|
|
172
|
+
readonly reversed?: true;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* One project of a run, as the file phase reaches it: `open` builds its program (or hands the one
|
|
176
|
+
* built already), and `release` lets it go once the phase is done with its files, so a run that
|
|
177
|
+
* keeps no program holds one project's at a time.
|
|
178
|
+
*/
|
|
179
|
+
export type UnitSource = {
|
|
180
|
+
readonly tsconfig: string;
|
|
181
|
+
/** The unit when it is built already: its files count in the progress from the start. */
|
|
182
|
+
readonly built?: ProjectUnit;
|
|
183
|
+
open(): ProjectUnit;
|
|
184
|
+
release(): void;
|
|
185
|
+
};
|
|
186
|
+
/** Units built already, kept after the phase (`release` lets nothing go). */
|
|
187
|
+
export declare function builtSources(units: readonly ProjectUnit[]): readonly UnitSource[];
|
|
127
188
|
/** `runFilePhase`, one file per step. */
|
|
128
|
-
export declare function filePhaseRun(config: Config, cwd: string, units: readonly
|
|
189
|
+
export declare function filePhaseRun(config: Config, cwd: string, units: readonly UnitSource[], selection?: RuleSelection, cache?: ResultCache, ignores?: boolean, timing?: TimingRecorder, slicing?: CheckerSlicing): PhaseRun<FilePhase>;
|
|
129
190
|
/** The rules' project sides: each project rule's check over the summaries, and the result. */
|
|
130
191
|
export declare function runProjectPhase(config: Config, phase: FilePhase, started: number, keepSummaries?: Map<string, () => ReadonlyMap<string, Json>>, cache?: ResultCache, capped?: boolean, timing?: TimingRecorder): CheckResult;
|
|
131
192
|
/**
|