@stateward/core 1.0.1-rc.1 → 1.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 +80 -4
- package/dist/backend/fingerprints.d.ts +22 -2
- package/dist/backend/fingerprints.js +160 -18
- package/dist/backend/program-record.d.ts +1 -1
- package/dist/backend/qualified-ids.d.ts +6 -0
- package/dist/backend/qualified-ids.js +66 -10
- package/dist/backend/typescript6.d.ts +28 -9
- package/dist/backend/typescript6.js +200 -15
- package/dist/cache.d.ts +5 -4
- package/dist/cache.js +2 -2
- package/dist/checker.d.ts +7 -1
- package/dist/checker.js +19 -3
- package/dist/config.js +47 -4
- package/dist/disk-cache.d.ts +24 -2
- package/dist/disk-cache.js +43 -5
- package/dist/engine.d.ts +11 -1
- package/dist/engine.js +150 -40
- package/dist/guarantees.d.ts +41 -0
- package/dist/guarantees.js +68 -0
- package/dist/ignores.d.ts +2 -2
- package/dist/ignores.js +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/internal.d.ts +5 -3
- package/dist/internal.js +4 -3
- package/dist/plan.d.ts +17 -0
- package/dist/plan.js +22 -5
- package/dist/testing-tsc.d.ts +11 -0
- package/dist/testing-tsc.js +125 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.js +13 -0
- package/dist/types.d.ts +121 -0
- package/package.json +1 -1
package/dist/engine.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { CachedSummary, ResultCache } from "./cache.js";
|
|
|
2
2
|
import type { IgnoreDirective } from "./ignores.js";
|
|
3
3
|
import type { ProjectUnit } from "./backend/typescript6.js";
|
|
4
4
|
import type { TimingRecorder } from "./timing.js";
|
|
5
|
-
import type { PackageFactsConfig, CheckResult, Config, Finding, HiddenFindings, Json, Location, Options, Rule, RuleSelection, RuleSetting, Severity } from "./types.js";
|
|
5
|
+
import type { PackageFactsConfig, CheckNotes, CheckResult, Config, Finding, HiddenFindings, Json, Location, Options, Rule, RuleSelection, RuleSetting, Severity } from "./types.js";
|
|
6
6
|
/** More findings of one rule in one file than this are counted, not listed. */
|
|
7
7
|
export declare const MAX_FINDINGS_PER_RULE_PER_FILE = 20;
|
|
8
8
|
/**
|
|
@@ -12,6 +12,12 @@ export declare const MAX_FINDINGS_PER_RULE_PER_FILE = 20;
|
|
|
12
12
|
export declare const SYNTAX_RULE_ID = "stateward/syntax";
|
|
13
13
|
/** The id of the finding for a file with imports that do not resolve; cached like the syntax one. */
|
|
14
14
|
export declare const IMPORTS_RULE_ID = "stateward/imports";
|
|
15
|
+
/** The remedy said once when a project checks without `strictNullChecks`. */
|
|
16
|
+
export declare const STRICT_NULLS_REMEDY = "set `strict: true` or `strictNullChecks: true` in tsconfig.json";
|
|
17
|
+
/** Added to the fix line of a finding whose fix relies on `strictNullChecks` in a project without it. */
|
|
18
|
+
export declare const LOOSE_NULLS_FIX = "`strictNullChecks` is off in this project, so TypeScript does not check `null` and `undefined` in this fix: set `strict: true` or `strictNullChecks: true` in tsconfig.json";
|
|
19
|
+
/** Why rules that read a library by its types could not run: "React's types are not installed (…)". */
|
|
20
|
+
export declare function missingTypesReason(library: string): string;
|
|
15
21
|
type ActiveRule = {
|
|
16
22
|
id: string;
|
|
17
23
|
/** The plugin's name and the rule's name within it: `id` is "<plugin>/<name>". */
|
|
@@ -64,6 +70,10 @@ export type FilePhase = {
|
|
|
64
70
|
tsconfig: string;
|
|
65
71
|
files: number;
|
|
66
72
|
}[] | undefined;
|
|
73
|
+
/** What the run cannot check as a whole (`CheckResult.notes`). */
|
|
74
|
+
readonly notes: CheckNotes | undefined;
|
|
75
|
+
/** The own files of the projects without `strictNullChecks`. */
|
|
76
|
+
readonly looseNulls: ReadonlySet<string>;
|
|
67
77
|
};
|
|
68
78
|
/**
|
|
69
79
|
* The first of the two phases of running the rules (then `runProjectPhase`): every active rule
|
package/dist/engine.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { readRollout } from "./rollout.js";
|
|
3
|
-
import { ruleKey, sha1, summaryOf, summaryValue } from "./cache.js";
|
|
3
|
+
import { ruleKey, sha1, summaryOf, summaryText, summaryValue } from "./cache.js";
|
|
4
4
|
import { defaultOptions } from "./options.js";
|
|
5
5
|
import { codeOf, loadRule } from "./lazy.js";
|
|
6
6
|
import { IGNORE_EXPLAIN, IGNORE_RULE_ID, applyIgnores, fileDirectives } from "./ignores.js";
|
|
@@ -27,8 +27,8 @@ function syntaxFinding(unit, file, cwd) {
|
|
|
27
27
|
{
|
|
28
28
|
kind: "unknown",
|
|
29
29
|
ruleId: SYNTAX_RULE_ID,
|
|
30
|
-
message:
|
|
31
|
-
hint:
|
|
30
|
+
message: `not checked: \`${name}\`: it has a syntax error`,
|
|
31
|
+
hint: `fix the syntax error at line ${String(error.line)}:${String(error.column)} (${error.message}), then check again`,
|
|
32
32
|
location: { file, start: error.start, end: error.end },
|
|
33
33
|
},
|
|
34
34
|
];
|
|
@@ -45,34 +45,29 @@ function squeeze(text, max) {
|
|
|
45
45
|
return `${text.slice(0, head)}…${text.slice(text.length - (keep - head))}`;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* The headline of an imports finding, in at most 100 characters:
|
|
49
|
-
*
|
|
48
|
+
* The headline of an imports finding (M19), in at most 100 characters: the specifier is shortened
|
|
49
|
+
* in the middle when it does not fit; the location shows the file.
|
|
50
50
|
*/
|
|
51
|
-
function importsMessage(
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (fits !== undefined)
|
|
65
|
-
return fits;
|
|
66
|
-
const room = MAX_HEADLINE - `\`\` ${short}`.length;
|
|
67
|
-
return `\`${squeeze(specifier, room)}\` ${short}`;
|
|
51
|
+
function importsMessage(specifier, untyped) {
|
|
52
|
+
const relative = specifier.startsWith(".") || specifier.startsWith("/");
|
|
53
|
+
const why = untyped
|
|
54
|
+
? "it has no types"
|
|
55
|
+
: relative
|
|
56
|
+
? "the file is not found"
|
|
57
|
+
: "the package is not installed";
|
|
58
|
+
const form = (spec) => `not checked: code using \`${spec}\`: ${why}`;
|
|
59
|
+
const whole = form(specifier);
|
|
60
|
+
if (whole.length <= MAX_HEADLINE)
|
|
61
|
+
return whole;
|
|
62
|
+
const room = MAX_HEADLINE - form("").length;
|
|
63
|
+
return form(squeeze(specifier, room));
|
|
68
64
|
}
|
|
69
65
|
/** The one `unknown` finding for a file whose imports do not resolve (types from them are unknown). */
|
|
70
66
|
function importsFinding(unit, file, cwd) {
|
|
71
67
|
const [first, ...rest] = unit.unresolvedImports(file);
|
|
72
68
|
if (first === undefined)
|
|
73
69
|
return [];
|
|
74
|
-
const
|
|
75
|
-
const more = rest.length > 0 ? `; ${String(rest.length)} more unresolved in this file` : "";
|
|
70
|
+
const more = rest.length > 0 ? `; ${String(rest.length)} more unresolved in the file` : "";
|
|
76
71
|
// Imports resolve by the project's options: a file two projects list says which one decided.
|
|
77
72
|
const project = unit.listedElsewhere(file)
|
|
78
73
|
? ` (checked as part of \`${path.relative(cwd, unit.tsconfig).split(path.sep).join("/")}\`)`
|
|
@@ -83,7 +78,7 @@ function importsFinding(unit, file, cwd) {
|
|
|
83
78
|
{
|
|
84
79
|
kind: "unknown",
|
|
85
80
|
ruleId: IMPORTS_RULE_ID,
|
|
86
|
-
message: importsMessage(
|
|
81
|
+
message: importsMessage(first.specifier, untyped),
|
|
87
82
|
hint: untyped
|
|
88
83
|
? `install its types (\`${types}\`) or declare the module${more}${project}`
|
|
89
84
|
: `install the project's packages (or build its workspace packages) and check again${more}${project}`,
|
|
@@ -91,6 +86,65 @@ function importsFinding(unit, file, cwd) {
|
|
|
91
86
|
},
|
|
92
87
|
];
|
|
93
88
|
}
|
|
89
|
+
/** The remedy said once when a project checks without `strictNullChecks`. */
|
|
90
|
+
export const STRICT_NULLS_REMEDY = "set `strict: true` or `strictNullChecks: true` in tsconfig.json";
|
|
91
|
+
/** Added to the fix line of a finding whose fix relies on `strictNullChecks` in a project without it. */
|
|
92
|
+
export const LOOSE_NULLS_FIX = `\`strictNullChecks\` is off in this project, so TypeScript does not check \`null\` and \`undefined\` in this fix: ${STRICT_NULLS_REMEDY}`;
|
|
93
|
+
/** Why rules that read a library by its types could not run: "React's types are not installed (…)". */
|
|
94
|
+
export function missingTypesReason(library) {
|
|
95
|
+
return `${library}'s types are not installed (install the app's dependencies)`;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* What the run cannot check as a whole (`CheckResult.notes`): the rules among `rules` whose
|
|
99
|
+
* library's types do not resolve in some project with files, and the projects without
|
|
100
|
+
* `strictNullChecks`. Undefined when there is nothing to say.
|
|
101
|
+
*/
|
|
102
|
+
function notesOf(units, rules) {
|
|
103
|
+
const missing = new Map();
|
|
104
|
+
const looseNulls = [];
|
|
105
|
+
for (const unit of units) {
|
|
106
|
+
if (unit.files.length === 0)
|
|
107
|
+
continue;
|
|
108
|
+
if (!unit.strictNullChecks)
|
|
109
|
+
looseNulls.push(unit.tsconfig);
|
|
110
|
+
for (const entry of rules) {
|
|
111
|
+
const needs = entry.rule.meta.needsTypes;
|
|
112
|
+
if (needs === undefined || needs.modules.some((module) => unit.typesResolve(module)))
|
|
113
|
+
continue;
|
|
114
|
+
const ids = missing.get(needs.library) ?? new Set();
|
|
115
|
+
ids.add(entry.id);
|
|
116
|
+
missing.set(needs.library, ids);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (missing.size === 0 && looseNulls.length === 0)
|
|
120
|
+
return undefined;
|
|
121
|
+
const missingTypes = [...missing]
|
|
122
|
+
.sort(([a], [b]) => compareText(a, b))
|
|
123
|
+
.map(([library, ids]) => ({
|
|
124
|
+
library,
|
|
125
|
+
reason: missingTypesReason(library),
|
|
126
|
+
rules: [...ids].sort(compareText),
|
|
127
|
+
}));
|
|
128
|
+
return { missingTypes, looseNulls };
|
|
129
|
+
}
|
|
130
|
+
/** The own files of the projects without `strictNullChecks`. */
|
|
131
|
+
function looseNullFiles(units) {
|
|
132
|
+
return new Set(units.flatMap((unit) => (unit.strictNullChecks ? [] : unit.files)));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* `findings` with `LOOSE_NULLS_FIX` added to the fix line of each problem whose rule's fix needs
|
|
136
|
+
* `strictNullChecks` (`RuleInfo.fixNeedsStrictNulls`) in a file of a project without it.
|
|
137
|
+
*/
|
|
138
|
+
function withLooseNullFixes(findings, rules, loose) {
|
|
139
|
+
if (loose.size === 0)
|
|
140
|
+
return findings;
|
|
141
|
+
const affected = new Set(rules.filter((entry) => entry.rule.meta.fixNeedsStrictNulls === true).map((entry) => entry.id));
|
|
142
|
+
if (affected.size === 0)
|
|
143
|
+
return findings;
|
|
144
|
+
return findings.map((finding) => finding.kind === "problem" && affected.has(finding.ruleId) && loose.has(finding.location.file)
|
|
145
|
+
? { ...finding, hint: `${finding.hint}\n${LOOSE_NULLS_FIX}` }
|
|
146
|
+
: finding);
|
|
147
|
+
}
|
|
94
148
|
/** What ignore comments may name, and what ran: the config's rules and what stateward reports itself. */
|
|
95
149
|
function ignoreScope(config, ran) {
|
|
96
150
|
const known = new Set([SYNTAX_RULE_ID, IMPORTS_RULE_ID]);
|
|
@@ -577,7 +631,7 @@ nextFiles, cache, ignores, timing) {
|
|
|
577
631
|
nextFiles.set(file, {
|
|
578
632
|
fingerprint,
|
|
579
633
|
rules: results,
|
|
580
|
-
reads: readsAfter(unit, file, holding),
|
|
634
|
+
reads: readsAfter(unit, file, holding, results),
|
|
581
635
|
});
|
|
582
636
|
}
|
|
583
637
|
done += 1;
|
|
@@ -605,6 +659,8 @@ nextFiles, cache, ignores, timing) {
|
|
|
605
659
|
projects: units.length > 1
|
|
606
660
|
? units.map((unit) => ({ tsconfig: unit.tsconfig, files: unit.files.length }))
|
|
607
661
|
: undefined,
|
|
662
|
+
notes: notesOf(units, rules),
|
|
663
|
+
looseNulls: looseNullFiles(units),
|
|
608
664
|
};
|
|
609
665
|
}
|
|
610
666
|
/** The rules' project sides: each project rule's check over the summaries, and the result. */
|
|
@@ -665,7 +721,7 @@ export function* projectPhaseSteps(config, phase, started, keepSummaries, cache,
|
|
|
665
721
|
}
|
|
666
722
|
findings.push(...atTheirFiles(sets, entry, own));
|
|
667
723
|
}
|
|
668
|
-
const covered = applyIgnores(oneCauseOneMessage(findings, rules), directives, ignoreScope(config, rules));
|
|
724
|
+
const covered = applyIgnores(withLooseNullFixes(oneCauseOneMessage(findings, rules), rules, phase.looseNulls), directives, ignoreScope(config, rules));
|
|
669
725
|
covered.findings.sort(compareFindings);
|
|
670
726
|
const { shown, hidden } = capped
|
|
671
727
|
? limitPerRuleAndFile(withUnknownsShown(covered.findings, config.unknowns))
|
|
@@ -674,6 +730,7 @@ export function* projectPhaseSteps(config, phase, started, keepSummaries, cache,
|
|
|
674
730
|
findings: shown,
|
|
675
731
|
hidden,
|
|
676
732
|
ignored: covered.ignored,
|
|
733
|
+
...(phase.notes === undefined ? {} : { notes: phase.notes }),
|
|
677
734
|
stats: {
|
|
678
735
|
files: fileCount,
|
|
679
736
|
durationMs: Math.round(performance.now() - started),
|
|
@@ -719,10 +776,44 @@ export function limitFindings(sorted) {
|
|
|
719
776
|
const { shown, hidden } = limitPerRuleAndFile(sorted);
|
|
720
777
|
return { findings: shown, hidden };
|
|
721
778
|
}
|
|
779
|
+
/**
|
|
780
|
+
* Which findings the per-rule, per-file cap keeps first: failures, then errors, warnings, infos,
|
|
781
|
+
* and places not checked last. Kept in position order, a file's first 20 "not checked" places of a
|
|
782
|
+
* rule could hide an error of the same rule further down, and the check would pass.
|
|
783
|
+
*/
|
|
784
|
+
function capRank(finding) {
|
|
785
|
+
switch (finding.kind) {
|
|
786
|
+
case "failure":
|
|
787
|
+
return 0;
|
|
788
|
+
case "problem":
|
|
789
|
+
switch (finding.severity) {
|
|
790
|
+
case "error":
|
|
791
|
+
return 1;
|
|
792
|
+
case "warning":
|
|
793
|
+
return 2;
|
|
794
|
+
case "info":
|
|
795
|
+
return 3;
|
|
796
|
+
default: {
|
|
797
|
+
const unreachable = finding.severity;
|
|
798
|
+
return unreachable;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
case "unknown":
|
|
802
|
+
return 4;
|
|
803
|
+
default: {
|
|
804
|
+
const unreachable = finding;
|
|
805
|
+
return unreachable;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
722
809
|
function limitPerRuleAndFile(sorted) {
|
|
723
810
|
const seen = new Map();
|
|
724
|
-
const
|
|
725
|
-
|
|
811
|
+
const kept = new Set();
|
|
812
|
+
// Decide in priority order (stable within a rank), then list what is kept in position order.
|
|
813
|
+
const byRank = sorted
|
|
814
|
+
.map((finding, index) => ({ finding, index }))
|
|
815
|
+
.sort((a, b) => capRank(a.finding) - capRank(b.finding) || a.index - b.index);
|
|
816
|
+
for (const { finding } of byRank) {
|
|
726
817
|
const key = JSON.stringify([finding.location.file, finding.ruleId]);
|
|
727
818
|
const entry = seen.get(key) ?? {
|
|
728
819
|
file: finding.location.file,
|
|
@@ -733,12 +824,13 @@ function limitPerRuleAndFile(sorted) {
|
|
|
733
824
|
seen.set(key, entry);
|
|
734
825
|
if (entry.listed < MAX_FINDINGS_PER_RULE_PER_FILE) {
|
|
735
826
|
entry.listed++;
|
|
736
|
-
|
|
827
|
+
kept.add(finding);
|
|
737
828
|
}
|
|
738
829
|
else {
|
|
739
830
|
entry.count++;
|
|
740
831
|
}
|
|
741
832
|
}
|
|
833
|
+
const shown = sorted.filter((finding) => kept.has(finding));
|
|
742
834
|
const hidden = [...seen.values()]
|
|
743
835
|
.filter((entry) => entry.count > 0)
|
|
744
836
|
.map(({ file, ruleId, count }) => ({ file, ruleId, count }))
|
|
@@ -766,27 +858,45 @@ function secondPass(units, sets, timing) {
|
|
|
766
858
|
}
|
|
767
859
|
}
|
|
768
860
|
}
|
|
769
|
-
/** Whether
|
|
861
|
+
/** Whether everything a cached entry read of other files (declarations, files) is as it was then. */
|
|
770
862
|
function readsHold(unit, reads) {
|
|
771
|
-
for (const [
|
|
772
|
-
if (unit.readFingerprint(
|
|
863
|
+
for (const [read, print] of reads) {
|
|
864
|
+
if (unit.readFingerprint(read) !== print)
|
|
773
865
|
return false;
|
|
774
866
|
}
|
|
775
867
|
return true;
|
|
776
868
|
}
|
|
869
|
+
/** A print no read has: what could not be hashed never holds. */
|
|
870
|
+
const NO_PRINT = "";
|
|
777
871
|
/**
|
|
778
872
|
* The reads of a file's entry after this run: those of the entry it kept (its rules that did not
|
|
779
|
-
* run read them), with what the rules that ran on it in this program read, each with its
|
|
873
|
+
* run read them), with what the rules that ran on it in this program read, each with its hash
|
|
874
|
+
* (`ProjectUnit.readsOf`). A declaration is read by its id, unless the file's results name the
|
|
875
|
+
* file it is in: a rule that keeps another file's offsets (a location, a summary's span) changes
|
|
876
|
+
* with any edit above them, so the whole file is read.
|
|
780
877
|
*/
|
|
781
|
-
function readsAfter(unit, file, kept) {
|
|
878
|
+
function readsAfter(unit, file, kept, results) {
|
|
782
879
|
const reads = new Map(kept?.reads ?? []);
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
880
|
+
let text;
|
|
881
|
+
const mentioned = (readFile) => {
|
|
882
|
+
text ??= resultsText(results);
|
|
883
|
+
return text.includes(readFile);
|
|
884
|
+
};
|
|
885
|
+
for (const read of unit.readsOf(file, mentioned)) {
|
|
886
|
+
reads.set(read, unit.readFingerprint(read) ?? NO_PRINT);
|
|
787
887
|
}
|
|
788
888
|
return reads;
|
|
789
889
|
}
|
|
890
|
+
/** The findings and summaries of a file's results, as text: what the results could name. */
|
|
891
|
+
function resultsText(results) {
|
|
892
|
+
const parts = [];
|
|
893
|
+
for (const result of results.values()) {
|
|
894
|
+
parts.push(JSON.stringify(result.findings));
|
|
895
|
+
if (result.summary !== undefined)
|
|
896
|
+
parts.push(summaryText(result.summary));
|
|
897
|
+
}
|
|
898
|
+
return parts.join("\n");
|
|
899
|
+
}
|
|
790
900
|
/** The parsed file, its program bound first (rules need parents): building the program if it is lazy. */
|
|
791
901
|
function boundSourceFile(unit, file) {
|
|
792
902
|
unit.bind();
|
|
@@ -922,7 +1032,7 @@ export function runFileRules(config, cwd, units, files, started, capped = true,
|
|
|
922
1032
|
}
|
|
923
1033
|
}
|
|
924
1034
|
// Only the file rules ran, so an ignore of a project rule is not judged here.
|
|
925
|
-
const covered = applyIgnores(oneCauseOneMessage(findings, rules), directives, ignoreScope(config, rules));
|
|
1035
|
+
const covered = applyIgnores(withLooseNullFixes(oneCauseOneMessage(findings, rules), rules, looseNullFiles(units)), directives, ignoreScope(config, rules));
|
|
926
1036
|
covered.findings.sort(compareFindings);
|
|
927
1037
|
const { shown, hidden } = capped
|
|
928
1038
|
? limitPerRuleAndFile(withUnknownsShown(covered.findings, config.unknowns))
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Finding, StatedGuarantee } from "./types.js";
|
|
2
|
+
type Problem = Extract<Finding, {
|
|
3
|
+
kind: "problem";
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* Where a stated guarantee stands after a check:
|
|
7
|
+
* - `proven`: its rule ran and reported nothing about it;
|
|
8
|
+
* - `unproven`: its rule reported these errors about it (each names the declaration);
|
|
9
|
+
* - `unused`: nothing uses it, so there is nothing to prove (a dead marker);
|
|
10
|
+
* - `off`: its rule is not on (the rollout has not reached it), so nothing proves it.
|
|
11
|
+
*/
|
|
12
|
+
export type GuaranteeStatus = {
|
|
13
|
+
readonly kind: "proven";
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "unproven";
|
|
16
|
+
readonly errors: readonly Problem[];
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "unused";
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: "off";
|
|
21
|
+
};
|
|
22
|
+
export type GuaranteeProof = {
|
|
23
|
+
readonly stated: StatedGuarantee;
|
|
24
|
+
readonly status: GuaranteeStatus;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Each stated guarantee with its status, in file and offset order. `findings` are a check's
|
|
28
|
+
* (after ignore comments, before a baseline: an accepted error still leaves it unproven);
|
|
29
|
+
* `active` the rules that check ran. A finding is about a guarantee when it is a problem of the
|
|
30
|
+
* guarantee's rule, not an info, with a related note at the declaration.
|
|
31
|
+
*/
|
|
32
|
+
export declare function proveGuarantees(stated: readonly StatedGuarantee[], findings: readonly Finding[], active: ReadonlySet<string>): GuaranteeProof[];
|
|
33
|
+
/**
|
|
34
|
+
* The status in a few words, the same in `stateward guarantees` and the editor: "proven for 3
|
|
35
|
+
* readers", "not proven: 2 errors", "unused: nothing reads it", "not checked: … is not on".
|
|
36
|
+
*/
|
|
37
|
+
export declare function describeStatus(proof: GuaranteeProof): string;
|
|
38
|
+
/** The guarantee whose declaration covers `offset` of `file` (a TypeScript path), if any. */
|
|
39
|
+
export declare function guaranteeAt(proofs: readonly GuaranteeProof[], file: string, offset: number): GuaranteeProof | undefined;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=guarantees.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { compareFindings } from "./engine.js";
|
|
2
|
+
function sameStart(a, b) {
|
|
3
|
+
return a.file === b.file && a.start === b.start;
|
|
4
|
+
}
|
|
5
|
+
function compareStated(a, b) {
|
|
6
|
+
if (a.location.file !== b.location.file)
|
|
7
|
+
return a.location.file < b.location.file ? -1 : 1;
|
|
8
|
+
return a.location.start - b.location.start || (a.guarantee < b.guarantee ? -1 : 1);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Each stated guarantee with its status, in file and offset order. `findings` are a check's
|
|
12
|
+
* (after ignore comments, before a baseline: an accepted error still leaves it unproven);
|
|
13
|
+
* `active` the rules that check ran. A finding is about a guarantee when it is a problem of the
|
|
14
|
+
* guarantee's rule, not an info, with a related note at the declaration.
|
|
15
|
+
*/
|
|
16
|
+
export function proveGuarantees(stated, findings, active) {
|
|
17
|
+
const problems = findings
|
|
18
|
+
.filter((finding) => finding.kind === "problem")
|
|
19
|
+
.filter((finding) => finding.severity !== "info");
|
|
20
|
+
return [...stated].sort(compareStated).map((guarantee) => {
|
|
21
|
+
if (!active.has(guarantee.ruleId))
|
|
22
|
+
return { stated: guarantee, status: { kind: "off" } };
|
|
23
|
+
const errors = problems
|
|
24
|
+
.filter((finding) => finding.ruleId === guarantee.ruleId &&
|
|
25
|
+
finding.related.some((note) => sameStart(note.location, guarantee.location)))
|
|
26
|
+
.sort(compareFindings);
|
|
27
|
+
if (errors.length > 0)
|
|
28
|
+
return { stated: guarantee, status: { kind: "unproven", errors } };
|
|
29
|
+
if (guarantee.covered.length === 0)
|
|
30
|
+
return { stated: guarantee, status: { kind: "unused" } };
|
|
31
|
+
return { stated: guarantee, status: { kind: "proven" } };
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function plural(count, noun) {
|
|
35
|
+
return `${String(count)} ${count === 1 ? noun : `${noun}s`}`;
|
|
36
|
+
}
|
|
37
|
+
/** "reader" for "readers": the noun of one covered place. */
|
|
38
|
+
function singular(covers) {
|
|
39
|
+
return covers.endsWith("s") ? covers.slice(0, -1) : covers;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The status in a few words, the same in `stateward guarantees` and the editor: "proven for 3
|
|
43
|
+
* readers", "not proven: 2 errors", "unused: nothing reads it", "not checked: … is not on".
|
|
44
|
+
*/
|
|
45
|
+
export function describeStatus(proof) {
|
|
46
|
+
const { stated, status } = proof;
|
|
47
|
+
switch (status.kind) {
|
|
48
|
+
case "proven":
|
|
49
|
+
return `proven for ${plural(stated.covered.length, singular(stated.covers))}`;
|
|
50
|
+
case "unproven":
|
|
51
|
+
return `not proven: ${plural(status.errors.length, "error")}`;
|
|
52
|
+
case "unused":
|
|
53
|
+
return `unused: no ${singular(stated.covers)}, so nothing to prove; use it or drop the marker`;
|
|
54
|
+
case "off":
|
|
55
|
+
return `not checked: ${stated.ruleId} is not on`;
|
|
56
|
+
default: {
|
|
57
|
+
const unreachable = status;
|
|
58
|
+
return unreachable;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** The guarantee whose declaration covers `offset` of `file` (a TypeScript path), if any. */
|
|
63
|
+
export function guaranteeAt(proofs, file, offset) {
|
|
64
|
+
return proofs.find(({ stated }) => stated.location.file === file &&
|
|
65
|
+
offset >= stated.location.start &&
|
|
66
|
+
offset <= stated.location.end);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=guarantees.js.map
|
package/dist/ignores.d.ts
CHANGED
|
@@ -63,8 +63,8 @@ export declare function applyIgnores(findings: readonly Finding[], directives: R
|
|
|
63
63
|
ignored: IgnoredFinding[];
|
|
64
64
|
};
|
|
65
65
|
/** The page `stateward explain stateward/ignore` shows. */
|
|
66
|
-
export declare const IGNORE_EXPLAIN = "# stateward/ignore\n\nA `stateward-ignore` comment is missing its reason, names a rule that does not exist, or ignores nothing.\n\n## Why\n\nA comment that ignores one case should say why the case is fine, and should go when the case is fixed.\nOtherwise the next person cannot tell an intended exception from a forgotten one, and old comments\npile up. stateward checks the comments the way it checks your code.\n\n## When to use it\n\nPut a comment on the line above a finding that is intended, with the rule and the reason:\n\n // stateward-ignore records/lookup-misses-key: keys come from the server's fixed list\n const label = labels[status];\n\nSeveral rules go in one comment, separated by commas. For a whole file, put\n`// stateward-ignore-file <rule>: <reason>` above its first statement. Comment lines between the\nignore and the code are fine. In VS Code, the quick fix \"
|
|
67
|
-
export declare const IGNORE_FIX_TITLE = "
|
|
66
|
+
export declare const IGNORE_EXPLAIN = "# stateward/ignore\n\nA `stateward-ignore` comment is missing its reason, names a rule that does not exist, or ignores nothing.\n\n## Why\n\nA comment that ignores one case should say why the case is fine, and should go when the case is fixed.\nOtherwise the next person cannot tell an intended exception from a forgotten one, and old comments\npile up. stateward checks the comments the way it checks your code.\n\n## When to use it\n\nPut a comment on the line above a finding that is intended, with the rule and the reason:\n\n // stateward-ignore records/lookup-misses-key: keys come from the server's fixed list\n const label = labels[status];\n\nSeveral rules go in one comment, separated by commas. For a whole file, put\n`// stateward-ignore-file <rule>: <reason>` above its first statement. Comment lines between the\nignore and the code are fine. In VS Code, the quick fix \"Add an ignore comment\" writes it.\n\n## What it catches\n\n- an ignore with no reason after the colon (it still works; this is a warning)\n- an ignore that no longer covers a finding: the code was fixed or moved (a warning; the quick fix removes it)\n- a rule id that does not exist, with the closest one (an error: the ignore does nothing)\n- `stateward-ignore-file` below the first statement, and an ignore with no rule\n\n## What it does not catch\n\nWhether the reason is a good one. A comment is not the same as a baseline: the baseline says \"fix\nlater\", a comment says \"this is intended\". Both stay. Findings of this rule cannot be ignored.\n\n## Turn it on or off\n\nIt is always on. `stateward check --no-ignores` shows the findings that comments cover, and the\nsummary counts them (\"2 ignored in the code\"). Fix a comment, or remove it, to clear its finding.\n";
|
|
67
|
+
export declare const IGNORE_FIX_TITLE = "Add an ignore comment";
|
|
68
68
|
/**
|
|
69
69
|
* "Ignore this case here": `// stateward-ignore <rule>: ` on the line above the finding, indented
|
|
70
70
|
* like it, so the warning about the missing reason asks for the reason at once. Undefined for a
|
package/dist/ignores.js
CHANGED
|
@@ -294,7 +294,7 @@ function judge(file, directive, used, scope) {
|
|
|
294
294
|
const form = directive.file ? "stateward-ignore-file" : "stateward-ignore";
|
|
295
295
|
if (directive.rules.length === 0) {
|
|
296
296
|
return [
|
|
297
|
-
commentFinding(file, here, "warning", "
|
|
297
|
+
commentFinding(file, here, "warning", "ignore comment does not name a rule", `write the rule, then why: \`// ${form} <rule>: <why this case is fine>\``, []),
|
|
298
298
|
];
|
|
299
299
|
}
|
|
300
300
|
if (directive.file && !directive.placed) {
|
|
@@ -310,9 +310,9 @@ function judge(file, directive, used, scope) {
|
|
|
310
310
|
}
|
|
311
311
|
else if (!scope.known.has(rule.id)) {
|
|
312
312
|
const guess = closest(rule.id, scope.known);
|
|
313
|
-
found.push(commentFinding(file, rule, "error", fits(`\`${rule.id}\` is not a stateward rule`, MAX_HEADLINE, "
|
|
314
|
-
? "write a rule id as a finding shows it, such as `records/lookup-misses-key`;
|
|
315
|
-
: `
|
|
313
|
+
found.push(commentFinding(file, rule, "error", fits(`\`${rule.id}\` is not a stateward rule`, MAX_HEADLINE, "ignore comment names a rule that does not exist"), fits(guess === undefined
|
|
314
|
+
? "write a rule id as a finding shows it, such as `records/lookup-misses-key`; until then the comment ignores nothing"
|
|
315
|
+
: `write \`${guess}\`, the rule with the nearest name; until then the comment ignores nothing`, MAX_HINT, "check the rule id; until it is right the comment ignores nothing"), guess === undefined
|
|
316
316
|
? []
|
|
317
317
|
: [
|
|
318
318
|
{
|
|
@@ -328,11 +328,11 @@ function judge(file, directive, used, scope) {
|
|
|
328
328
|
if (unused.length > 0 && scope.options.reportUnused !== "off") {
|
|
329
329
|
const everything = unused.length === directive.rules.length;
|
|
330
330
|
const keep = directive.rules.map((rule) => rule.id).filter((id) => !unused.includes(id));
|
|
331
|
-
const where = directive.file ? "in
|
|
332
|
-
found.push(commentFinding(file, here, scope.options.reportUnused, fits(`
|
|
331
|
+
const where = directive.file ? "in the file" : "in the code it covers";
|
|
332
|
+
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", [
|
|
333
333
|
everything
|
|
334
334
|
? {
|
|
335
|
-
title: "Remove
|
|
335
|
+
title: "Remove the ignore comment",
|
|
336
336
|
safe: true,
|
|
337
337
|
edits: [
|
|
338
338
|
{
|
|
@@ -342,7 +342,7 @@ function judge(file, directive, used, scope) {
|
|
|
342
342
|
],
|
|
343
343
|
}
|
|
344
344
|
: {
|
|
345
|
-
title: `Remove ${names(unused)} from
|
|
345
|
+
title: `Remove ${names(unused)} from the ignore comment`,
|
|
346
346
|
safe: true,
|
|
347
347
|
edits: [{ location: { file, ...here }, newText: rebuilt(directive, keep) }],
|
|
348
348
|
},
|
|
@@ -350,7 +350,7 @@ function judge(file, directive, used, scope) {
|
|
|
350
350
|
}
|
|
351
351
|
if (directive.reason === "" && scope.options.requireReason) {
|
|
352
352
|
const first = directive.rules[0]?.id ?? "<rule>";
|
|
353
|
-
found.push(commentFinding(file, here, "warning", "
|
|
353
|
+
found.push(commentFinding(file, here, "warning", "ignore comment does not say why the case is fine", fits(`add the reason after a colon: \`// ${form} ${first}: <why this case is fine>\``, MAX_HINT, "add the reason after a colon, and say why this case is fine"), []));
|
|
354
354
|
}
|
|
355
355
|
return found;
|
|
356
356
|
}
|
|
@@ -420,7 +420,7 @@ Put a comment on the line above a finding that is intended, with the rule and th
|
|
|
420
420
|
|
|
421
421
|
Several rules go in one comment, separated by commas. For a whole file, put
|
|
422
422
|
\`// stateward-ignore-file <rule>: <reason>\` above its first statement. Comment lines between the
|
|
423
|
-
ignore and the code are fine. In VS Code, the quick fix "
|
|
423
|
+
ignore and the code are fine. In VS Code, the quick fix "Add an ignore comment" writes it.
|
|
424
424
|
|
|
425
425
|
## What it catches
|
|
426
426
|
|
|
@@ -439,7 +439,7 @@ later", a comment says "this is intended". Both stay. Findings of this rule cann
|
|
|
439
439
|
It is always on. \`stateward check --no-ignores\` shows the findings that comments cover, and the
|
|
440
440
|
summary counts them ("2 ignored in the code"). Fix a comment, or remove it, to clear its finding.
|
|
441
441
|
`;
|
|
442
|
-
export const IGNORE_FIX_TITLE = "
|
|
442
|
+
export const IGNORE_FIX_TITLE = "Add an ignore comment";
|
|
443
443
|
/**
|
|
444
444
|
* "Ignore this case here": `// stateward-ignore <rule>: ` on the line above the finding, indented
|
|
445
445
|
* like it, so the warning about the missing reason asks for the reason at once. Undefined for a
|
package/dist/index.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ export type { PackageCacheKey } from "./package-cache.js";
|
|
|
16
16
|
export { findPackageRoot, reparsedWithJsDoc } from "./backend/package-source.js";
|
|
17
17
|
export { openPackageSource } from "./backend/typescript6.js";
|
|
18
18
|
export type { PackageSource } from "./backend/typescript6.js";
|
|
19
|
-
export type { BooleanOption, CheckResult, Config, ConfigOverride, EditorAction, EditorContributions, EditorHint, ExtendedConfig, FileContext, FactSource, FileRule, Finding, FunctionFacts, LibraryUse, PackageFactsConfig, Fix, FixForm, FixReview, FixSetReview, FixVerdict, RejectedFix, GroupIdOf, HiddenFindings, IgnoreOptions, IgnoredFinding, Json, Literal, NarrowedMembers, 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";
|
|
19
|
+
export type { BooleanOption, CheckNotes, CheckResult, Config, ConfigOverride, 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, 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";
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/internal.d.ts
CHANGED
|
@@ -9,12 +9,14 @@ export { matchingOverrides } from "./overrides.js";
|
|
|
9
9
|
export { ROLLOUT_FILE, RolloutError, readRollout, rolloutFile, writeRollout } from "./rollout.js";
|
|
10
10
|
export { BASELINE_FILE, BaselineError, OUTDATED_BASELINE, applyBaseline, baselineFile, baselineOf, fingerprintOf, isOutdated, mergeBaseline, readBaseline, sizeOf, writeBaseline, } from "./baseline.js";
|
|
11
11
|
export type { Baseline, BaselineEntry, BaselineView, FingerprintContext } from "./baseline.js";
|
|
12
|
-
export { advance, buildPlan, describeTurnOn } from "./plan.js";
|
|
12
|
+
export { advance, buildPlan, describeNotChecked, describeTurnOn, isClean } from "./plan.js";
|
|
13
13
|
export type { Advance, Plan, PlanRow } from "./plan.js";
|
|
14
14
|
export { findConfigFile, findConfigUpward, loadConfig, loadConfigFile, reloadsLocalImports, } from "./config-file.js";
|
|
15
|
-
export { MAX_FINDINGS_PER_RULE_PER_FILE, activeRuleIds, compareFindings, explain, limitFindings, } from "./engine.js";
|
|
15
|
+
export { LOOSE_NULLS_FIX, MAX_FINDINGS_PER_RULE_PER_FILE, STRICT_NULLS_REMEDY, activeRuleIds, compareFindings, explain, limitFindings, } from "./engine.js";
|
|
16
16
|
export type { CheckProgress } from "./engine.js";
|
|
17
17
|
export { SLICE_MS } from "./checker.js";
|
|
18
|
+
export { describeStatus, guaranteeAt, proveGuarantees } from "./guarantees.js";
|
|
19
|
+
export type { GuaranteeProof, GuaranteeStatus } from "./guarantees.js";
|
|
18
20
|
export type { LongestStep, SliceOptions, SlicedCheck } from "./checker.js";
|
|
19
21
|
export { IGNORE_FIX_TITLE, IGNORE_RULE_ID, ignoreFix } from "./ignores.js";
|
|
20
22
|
export { CACHE_FORMAT, emptyCache, parseSnapshot, toSnapshot } from "./cache.js";
|
|
@@ -26,7 +28,7 @@ export type { PackageCacheClean, PackageCacheStats } from "./package-cache.js";
|
|
|
26
28
|
export { NothingToCheckError, TsconfigError, TypeScriptLibMissingError, missingDefaultLib, toTypeScriptPath, tsconfigDirectory, } from "./backend/typescript6.js";
|
|
27
29
|
export { createTimingRecorder } from "./timing.js";
|
|
28
30
|
export { cacheEntries, dropLeastRecentlyUsed, limitBytes, markUsed } from "./disk-limits.js";
|
|
29
|
-
export { CACHE_SUBDIR, RESULTS_CACHE_DEFAULT_MB, cleanResultsCache, defaultCacheDir, openDiskCache, resultsCacheLimit, resultsCacheStats, } from "./disk-cache.js";
|
|
31
|
+
export { CACHE_SUBDIR, PROJECT_CACHE_DIR, RESULTS_CACHE_DEFAULT_MB, cleanResultsCache, defaultCacheDir, userCacheDir, openDiskCache, resultsCacheLimit, resultsCacheStats, } from "./disk-cache.js";
|
|
30
32
|
export type { DiskCache, ResultsCacheStats } from "./disk-cache.js";
|
|
31
33
|
export type { CacheEntry } from "./disk-limits.js";
|
|
32
34
|
export type { RuleCost, RunTiming, TimingRecorder } from "./timing.js";
|
package/dist/internal.js
CHANGED
|
@@ -10,10 +10,11 @@ export { displayPath, slashed } from "./display-path.js";
|
|
|
10
10
|
export { matchingOverrides } from "./overrides.js";
|
|
11
11
|
export { ROLLOUT_FILE, RolloutError, readRollout, rolloutFile, writeRollout } from "./rollout.js";
|
|
12
12
|
export { BASELINE_FILE, BaselineError, OUTDATED_BASELINE, applyBaseline, baselineFile, baselineOf, fingerprintOf, isOutdated, mergeBaseline, readBaseline, sizeOf, writeBaseline, } from "./baseline.js";
|
|
13
|
-
export { advance, buildPlan, describeTurnOn } from "./plan.js";
|
|
13
|
+
export { advance, buildPlan, describeNotChecked, describeTurnOn, isClean } from "./plan.js";
|
|
14
14
|
export { findConfigFile, findConfigUpward, loadConfig, loadConfigFile, reloadsLocalImports, } from "./config-file.js";
|
|
15
|
-
export { MAX_FINDINGS_PER_RULE_PER_FILE, activeRuleIds, compareFindings, explain, limitFindings, } from "./engine.js";
|
|
15
|
+
export { LOOSE_NULLS_FIX, MAX_FINDINGS_PER_RULE_PER_FILE, STRICT_NULLS_REMEDY, activeRuleIds, compareFindings, explain, limitFindings, } from "./engine.js";
|
|
16
16
|
export { SLICE_MS } from "./checker.js";
|
|
17
|
+
export { describeStatus, guaranteeAt, proveGuarantees } from "./guarantees.js";
|
|
17
18
|
export { IGNORE_FIX_TITLE, IGNORE_RULE_ID, ignoreFix } from "./ignores.js";
|
|
18
19
|
export { CACHE_FORMAT, emptyCache, parseSnapshot, toSnapshot } from "./cache.js";
|
|
19
20
|
export { stronglyConnectedComponents } from "./graph.js";
|
|
@@ -22,5 +23,5 @@ export { PACKAGE_CACHE_DEFAULT_MB, PACKAGE_CACHE_MARKER, cleanPackageCache, pack
|
|
|
22
23
|
export { NothingToCheckError, TsconfigError, TypeScriptLibMissingError, missingDefaultLib, toTypeScriptPath, tsconfigDirectory, } from "./backend/typescript6.js";
|
|
23
24
|
export { createTimingRecorder } from "./timing.js";
|
|
24
25
|
export { cacheEntries, dropLeastRecentlyUsed, limitBytes, markUsed } from "./disk-limits.js";
|
|
25
|
-
export { CACHE_SUBDIR, RESULTS_CACHE_DEFAULT_MB, cleanResultsCache, defaultCacheDir, openDiskCache, resultsCacheLimit, resultsCacheStats, } from "./disk-cache.js";
|
|
26
|
+
export { CACHE_SUBDIR, PROJECT_CACHE_DIR, RESULTS_CACHE_DEFAULT_MB, cleanResultsCache, defaultCacheDir, userCacheDir, openDiskCache, resultsCacheLimit, resultsCacheStats, } from "./disk-cache.js";
|
|
26
27
|
//# sourceMappingURL=internal.js.map
|
package/dist/plan.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export type PlanRow = {
|
|
|
17
17
|
* phrase after "silent: "; left out when it can.
|
|
18
18
|
*/
|
|
19
19
|
silent?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Why the rule could not run in this project (`CheckResult.notes`: its library's types do not
|
|
22
|
+
* resolve), so its count of findings says nothing: it is never "clean". Left out when it ran.
|
|
23
|
+
*/
|
|
24
|
+
notChecked?: string;
|
|
20
25
|
};
|
|
21
26
|
export type Plan = {
|
|
22
27
|
rules: readonly PlanRow[];
|
|
@@ -46,11 +51,23 @@ export type Advance =
|
|
|
46
51
|
| {
|
|
47
52
|
kind: "blocked";
|
|
48
53
|
row: PlanRow;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Every rule not on yet could not run here (`PlanRow.notChecked`): nothing is turned on until
|
|
57
|
+
* they can, since "nothing to fix" would not be known.
|
|
58
|
+
*/
|
|
59
|
+
| {
|
|
60
|
+
kind: "not-checked";
|
|
61
|
+
rows: readonly PlanRow[];
|
|
49
62
|
} | {
|
|
50
63
|
kind: "all-on";
|
|
51
64
|
};
|
|
65
|
+
/** Whether a row has nothing to fix as far as anyone knows: no finding, and the rule ran. */
|
|
66
|
+
export declare function isClean(row: PlanRow): boolean;
|
|
52
67
|
/** The next step from the rules turned on so far (in the order they were turned on). */
|
|
53
68
|
export declare function advance(plan: Plan, enabled: readonly string[], anyway: boolean): Advance;
|
|
69
|
+
/** What `next` says when only rules that could not run are left, in one line. */
|
|
70
|
+
export declare function describeNotChecked(rows: readonly PlanRow[]): string;
|
|
54
71
|
/**
|
|
55
72
|
* The lines `stateward next` and the editor's "Turn on the next rule" tell the developer after a
|
|
56
73
|
* `turn-on` step: the clean rules that came along, the rule now on with what it protects, and
|