@stateward/core 1.0.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/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 +223 -22
- package/dist/cache.d.ts +5 -4
- package/dist/cache.js +2 -2
- package/dist/checker.d.ts +14 -2
- package/dist/checker.js +27 -5
- 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 +25 -3
- package/dist/engine.js +186 -50
- package/dist/guarantees.d.ts +41 -0
- package/dist/guarantees.js +68 -0
- package/dist/ignores.d.ts +2 -4
- package/dist/ignores.js +11 -15
- 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/ignores.d.ts
CHANGED
|
@@ -44,8 +44,6 @@ export declare function fileDirectives(unit: ProjectUnit, file: string, results:
|
|
|
44
44
|
directives: readonly IgnoreDirective[];
|
|
45
45
|
stored: boolean;
|
|
46
46
|
};
|
|
47
|
-
/** The ignore comments of one file, read now (the fast pass has no cache to keep them in). */
|
|
48
|
-
export declare function readFileDirectives(unit: ProjectUnit, file: string): readonly IgnoreDirective[];
|
|
49
47
|
/** The ids a comment may name, and the ones whose rule ran, for "nothing to ignore" to be a fair judgement. */
|
|
50
48
|
export type IgnoreScope = {
|
|
51
49
|
/** Every rule id of the config's plugins, and the ids stateward reports itself. */
|
|
@@ -65,8 +63,8 @@ export declare function applyIgnores(findings: readonly Finding[], directives: R
|
|
|
65
63
|
ignored: IgnoredFinding[];
|
|
66
64
|
};
|
|
67
65
|
/** The page `stateward explain stateward/ignore` shows. */
|
|
68
|
-
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 \"
|
|
69
|
-
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";
|
|
70
68
|
/**
|
|
71
69
|
* "Ignore this case here": `// stateward-ignore <rule>: ` on the line above the finding, indented
|
|
72
70
|
* like it, so the warning about the missing reason asks for the reason at once. Undefined for a
|
package/dist/ignores.js
CHANGED
|
@@ -233,10 +233,6 @@ export function fileDirectives(unit, file, results) {
|
|
|
233
233
|
results.set(COMMENTS_KEY, { findings: [], summary: summaryOf(directives) });
|
|
234
234
|
return { directives, stored: true };
|
|
235
235
|
}
|
|
236
|
-
/** The ignore comments of one file, read now (the fast pass has no cache to keep them in). */
|
|
237
|
-
export function readFileDirectives(unit, file) {
|
|
238
|
-
return readDirectives(unit, file);
|
|
239
|
-
}
|
|
240
236
|
function distance(a, b) {
|
|
241
237
|
let previous = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
242
238
|
for (let i = 1; i <= a.length; i++) {
|
|
@@ -298,7 +294,7 @@ function judge(file, directive, used, scope) {
|
|
|
298
294
|
const form = directive.file ? "stateward-ignore-file" : "stateward-ignore";
|
|
299
295
|
if (directive.rules.length === 0) {
|
|
300
296
|
return [
|
|
301
|
-
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>\``, []),
|
|
302
298
|
];
|
|
303
299
|
}
|
|
304
300
|
if (directive.file && !directive.placed) {
|
|
@@ -314,9 +310,9 @@ function judge(file, directive, used, scope) {
|
|
|
314
310
|
}
|
|
315
311
|
else if (!scope.known.has(rule.id)) {
|
|
316
312
|
const guess = closest(rule.id, scope.known);
|
|
317
|
-
found.push(commentFinding(file, rule, "error", fits(`\`${rule.id}\` is not a stateward rule`, MAX_HEADLINE, "
|
|
318
|
-
? "write a rule id as a finding shows it, such as `records/lookup-misses-key`;
|
|
319
|
-
: `
|
|
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
|
|
320
316
|
? []
|
|
321
317
|
: [
|
|
322
318
|
{
|
|
@@ -332,11 +328,11 @@ function judge(file, directive, used, scope) {
|
|
|
332
328
|
if (unused.length > 0 && scope.options.reportUnused !== "off") {
|
|
333
329
|
const everything = unused.length === directive.rules.length;
|
|
334
330
|
const keep = directive.rules.map((rule) => rule.id).filter((id) => !unused.includes(id));
|
|
335
|
-
const where = directive.file ? "in
|
|
336
|
-
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", [
|
|
337
333
|
everything
|
|
338
334
|
? {
|
|
339
|
-
title: "Remove
|
|
335
|
+
title: "Remove the ignore comment",
|
|
340
336
|
safe: true,
|
|
341
337
|
edits: [
|
|
342
338
|
{
|
|
@@ -346,7 +342,7 @@ function judge(file, directive, used, scope) {
|
|
|
346
342
|
],
|
|
347
343
|
}
|
|
348
344
|
: {
|
|
349
|
-
title: `Remove ${names(unused)} from
|
|
345
|
+
title: `Remove ${names(unused)} from the ignore comment`,
|
|
350
346
|
safe: true,
|
|
351
347
|
edits: [{ location: { file, ...here }, newText: rebuilt(directive, keep) }],
|
|
352
348
|
},
|
|
@@ -354,7 +350,7 @@ function judge(file, directive, used, scope) {
|
|
|
354
350
|
}
|
|
355
351
|
if (directive.reason === "" && scope.options.requireReason) {
|
|
356
352
|
const first = directive.rules[0]?.id ?? "<rule>";
|
|
357
|
-
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"), []));
|
|
358
354
|
}
|
|
359
355
|
return found;
|
|
360
356
|
}
|
|
@@ -424,7 +420,7 @@ Put a comment on the line above a finding that is intended, with the rule and th
|
|
|
424
420
|
|
|
425
421
|
Several rules go in one comment, separated by commas. For a whole file, put
|
|
426
422
|
\`// stateward-ignore-file <rule>: <reason>\` above its first statement. Comment lines between the
|
|
427
|
-
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.
|
|
428
424
|
|
|
429
425
|
## What it catches
|
|
430
426
|
|
|
@@ -443,7 +439,7 @@ later", a comment says "this is intended". Both stay. Findings of this rule cann
|
|
|
443
439
|
It is always on. \`stateward check --no-ignores\` shows the findings that comments cover, and the
|
|
444
440
|
summary counts them ("2 ignored in the code"). Fix a comment, or remove it, to clear its finding.
|
|
445
441
|
`;
|
|
446
|
-
export const IGNORE_FIX_TITLE = "
|
|
442
|
+
export const IGNORE_FIX_TITLE = "Add an ignore comment";
|
|
447
443
|
/**
|
|
448
444
|
* "Ignore this case here": `// stateward-ignore <rule>: ` on the line above the finding, indented
|
|
449
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
|
package/dist/plan.js
CHANGED
|
@@ -36,6 +36,11 @@ silent = new Map()) {
|
|
|
36
36
|
}
|
|
37
37
|
for (const entry of result.hidden)
|
|
38
38
|
bump(findings, entry.ruleId, entry.count);
|
|
39
|
+
const notChecked = new Map();
|
|
40
|
+
for (const missing of result.notes?.missingTypes ?? []) {
|
|
41
|
+
for (const ruleId of missing.rules)
|
|
42
|
+
notChecked.set(ruleId, missing.reason);
|
|
43
|
+
}
|
|
39
44
|
const candidates = config.plugins.flatMap((plugin, packIndex) => Object.entries(plugin.rules).flatMap(([key, rule]) => {
|
|
40
45
|
if (!ruleIsOn(config, plugin.name, key, rule.meta))
|
|
41
46
|
return [];
|
|
@@ -63,9 +68,16 @@ silent = new Map()) {
|
|
|
63
68
|
fixable: candidate.fixable,
|
|
64
69
|
protects: candidate.protects,
|
|
65
70
|
...(silent.has(candidate.ruleId) ? { silent: silent.get(candidate.ruleId) ?? "" } : {}),
|
|
71
|
+
...(notChecked.has(candidate.ruleId)
|
|
72
|
+
? { notChecked: notChecked.get(candidate.ruleId) ?? "" }
|
|
73
|
+
: {}),
|
|
66
74
|
})),
|
|
67
75
|
};
|
|
68
76
|
}
|
|
77
|
+
/** Whether a row has nothing to fix as far as anyone knows: no finding, and the rule ran. */
|
|
78
|
+
export function isClean(row) {
|
|
79
|
+
return row.findings === 0 && row.notChecked === undefined;
|
|
80
|
+
}
|
|
69
81
|
/** The next step from the rules turned on so far (in the order they were turned on). */
|
|
70
82
|
export function advance(plan, enabled, anyway) {
|
|
71
83
|
const off = plan.rules.filter((row) => !enabled.includes(row.ruleId));
|
|
@@ -75,15 +87,20 @@ export function advance(plan, enabled, anyway) {
|
|
|
75
87
|
const last = plan.rules.find((row) => row.ruleId === lastId);
|
|
76
88
|
if (!anyway && last !== undefined && last.findings > 0)
|
|
77
89
|
return { kind: "blocked", row: last };
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
};
|
|
90
|
+
const row = off.find((candidate) => candidate.findings > 0);
|
|
91
|
+
const clean = off.filter(isClean);
|
|
92
|
+
if (row === undefined && clean.length === 0)
|
|
93
|
+
return { kind: "not-checked", rows: off };
|
|
94
|
+
return { kind: "turn-on", row, clean };
|
|
83
95
|
}
|
|
84
96
|
function countOf(count, noun) {
|
|
85
97
|
return `${String(count)} ${noun}${count === 1 ? "" : "s"}`;
|
|
86
98
|
}
|
|
99
|
+
/** What `next` says when only rules that could not run are left, in one line. */
|
|
100
|
+
export function describeNotChecked(rows) {
|
|
101
|
+
const reasons = [...new Set(rows.map((row) => row.notChecked ?? ""))].join("; ");
|
|
102
|
+
return `the ${countOf(rows.length, "rule")} left could not run here: ${reasons}; then run \`stateward next\` again`;
|
|
103
|
+
}
|
|
87
104
|
/**
|
|
88
105
|
* The lines `stateward next` and the editor's "Turn on the next rule" tell the developer after a
|
|
89
106
|
* `turn-on` step: the clean rules that came along, the rule now on with what it protects, and
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The compiler's complaints about the project at `dir` (its tsconfig.json), as `tsc -p dir` prints them. */
|
|
2
|
+
export declare function typeErrors(dir: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* The type errors of each text, as `tsc` prints them with each text a file of its own
|
|
5
|
+
* ("a3.ts(1,2): error ..."); a text maps to "" when it compiles. The strict, NodeNext options of
|
|
6
|
+
* the old spawned check. Texts must be modules, or their top-level names would meet in one scope.
|
|
7
|
+
*/
|
|
8
|
+
export declare function typeErrorsOfTexts(texts: readonly string[]): ReadonlyMap<string, string>;
|
|
9
|
+
/** The type errors of one text (see `typeErrorsOfTexts`), "" when it compiles. */
|
|
10
|
+
export declare function typeErrorsOfText(text: string): string;
|
|
11
|
+
//# sourceMappingURL=testing-tsc.d.ts.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
/**
|
|
4
|
+
* What `tsc -p` prints for a project, computed in this process. A test that asks "does this code
|
|
5
|
+
* compile?" many times would otherwise spawn tsc for each question (seconds each, and a timeout
|
|
6
|
+
* when the machine is busy). Library files and the previous program of each option set are kept
|
|
7
|
+
* for the life of the module, so a later question costs only the files that changed. The text is
|
|
8
|
+
* the same as tsc's: same diagnostics, same order, same format, "" when the code compiles.
|
|
9
|
+
*/
|
|
10
|
+
const sourceFiles = new Map();
|
|
11
|
+
const lastPrograms = new Map();
|
|
12
|
+
function formatHostIn(directory) {
|
|
13
|
+
return {
|
|
14
|
+
getCurrentDirectory: () => directory,
|
|
15
|
+
getCanonicalFileName: (name) => name,
|
|
16
|
+
getNewLine: () => ts.sys.newLine,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** A compiler host over the disk plus `overlay` (virtual files), reusing unchanged source files. */
|
|
20
|
+
function hostFor(options, overlay, currentDirectory) {
|
|
21
|
+
const base = ts.createCompilerHost(options, true);
|
|
22
|
+
const read = (fileName) => overlay.get(path.resolve(fileName)) ?? base.readFile(fileName);
|
|
23
|
+
return {
|
|
24
|
+
...base,
|
|
25
|
+
getCurrentDirectory: () => currentDirectory,
|
|
26
|
+
fileExists: (fileName) => overlay.has(path.resolve(fileName)) || base.fileExists(fileName),
|
|
27
|
+
readFile: read,
|
|
28
|
+
getSourceFile: (fileName, languageVersionOrOptions) => {
|
|
29
|
+
const text = read(fileName);
|
|
30
|
+
if (text === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
const key = `${path.resolve(fileName)}\0${JSON.stringify(languageVersionOrOptions)}`;
|
|
33
|
+
const cached = sourceFiles.get(key);
|
|
34
|
+
if (cached?.text === text)
|
|
35
|
+
return cached.file;
|
|
36
|
+
const file = ts.createSourceFile(fileName, text, languageVersionOrOptions, true);
|
|
37
|
+
sourceFiles.set(key, { text, file });
|
|
38
|
+
return file;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function compile(rootNames, options, overlay, configErrors, currentDirectory, cacheKey) {
|
|
43
|
+
const program = ts.createProgram(rootNames, options, hostFor(options, overlay, currentDirectory), lastPrograms.get(cacheKey), configErrors);
|
|
44
|
+
lastPrograms.set(cacheKey, program);
|
|
45
|
+
return { program, configErrors };
|
|
46
|
+
}
|
|
47
|
+
/** The diagnostics `tsc` reports, in its order: syntax first, the rest only when syntax is clean. */
|
|
48
|
+
function diagnosticsOf({ program, configErrors }, only) {
|
|
49
|
+
const syntactic = [...configErrors, ...program.getSyntacticDiagnostics(only)];
|
|
50
|
+
const all = syntactic.length > 0
|
|
51
|
+
? syntactic
|
|
52
|
+
: [
|
|
53
|
+
...program.getOptionsDiagnostics(),
|
|
54
|
+
...program.getGlobalDiagnostics(),
|
|
55
|
+
...program.getSemanticDiagnostics(only),
|
|
56
|
+
];
|
|
57
|
+
return [...ts.sortAndDeduplicateDiagnostics(all)];
|
|
58
|
+
}
|
|
59
|
+
/** The compiler's complaints about the project at `dir` (its tsconfig.json), as `tsc -p dir` prints them. */
|
|
60
|
+
export function typeErrors(dir) {
|
|
61
|
+
const configPath = path.resolve(dir, "tsconfig.json");
|
|
62
|
+
const parsed = ts.getParsedCommandLineOfConfigFile(configPath, {}, {
|
|
63
|
+
...ts.sys,
|
|
64
|
+
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
65
|
+
throw new Error(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
if (parsed === undefined)
|
|
69
|
+
throw new Error(`cannot read ${configPath}`);
|
|
70
|
+
const compiled = compile(parsed.fileNames, parsed.options, new Map(), parsed.errors, ts.sys.getCurrentDirectory(), `project\0${JSON.stringify(parsed.options)}`);
|
|
71
|
+
const diagnostics = diagnosticsOf(compiled);
|
|
72
|
+
return diagnostics.length === 0
|
|
73
|
+
? ""
|
|
74
|
+
: ts.formatDiagnostics(diagnostics, formatHostIn(ts.sys.getCurrentDirectory()));
|
|
75
|
+
}
|
|
76
|
+
const TEXT_OPTIONS = {
|
|
77
|
+
strict: true,
|
|
78
|
+
module: ts.ModuleKind.NodeNext,
|
|
79
|
+
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
80
|
+
noEmit: true,
|
|
81
|
+
types: [],
|
|
82
|
+
};
|
|
83
|
+
/** Not a real folder: its files exist only as overlay text. */
|
|
84
|
+
const VIRTUAL_DIR = path.join(path.sep, "stateward-virtual-texts");
|
|
85
|
+
/**
|
|
86
|
+
* The type errors of each text, as `tsc` prints them with each text a file of its own
|
|
87
|
+
* ("a3.ts(1,2): error ..."); a text maps to "" when it compiles. The strict, NodeNext options of
|
|
88
|
+
* the old spawned check. Texts must be modules, or their top-level names would meet in one scope.
|
|
89
|
+
*/
|
|
90
|
+
export function typeErrorsOfTexts(texts) {
|
|
91
|
+
return typeErrorsOfNamed(texts, (index) => `a${String(index)}.ts`);
|
|
92
|
+
}
|
|
93
|
+
function typeErrorsOfNamed(texts, nameOf) {
|
|
94
|
+
const unique = [...new Set(texts)];
|
|
95
|
+
const notModules = unique.filter((text) => !/^(?:import|export)\b/m.test(text));
|
|
96
|
+
if (notModules.length > 0) {
|
|
97
|
+
throw new Error("a text with no top-level import or export cannot be compiled with the others");
|
|
98
|
+
}
|
|
99
|
+
const names = unique.map((_, index) => nameOf(index));
|
|
100
|
+
const overlay = new Map(unique.map((text, index) => [path.join(VIRTUAL_DIR, names[index] ?? ""), text]));
|
|
101
|
+
const compiled = compile([...overlay.keys()], TEXT_OPTIONS, overlay, [], VIRTUAL_DIR, "texts");
|
|
102
|
+
const diagnostics = diagnosticsOf(compiled);
|
|
103
|
+
const perFile = new Map();
|
|
104
|
+
const unplaced = [];
|
|
105
|
+
for (const diagnostic of diagnostics) {
|
|
106
|
+
const name = diagnostic.file === undefined ? undefined : path.basename(diagnostic.file.fileName);
|
|
107
|
+
if (name === undefined)
|
|
108
|
+
unplaced.push(diagnostic);
|
|
109
|
+
else
|
|
110
|
+
perFile.set(name, [...(perFile.get(name) ?? []), diagnostic]);
|
|
111
|
+
}
|
|
112
|
+
const show = (list) => ts.formatDiagnostics(list, formatHostIn(VIRTUAL_DIR)).replace(/\r?\n$/, "");
|
|
113
|
+
const unplacedText = show(unplaced);
|
|
114
|
+
return new Map(unique.map((text, index) => [
|
|
115
|
+
text,
|
|
116
|
+
[show(perFile.get(names[index] ?? "") ?? []), unplacedText]
|
|
117
|
+
.filter((s) => s !== "")
|
|
118
|
+
.join("\n"),
|
|
119
|
+
]));
|
|
120
|
+
}
|
|
121
|
+
/** The type errors of one text (see `typeErrorsOfTexts`), "" when it compiles. */
|
|
122
|
+
export function typeErrorsOfText(text) {
|
|
123
|
+
return typeErrorsOfNamed([text], () => "a.ts").get(text) ?? "";
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=testing-tsc.js.map
|
package/dist/testing.d.ts
CHANGED
|
@@ -30,4 +30,5 @@ export declare class MessageStandardError extends Error {
|
|
|
30
30
|
}
|
|
31
31
|
/** Throws a `MessageStandardError` listing every violation in `findings`; use it in rule tests. */
|
|
32
32
|
export declare function expectMessageStandard(findings: readonly Finding[]): void;
|
|
33
|
+
export { typeErrors, typeErrorsOfText, typeErrorsOfTexts } from "./testing-tsc.js";
|
|
33
34
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.js
CHANGED
|
@@ -141,6 +141,18 @@ export function messageProblems(finding) {
|
|
|
141
141
|
problems.push('headline must not start with "You"');
|
|
142
142
|
if (prose.includes("!"))
|
|
143
143
|
problems.push('headline must not contain "!"');
|
|
144
|
+
// M15, M16, M19: a fact about the code, with no pointing words and no question; a place not
|
|
145
|
+
// checked says so first, never "stateward cannot tell".
|
|
146
|
+
const pointing = /\b(?:this|here|you)\b/i.exec(prose);
|
|
147
|
+
if (pointing !== null)
|
|
148
|
+
problems.push(`headline must not point with "${pointing[0]}"`);
|
|
149
|
+
if (prose.includes("?"))
|
|
150
|
+
problems.push("headline must not be a question");
|
|
151
|
+
if (/\bstateward cannot\b/i.test(prose))
|
|
152
|
+
problems.push('headline must not say "stateward cannot"');
|
|
153
|
+
if (finding.kind === "unknown" && !prose.startsWith("not checked: ")) {
|
|
154
|
+
problems.push('a place not checked must start with "not checked: "');
|
|
155
|
+
}
|
|
144
156
|
if (finding.kind === "problem") {
|
|
145
157
|
finding.related.forEach((related, index) => {
|
|
146
158
|
problems.push(...lineProblems(`related message ${String(index + 1)}`, related.message, undefined));
|
|
@@ -162,4 +174,5 @@ export function expectMessageStandard(findings) {
|
|
|
162
174
|
throw new MessageStandardError(`${String(violations.length)} message standard violation(s):\n${violations.join("\n")}`);
|
|
163
175
|
}
|
|
164
176
|
}
|
|
177
|
+
export { typeErrors, typeErrorsOfText, typeErrorsOfTexts } from "./testing-tsc.js";
|
|
165
178
|
//# sourceMappingURL=testing.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ export type TextEdit = {
|
|
|
24
24
|
*/
|
|
25
25
|
export type FixForm = {
|
|
26
26
|
title: string;
|
|
27
|
+
/**
|
|
28
|
+
* The edits, in any files. Edits at offset 0 of a file that does not exist create it (a helper
|
|
29
|
+
* file the fix writes once); the file's own errors then count against the fix.
|
|
30
|
+
*/
|
|
27
31
|
edits: readonly TextEdit[];
|
|
28
32
|
safe?: boolean;
|
|
29
33
|
/**
|
|
@@ -214,6 +218,11 @@ export type OptionsOf<S extends OptionSpecs> = {
|
|
|
214
218
|
*/
|
|
215
219
|
export type RuleInfo<S extends OptionSpecs = OptionSpecs, G extends string = string> = {
|
|
216
220
|
description: string;
|
|
221
|
+
/**
|
|
222
|
+
* What the rule finds, as a short phrase for the rules tables of the docs ("a `default` that
|
|
223
|
+
* hides cases of a union"); `description` is the sentence that opens the rule's page.
|
|
224
|
+
*/
|
|
225
|
+
summary?: string;
|
|
217
226
|
defaultSeverity: Severity;
|
|
218
227
|
tier: RuleTier;
|
|
219
228
|
/**
|
|
@@ -261,6 +270,25 @@ export type RuleInfo<S extends OptionSpecs = OptionSpecs, G extends string = str
|
|
|
261
270
|
* (`ctx.options` holds both). Only list options (`option.strings`) can be shared.
|
|
262
271
|
*/
|
|
263
272
|
sharedOptions?: Readonly<Record<string, string>>;
|
|
273
|
+
/**
|
|
274
|
+
* A library whose types the rule needs to see anything (`React` from `react`): where none of
|
|
275
|
+
* `modules` resolves to declarations from the project, the rule could not run there, and
|
|
276
|
+
* `check`, `plan` and `next` say so instead of calling it clean (never silent). Core only
|
|
277
|
+
* resolves the names; what they are is the pack's knowledge.
|
|
278
|
+
*/
|
|
279
|
+
needsTypes?: LibraryTypes;
|
|
280
|
+
/**
|
|
281
|
+
* The rule's fixes prove what they say only with `strictNullChecks` (a `Partial<…>` or a `??`
|
|
282
|
+
* TypeScript then checks): in a project without it, each finding's fix line says so.
|
|
283
|
+
*/
|
|
284
|
+
fixNeedsStrictNulls?: true;
|
|
285
|
+
};
|
|
286
|
+
/** A library a rule reads by its types: its name as people say it, and the modules that give them. */
|
|
287
|
+
export type LibraryTypes = {
|
|
288
|
+
/** As people say it: "React". */
|
|
289
|
+
readonly library: string;
|
|
290
|
+
/** The module names that bring its types, any one is enough: `["react"]`. */
|
|
291
|
+
readonly modules: readonly string[];
|
|
264
292
|
};
|
|
265
293
|
export type RuleMeta<S extends OptionSpecs = OptionSpecs, G extends string = string> = RuleInfo<S, G> & {
|
|
266
294
|
/** Markdown shown by `stateward explain`. */
|
|
@@ -297,6 +325,14 @@ export type NarrowedMembers = {
|
|
|
297
325
|
members: readonly string[];
|
|
298
326
|
removed: readonly string[];
|
|
299
327
|
};
|
|
328
|
+
/**
|
|
329
|
+
* Where a call's callee takes an abort signal: the index of the parameter, and `"signal"` when the
|
|
330
|
+
* signal is the `signal` property of an options object at that index (`fetch(url, { signal })`).
|
|
331
|
+
*/
|
|
332
|
+
export type SignalParameter = {
|
|
333
|
+
readonly index: number;
|
|
334
|
+
readonly property: "signal" | undefined;
|
|
335
|
+
};
|
|
300
336
|
/**
|
|
301
337
|
* `id` is the qualified id "<file relative to the project>#<path>" (`src/cart.ts#useCart.onAdd`;
|
|
302
338
|
* the module itself is "<file>#"): stable across runs and across edits that do not rename or move
|
|
@@ -393,6 +429,17 @@ export type TypeQueries = {
|
|
|
393
429
|
* recognised by where that symbol is declared.
|
|
394
430
|
*/
|
|
395
431
|
uniqueSymbolKeyFiles(node: ts.Node): readonly string[];
|
|
432
|
+
/**
|
|
433
|
+
* The guarantees a type states: the string literals of its optional `__guarantee` property
|
|
434
|
+
* (`Context<T> & { readonly __guarantee?: "required-context" }`), sorted. The type is the one
|
|
435
|
+
* of an expression or type node, or the declared type of a symbol (a variable's type, a type
|
|
436
|
+
* alias's type), resolved through aliases, generics and re-exports. A type parameter is widened
|
|
437
|
+
* to its constraint; `null` and `undefined` members are left out, and every other member of a
|
|
438
|
+
* union must state a guarantee for it to count. Empty for a type that states none, or whose
|
|
439
|
+
* `__guarantee` is required or not a string literal (that is a brand, not a guarantee). The
|
|
440
|
+
* names mean nothing to core; each plugin reads its own.
|
|
441
|
+
*/
|
|
442
|
+
guaranteesOf(target: ts.Node | SymbolRef): readonly string[];
|
|
396
443
|
/**
|
|
397
444
|
* The type alias a value's type is an instance of, found from its declaration: after awaiting a
|
|
398
445
|
* `Promise`, every member of the type must be written in the same alias (`Result<T, E>` and
|
|
@@ -588,6 +635,17 @@ export type TypeQueries = {
|
|
|
588
635
|
* The project's JSDoc is parsed only when a rule that is on sets `needsJsDoc`.
|
|
589
636
|
*/
|
|
590
637
|
calleeTags(call: ts.CallExpression): readonly string[];
|
|
638
|
+
/**
|
|
639
|
+
* Where the function a call resolves to takes an abort signal: the first parameter whose type
|
|
640
|
+
* (without `null` and `undefined`, a type parameter widened to its constraint) is a signal, or
|
|
641
|
+
* an object type with a writable `signal` property that is one (an options object; a `Request`,
|
|
642
|
+
* whose `signal` is readonly, is not). A signal is an object type with an
|
|
643
|
+
* `aborted` property of type `boolean`: the platform's `AbortSignal`, and a library's own
|
|
644
|
+
* (`GenericAbortSignal`). Read from the signature TypeScript picks for the call as written, so
|
|
645
|
+
* an optional parameter the call leaves out counts (`fetch(url)`). Undefined when no parameter
|
|
646
|
+
* takes one, the call does not resolve, or the parameter is a rest parameter.
|
|
647
|
+
*/
|
|
648
|
+
signalParameterOf(call: ts.CallExpression): SignalParameter | undefined;
|
|
591
649
|
};
|
|
592
650
|
export type ReportProblem = {
|
|
593
651
|
message: string;
|
|
@@ -641,6 +699,39 @@ export type LibraryUse = {
|
|
|
641
699
|
readonly unknown: readonly string[];
|
|
642
700
|
}[];
|
|
643
701
|
};
|
|
702
|
+
/** A place a stated guarantee covers: a reader of a required context, a writer of owned state. */
|
|
703
|
+
export type CoveredPlace = {
|
|
704
|
+
/** How the place is named in a list: `<Profile>`, `useTheme()`. */
|
|
705
|
+
readonly name: string;
|
|
706
|
+
readonly location: Location;
|
|
707
|
+
};
|
|
708
|
+
/**
|
|
709
|
+
* A guarantee stated in the project's code, as the plugin that proves it reads it
|
|
710
|
+
* (`EditorContributions.guarantees`): for `stateward guarantees` and the editor's hover and code
|
|
711
|
+
* lens. Whether it is proven is not said here: core counts the findings of `ruleId` that name the
|
|
712
|
+
* declaration (a related note at `location`), so the list and the check never disagree.
|
|
713
|
+
*/
|
|
714
|
+
export type StatedGuarantee = {
|
|
715
|
+
/** The guarantee's name, as `__guarantee` writes it: `required-context`. */
|
|
716
|
+
readonly guarantee: string;
|
|
717
|
+
/** The marker type as the declaration's type names it: `RequiredContext`. */
|
|
718
|
+
readonly marker: string;
|
|
719
|
+
/** The declaration that states it: `ThemeContext`. */
|
|
720
|
+
readonly name: string;
|
|
721
|
+
/**
|
|
722
|
+
* The declaration. Every error of `ruleId` about this guarantee has a related note here (the
|
|
723
|
+
* note that says where the guarantee is stated): that is how its errors are counted.
|
|
724
|
+
*/
|
|
725
|
+
readonly location: Location;
|
|
726
|
+
/** The rule that proves it. */
|
|
727
|
+
readonly ruleId: string;
|
|
728
|
+
/** What it promises, after "Guaranteed: ": "every reader is rendered under its Provider". */
|
|
729
|
+
readonly promise: string;
|
|
730
|
+
/** What `covered` holds, as a plural noun: "readers", "writers". */
|
|
731
|
+
readonly covers: string;
|
|
732
|
+
/** The places the proof covers, in file and offset order; empty when nothing uses it. */
|
|
733
|
+
readonly covered: readonly CoveredPlace[];
|
|
734
|
+
};
|
|
644
735
|
export type FileContext<O extends Options = Options> = {
|
|
645
736
|
readonly file: string;
|
|
646
737
|
/** The config's facts about packages (`facts`); `{}` when it gives none. */
|
|
@@ -745,6 +836,10 @@ export type EditorHint = {
|
|
|
745
836
|
export type EditorAction = {
|
|
746
837
|
title: string;
|
|
747
838
|
edits: readonly TextEdit[];
|
|
839
|
+
/** Other ways to write it, in order, as a fix's `alternatives`: the first that compiles is offered. */
|
|
840
|
+
alternatives?: readonly {
|
|
841
|
+
edits: readonly TextEdit[];
|
|
842
|
+
}[];
|
|
748
843
|
};
|
|
749
844
|
export type EditorContributions = {
|
|
750
845
|
/** Returns markdown. */
|
|
@@ -799,6 +894,14 @@ export type EditorContributions = {
|
|
|
799
894
|
libraryFacts?(input: {
|
|
800
895
|
projectSummaries(ruleId: string): ReadonlyMap<string, Json> | undefined;
|
|
801
896
|
}): readonly LibraryUse[];
|
|
897
|
+
/**
|
|
898
|
+
* The guarantees stated in the project that this plugin proves, from the last full check's
|
|
899
|
+
* summaries (as `hover`: no new type checking): `stateward guarantees`, and the editor's hover
|
|
900
|
+
* and code lens on a marked declaration. Each is listed even when nothing uses it.
|
|
901
|
+
*/
|
|
902
|
+
guarantees?(input: {
|
|
903
|
+
projectSummaries(ruleId: string): ReadonlyMap<string, Json> | undefined;
|
|
904
|
+
}): readonly StatedGuarantee[];
|
|
802
905
|
};
|
|
803
906
|
/** Rule ids are "<plugin name>/<rule key>". */
|
|
804
907
|
export type Plugin = {
|
|
@@ -1034,5 +1137,23 @@ export type CheckResult = {
|
|
|
1034
1137
|
files: number;
|
|
1035
1138
|
}[];
|
|
1036
1139
|
};
|
|
1140
|
+
/**
|
|
1141
|
+
* What the run could not check as a whole, said once (not part of the JSON contract yet).
|
|
1142
|
+
* `missingTypes`: rules that ran where their library's types do not resolve
|
|
1143
|
+
* (`RuleInfo.needsTypes`), by library, rule ids sorted. `looseNulls`: the tsconfigs, absolute,
|
|
1144
|
+
* whose projects check without `strictNullChecks`. Left out when there is nothing to say.
|
|
1145
|
+
*/
|
|
1146
|
+
notes?: CheckNotes;
|
|
1147
|
+
};
|
|
1148
|
+
export type CheckNotes = {
|
|
1149
|
+
readonly missingTypes: readonly MissingTypes[];
|
|
1150
|
+
readonly looseNulls: readonly string[];
|
|
1151
|
+
};
|
|
1152
|
+
/** Rules that could not run because a library's types do not resolve, and the reason in words. */
|
|
1153
|
+
export type MissingTypes = {
|
|
1154
|
+
readonly library: string;
|
|
1155
|
+
/** "React's types are not installed (install the app's dependencies)". */
|
|
1156
|
+
readonly reason: string;
|
|
1157
|
+
readonly rules: readonly string[];
|
|
1037
1158
|
};
|
|
1038
1159
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED