@stateward/core 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyses.d.ts +37 -0
- package/dist/analyses.js +57 -0
- package/dist/backend/program-record.d.ts +7 -0
- package/dist/backend/typescript6.d.ts +33 -32
- package/dist/backend/typescript6.js +1438 -139
- package/dist/baseline.d.ts +1 -1
- package/dist/baseline.js +14 -10
- package/dist/cache.d.ts +74 -4
- package/dist/cache.js +211 -37
- package/dist/checker.d.ts +6 -1
- package/dist/checker.js +10 -0
- 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 +2 -0
- package/dist/disk-cache.js +77 -11
- package/dist/engine.d.ts +33 -1
- package/dist/engine.js +344 -24
- 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 +8 -9
- package/dist/index.js +10 -7
- package/dist/internal.d.ts +7 -4
- package/dist/internal.js +5 -3
- 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/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 +8 -0
- package/dist/timing.js +35 -1
- package/dist/types.d.ts +692 -19
- 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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Plugin, PluginAnalysis } from "./types.js";
|
|
2
|
+
/** An analysis's name: kebab-case, like a rule's key (`throws`). */
|
|
3
|
+
export declare const ANALYSIS_NAME: RegExp;
|
|
4
|
+
/**
|
|
5
|
+
* What is wrong with a project rule's `reads`, as the end of a message, or undefined when it is
|
|
6
|
+
* absent or a list of analysis ids.
|
|
7
|
+
*/
|
|
8
|
+
export declare function readsProblem(value: unknown): string | undefined;
|
|
9
|
+
/** Where a read id leads: the analysis, or why the rule cannot have it. */
|
|
10
|
+
export type ReadTarget = {
|
|
11
|
+
readonly kind: "found";
|
|
12
|
+
readonly plugin: string;
|
|
13
|
+
readonly analysis: PluginAnalysis;
|
|
14
|
+
}
|
|
15
|
+
/** The publisher is not in the config's plugins. */
|
|
16
|
+
| {
|
|
17
|
+
readonly kind: "no-plugin";
|
|
18
|
+
readonly plugin: string;
|
|
19
|
+
}
|
|
20
|
+
/** The publisher is there but publishes no analysis by that name (an older version of it). */
|
|
21
|
+
| {
|
|
22
|
+
readonly kind: "no-analysis";
|
|
23
|
+
readonly plugin: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
};
|
|
26
|
+
/** Finds the analysis `id` names among the config's plugins. */
|
|
27
|
+
export declare function readTarget(plugins: readonly Plugin[], id: string): ReadTarget;
|
|
28
|
+
/** A rule that reads an analysis the config cannot give it: the "not checked" finding's text. */
|
|
29
|
+
export declare function missingAnalysis(ruleId: string, id: string, target: Exclude<ReadTarget, {
|
|
30
|
+
kind: "found";
|
|
31
|
+
}>): {
|
|
32
|
+
message: string;
|
|
33
|
+
hint: string;
|
|
34
|
+
};
|
|
35
|
+
/** The config error for a rule that reads an analysis its loaded publisher does not publish. */
|
|
36
|
+
export declare function unpublishedRead(plugin: string, key: string, id: string, publisher: string): string;
|
|
37
|
+
//# sourceMappingURL=analyses.d.ts.map
|
package/dist/analyses.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Analyses a pack publishes for the project rules of any pack: the names a
|
|
3
|
+
* plugin may give one, the ids a rule reads one by, and where a read id leads in the config.
|
|
4
|
+
*/
|
|
5
|
+
/** An analysis's name: kebab-case, like a rule's key (`throws`). */
|
|
6
|
+
export const ANALYSIS_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
7
|
+
/** An analysis's id as a rule reads it: `"<plugin>/<name>"` (`errors/throws`). */
|
|
8
|
+
const ANALYSIS_ID = /^[^/\s]+\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
9
|
+
/**
|
|
10
|
+
* What is wrong with a project rule's `reads`, as the end of a message, or undefined when it is
|
|
11
|
+
* absent or a list of analysis ids.
|
|
12
|
+
*/
|
|
13
|
+
export function readsProblem(value) {
|
|
14
|
+
if (value === undefined)
|
|
15
|
+
return undefined;
|
|
16
|
+
if (!Array.isArray(value)) {
|
|
17
|
+
return `reads must be a list of analysis ids, like ["errors/throws"]`;
|
|
18
|
+
}
|
|
19
|
+
for (const item of value) {
|
|
20
|
+
if (typeof item !== "string" || !ANALYSIS_ID.test(item)) {
|
|
21
|
+
return `reads: ${JSON.stringify(item)} is not an analysis id "<plugin>/<name>", like "errors/throws"`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
/** Finds the analysis `id` names among the config's plugins. */
|
|
27
|
+
export function readTarget(plugins, id) {
|
|
28
|
+
const slash = id.indexOf("/");
|
|
29
|
+
const pluginName = id.slice(0, slash);
|
|
30
|
+
const name = id.slice(slash + 1);
|
|
31
|
+
const plugin = plugins.find((one) => one.name === pluginName);
|
|
32
|
+
if (plugin === undefined)
|
|
33
|
+
return { kind: "no-plugin", plugin: pluginName };
|
|
34
|
+
const analyses = plugin.analyses;
|
|
35
|
+
const analysis = analyses !== undefined && Object.hasOwn(analyses, name) ? analyses[name] : undefined;
|
|
36
|
+
return analysis === undefined
|
|
37
|
+
? { kind: "no-analysis", plugin: pluginName, name }
|
|
38
|
+
: { kind: "found", plugin: pluginName, analysis };
|
|
39
|
+
}
|
|
40
|
+
/** A rule that reads an analysis the config cannot give it: the "not checked" finding's text. */
|
|
41
|
+
export function missingAnalysis(ruleId, id, target) {
|
|
42
|
+
if (target.kind === "no-plugin") {
|
|
43
|
+
return {
|
|
44
|
+
message: `not checked: \`${ruleId}\` reads \`${id}\`, and the \`${target.plugin}\` pack is not in \`plugins\``,
|
|
45
|
+
hint: `add \`${target.plugin}()\` to \`plugins\``,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
message: `not checked: \`${ruleId}\` reads \`${id}\`, which the \`${target.plugin}\` pack in \`plugins\` does not publish`,
|
|
50
|
+
hint: `update the \`${target.plugin}\` pack to a version that publishes \`${target.name}\``,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** The config error for a rule that reads an analysis its loaded publisher does not publish. */
|
|
54
|
+
export function unpublishedRead(plugin, key, id, publisher) {
|
|
55
|
+
return `plugin "${plugin}": rule "${key}" reads "${id}", which plugin "${publisher}" does not publish`;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=analyses.js.map
|
|
@@ -29,6 +29,13 @@ export type ProgramRecord = {
|
|
|
29
29
|
* filled while the run that built the program asks for them.
|
|
30
30
|
*/
|
|
31
31
|
readonly reads: Record<string, string>;
|
|
32
|
+
/** The package modules the own files import (`importedModules`), sorted. */
|
|
33
|
+
readonly imports: readonly string[];
|
|
34
|
+
/**
|
|
35
|
+
* What the config's `facts` keys resolve to in the program (`ProjectUnit.factKeys`), as JSON,
|
|
36
|
+
* by a digest of the facts: filled while the run that asks for them has the program.
|
|
37
|
+
*/
|
|
38
|
+
readonly facts: Record<string, string>;
|
|
32
39
|
};
|
|
33
40
|
export declare function isQueryKind(value: unknown): value is QueryKind;
|
|
34
41
|
/** Everything else a program depends on: its inputs, TypeScript's version and lib folder, the process folder. */
|
|
@@ -2,7 +2,8 @@ import ts from "typescript";
|
|
|
2
2
|
import type { ResultCache } from "../cache.js";
|
|
3
3
|
import type { MarkedComment } from "./comments.js";
|
|
4
4
|
import type { DependenciesOf, IsPackageEntry, PackageOf } from "./fingerprints.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { FactKeyCheck } from "../package-facts.js";
|
|
6
|
+
import type { Config, FixForm, FixVerdict, PackageFactsConfig, TextEdit, TypeQueries } from "../types.js";
|
|
6
7
|
/** The tsconfig could not be read or is invalid. */
|
|
7
8
|
export declare class TsconfigError extends Error {
|
|
8
9
|
/** The one change that fixes it, shown on a `= fix:` line. */
|
|
@@ -81,11 +82,24 @@ export type ProjectUnit = {
|
|
|
81
82
|
* TypeScript 6's default, on). Read from the tsconfig: no program is built for it.
|
|
82
83
|
*/
|
|
83
84
|
readonly strictNullChecks: boolean;
|
|
85
|
+
/** The test-runner configs, absolute, whose test files could not be read (`test-runner.ts`). */
|
|
86
|
+
readonly unreadTestConfigs: readonly string[];
|
|
84
87
|
/**
|
|
85
88
|
* Whether `module` resolves to declarations (types) from the project's folder, by its options:
|
|
86
89
|
* `react` does when `@types/react` or a typed `react` is installed. No program is built for it.
|
|
87
90
|
*/
|
|
88
91
|
typesResolve(module: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* What each key of the config's `facts` resolves to in this program (`checkFactKeys`). A
|
|
94
|
+
* project whose program a run proved unchanged answers from its record when the facts are the
|
|
95
|
+
* same; otherwise the program is built.
|
|
96
|
+
*/
|
|
97
|
+
factKeys(facts: PackageFactsConfig): readonly FactKeyCheck[];
|
|
98
|
+
/**
|
|
99
|
+
* Whether an own file imports `module` or one of its subpaths (`importedModules`): a rule that
|
|
100
|
+
* reads a library by its types has nothing to say when no file uses the library.
|
|
101
|
+
*/
|
|
102
|
+
importsModule(module: string): boolean;
|
|
89
103
|
/**
|
|
90
104
|
* Binds the program (creating its type checker), which gives every node its parent: call it
|
|
91
105
|
* before a rule or a plugin sees a node of `files`. Parsing does not set parents.
|
|
@@ -133,6 +147,15 @@ export type UnresolvedImport = {
|
|
|
133
147
|
readonly start: number;
|
|
134
148
|
readonly end: number;
|
|
135
149
|
};
|
|
150
|
+
/**
|
|
151
|
+
* The package modules one file imports, as TypeScript reads its imports (not its text): import
|
|
152
|
+
* and export declarations, `import x = require(…)`, `import(…)`, `require(…)`, `import("…")`
|
|
153
|
+
* types, and the JSX runtime a file with JSX uses by the project's `jsx` option. Relative and
|
|
154
|
+
* absolute paths are left out: they name the project's own files.
|
|
155
|
+
*/
|
|
156
|
+
export declare function importedModules(sourceFile: ts.SourceFile, options: ts.CompilerOptions): string[];
|
|
157
|
+
/** Whether `imported` (as `importedModules` gives them) names `module` or one of its subpaths. */
|
|
158
|
+
export declare function importsModuleIn(imported: readonly string[], module: string): boolean;
|
|
136
159
|
/** Whether a project with these options checks with `strictNullChecks` (TypeScript 6: on unless turned off). */
|
|
137
160
|
export declare function checksNulls(options: ts.CompilerOptions): boolean;
|
|
138
161
|
export type Backend = {
|
|
@@ -169,20 +192,21 @@ export declare function hostWithOverlays(options: ts.CompilerOptions, overlays:
|
|
|
169
192
|
/** Serve a file that is not in `overlays` from `cache` without reading it from disk. */
|
|
170
193
|
trustCache?: boolean,
|
|
171
194
|
/** Parse the JSDoc of TypeScript files too: a rule that is on reads it (`RuleMeta.needsJsDoc`). */
|
|
172
|
-
jsDoc?: boolean
|
|
173
|
-
/**
|
|
174
|
-
* The files kept in the process-wide `libraryCache` rather than in `cache`. A package's own
|
|
175
|
-
* JavaScript (`openPackageSource`) goes in `cache`, so it is freed with the package's program:
|
|
176
|
-
* kept for the process, the packages a first run reads held over 500 MB on a large app.
|
|
177
|
-
*/
|
|
178
|
-
shared?: (fileName: string) => boolean): ts.CompilerHost;
|
|
195
|
+
jsDoc?: boolean): ts.CompilerHost;
|
|
179
196
|
/** A file's name in qualified ids: relative to the project, with forward slashes. */
|
|
180
197
|
export declare function idFileNames(root: string): (fileName: string) => string;
|
|
181
198
|
/** The type questions the flow scan asks in one file before it stops (`TypeQueries.typedFlowsIn`). */
|
|
182
199
|
export declare const FLOW_BUDGET = 200000;
|
|
200
|
+
/**
|
|
201
|
+
* The platform's packages every project has: Node's types. TypeScript's own lib is the platform
|
|
202
|
+
* too; the config's `platform` adds more (`bun-types`, `@cloudflare/workers-types`).
|
|
203
|
+
*/
|
|
204
|
+
export declare const PLATFORM_PACKAGES: readonly string[];
|
|
183
205
|
export declare function createTypeQueries(program: ts.Program, own: ReadonlySet<string>,
|
|
184
206
|
/** The project folder qualified ids are relative to. */
|
|
185
|
-
root: string, packageOf: PackageOf, isEntry: IsPackageEntry, dependenciesOf: DependenciesOf
|
|
207
|
+
root: string, packageOf: PackageOf, isEntry: IsPackageEntry, dependenciesOf: DependenciesOf,
|
|
208
|
+
/** Packages the config adds to the platform (`Config.platform`). */
|
|
209
|
+
platform?: readonly string[]): TypeQueries;
|
|
186
210
|
/**
|
|
187
211
|
* Builds one TypeScript program per project of the config's tsconfig (see `collectConfigs`) and
|
|
188
212
|
* serves the unsaved overlays. Later `open` calls reuse the previous programs.
|
|
@@ -195,28 +219,5 @@ export declare function createBackend({ config, cwd, cache, jsDoc, }: {
|
|
|
195
219
|
/** Parse the JSDoc of TypeScript files (`hostWithOverlays`). */
|
|
196
220
|
jsDoc?: boolean;
|
|
197
221
|
}): Backend;
|
|
198
|
-
/**
|
|
199
|
-
* A package's own JavaScript, read as the project's own code is (the fourth source of library facts): a small program over the files one entry reaches by relative imports and requires, never
|
|
200
|
-
* into other packages, with TypeScript's ES2022 library for the platform's globals. Plugins
|
|
201
|
-
* summarize its files with the same code as the project's, through these `TypeQueries`.
|
|
202
|
-
*/
|
|
203
|
-
export type PackageSource = {
|
|
204
|
-
/** The package's files the program loaded, absolute, sorted: the entry and what it reaches. */
|
|
205
|
-
readonly files: readonly string[];
|
|
206
|
-
sourceFile(file: string): ts.SourceFile | undefined;
|
|
207
|
-
/** Own files are the package's loaded files; qualified ids are relative to the package root. */
|
|
208
|
-
readonly types: TypeQueries;
|
|
209
|
-
/**
|
|
210
|
-
* The declaration a module exports under `path` (`["remote"]`, `["Client", "get"]`): an ES
|
|
211
|
-
* export, a CommonJS `exports.x = …` or `module.exports = { x }`, or `module.exports = fn` for
|
|
212
|
-
* `["default"]` or its own name. Undefined when the module does not export it.
|
|
213
|
-
*/
|
|
214
|
-
exported(file: string, path: readonly string[]): SymbolRef | undefined;
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Opens the package at `root` from `entry` (a JavaScript file in it). Its files are parsed with
|
|
218
|
-
* the library files' cache, so a later package or project shares TypeScript's lib files.
|
|
219
|
-
*/
|
|
220
|
-
export declare function openPackageSource(root: string, entry: string): PackageSource;
|
|
221
222
|
export {};
|
|
222
223
|
//# sourceMappingURL=typescript6.d.ts.map
|