@stateward/core 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyses.d.ts +37 -0
- package/dist/analyses.js +57 -0
- package/dist/backend/program-record.d.ts +7 -0
- package/dist/backend/typescript6.d.ts +35 -32
- package/dist/backend/typescript6.js +3804 -163
- package/dist/baseline.d.ts +1 -1
- package/dist/baseline.js +14 -10
- package/dist/cache.d.ts +89 -5
- package/dist/cache.js +271 -40
- package/dist/checker.d.ts +11 -1
- package/dist/checker.js +32 -2
- package/dist/class-id.d.ts +34 -0
- package/dist/class-id.js +93 -0
- package/dist/code-text.d.ts +8 -0
- package/dist/code-text.js +66 -0
- package/dist/config-file.js +7 -5
- package/dist/config.d.ts +10 -2
- package/dist/config.js +541 -49
- package/dist/define.d.ts +8 -2
- package/dist/disk-cache.d.ts +2 -0
- package/dist/disk-cache.js +77 -11
- package/dist/engine.d.ts +51 -1
- package/dist/engine.js +517 -42
- package/dist/fact-lines.d.ts +31 -0
- package/dist/fact-lines.js +197 -0
- package/dist/facts-versions.d.ts +27 -0
- package/dist/facts-versions.js +99 -0
- package/dist/fixes.js +9 -4
- package/dist/guarantees.d.ts +63 -11
- package/dist/guarantees.js +151 -21
- package/dist/ignores.d.ts +11 -0
- package/dist/ignores.js +74 -27
- package/dist/implementation.d.ts +0 -6
- package/dist/implementation.js +0 -17
- package/dist/index.d.ts +10 -9
- package/dist/index.js +14 -7
- package/dist/internal.d.ts +9 -5
- package/dist/internal.js +6 -3
- package/dist/lazy.d.ts +8 -1
- package/dist/lazy.js +27 -2
- package/dist/ledger.d.ts +77 -0
- package/dist/ledger.js +423 -0
- package/dist/off-by-default.d.ts +13 -0
- package/dist/off-by-default.js +15 -0
- package/dist/options.d.ts +21 -5
- package/dist/options.js +22 -7
- package/dist/package-facts.d.ts +211 -17
- package/dist/package-facts.js +520 -38
- package/dist/plan.d.ts +1 -1
- package/dist/plan.js +7 -2
- package/dist/release.d.ts +12 -21
- package/dist/release.js +28 -38
- package/dist/renamed.d.ts +22 -3
- package/dist/renamed.js +50 -16
- package/dist/rollout.js +7 -4
- package/dist/safe-calls.d.ts +26 -0
- package/dist/safe-calls.js +345 -0
- package/dist/severity.d.ts +1 -1
- package/dist/severity.js +17 -3
- package/dist/stated.d.ts +37 -0
- package/dist/stated.js +123 -0
- package/dist/test-runner.d.ts +18 -0
- package/dist/test-runner.js +483 -0
- package/dist/testing-tsc.d.ts +16 -0
- package/dist/testing-tsc.js +86 -0
- package/dist/testing.d.ts +5 -4
- package/dist/testing.js +6 -6
- package/dist/timing.d.ts +15 -0
- package/dist/timing.js +41 -2
- package/dist/types.d.ts +1068 -16
- package/dist/unread.d.ts +90 -0
- package/dist/unread.js +405 -0
- package/dist/vocabulary.d.ts +1 -1
- package/dist/vocabulary.js +1 -1
- package/package.json +4 -2
package/dist/checker.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ResultCache } from "./cache.js";
|
|
2
2
|
import type { TimingRecorder } from "./timing.js";
|
|
3
3
|
import type { CheckProgress } from "./engine.js";
|
|
4
|
-
import type { CheckResult, Config, EditorAction, EditorHint, Finding, FixForm, FixReview, FixSetReview, LibraryUse, Location, StatedGuarantee, RuleSelection, TokenType } from "./types.js";
|
|
4
|
+
import type { CheckResult, Config, EditorAction, EditorHint, Finding, FixForm, FixReview, FixSetReview, LibraryUse, Location, StatedGuarantee, RuleSelection, TokenType, ReportOutput, ReportPlace } from "./types.js";
|
|
5
5
|
export type CheckInput = {
|
|
6
6
|
config: Config;
|
|
7
7
|
cwd: string;
|
|
@@ -107,6 +107,11 @@ export type Checker = {
|
|
|
107
107
|
* before a check. Pair them with that check's findings with `proveGuarantees`.
|
|
108
108
|
*/
|
|
109
109
|
guarantees(): readonly StatedGuarantee[];
|
|
110
|
+
/**
|
|
111
|
+
* Runs the report `report` of `plugin` (`Plugin.reports`) on the summaries of the last full
|
|
112
|
+
* check; undefined when that plugin has no such report.
|
|
113
|
+
*/
|
|
114
|
+
report(plugin: string, report: string, place: (location: Location) => ReportPlace): ReportOutput | undefined;
|
|
110
115
|
/**
|
|
111
116
|
* Tries each fix of `findings` on a copy of the code of the last run (fixes.ts) and returns the
|
|
112
117
|
* findings in the same order, each with only the fixes that compile. Verdicts are kept in the
|
|
@@ -124,6 +129,11 @@ export type Checker = {
|
|
|
124
129
|
* of that check has the file. `check --fix` edits this text, never a newer one on disk.
|
|
125
130
|
*/
|
|
126
131
|
analysedText(file: string): string | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Whether the config turns `ruleId` off for `file`, by the rule's setting or an `overrides`
|
|
134
|
+
* entry: the rule never looked at the guarantee's places there (`proveGuarantees`).
|
|
135
|
+
*/
|
|
136
|
+
ruleOffAt(ruleId: string, file: string): boolean;
|
|
127
137
|
};
|
|
128
138
|
/**
|
|
129
139
|
* Editor requests are answered from the programs of the last check. A plugin that throws
|
package/dist/checker.js
CHANGED
|
@@ -2,7 +2,9 @@ import { createBackend, toTypeScriptPath } from "./backend/typescript6.js";
|
|
|
2
2
|
import { emptyCache } from "./cache.js";
|
|
3
3
|
import { reviewFixes, verifyFixSet } from "./fixes.js";
|
|
4
4
|
import { legacyMarkerRewrite } from "./guarantee-markers.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ledgerGuarantees } from "./ledger.js";
|
|
6
|
+
import { unlistedGuarantees } from "./stated.js";
|
|
7
|
+
import { drain, filePhaseRun, needsJsDoc, projectPhaseSteps, projectRuleIds, ruleOffAtFn, runFileRules, silentReasons, } from "./engine.js";
|
|
6
8
|
/** The default slice: short against the editor's 200 ms budget, long against a pause's cost. */
|
|
7
9
|
export const SLICE_MS = 20;
|
|
8
10
|
function fileTotal(units) {
|
|
@@ -32,9 +34,16 @@ export function createChecker({ config, cwd, rules = { kind: "configured" }, cac
|
|
|
32
34
|
cache: cache === false ? undefined : cache,
|
|
33
35
|
jsDoc: needsJsDoc(config),
|
|
34
36
|
});
|
|
37
|
+
let offAt;
|
|
35
38
|
/** The units of the last run; indexed (and bound) on the first editor request. */
|
|
36
39
|
let lastUnits;
|
|
37
40
|
let known;
|
|
41
|
+
/** The declarations that state a guarantee, of the last full check's files. */
|
|
42
|
+
let stated = [];
|
|
43
|
+
/** The references of the last full check's ledger. */
|
|
44
|
+
let ledgerRefs = [];
|
|
45
|
+
/** The rule that proves each tag trait, in the last full check. */
|
|
46
|
+
let tagRules = {};
|
|
38
47
|
/** The project rules' summaries of the last full check. */
|
|
39
48
|
let summaries = new Map();
|
|
40
49
|
/** Where verdicts are kept when the checker keeps no cache. */
|
|
@@ -76,6 +85,9 @@ export function createChecker({ config, cwd, rules = { kind: "configured" }, cac
|
|
|
76
85
|
const kept = new Map();
|
|
77
86
|
const result = yield* projectPhaseSteps(config, phase, started, kept, cache === false ? undefined : cache, uncapped === undefined, timing);
|
|
78
87
|
summaries = kept;
|
|
88
|
+
stated = phase.stated;
|
|
89
|
+
ledgerRefs = result.ledger?.refs ?? [];
|
|
90
|
+
tagRules = result.ledger?.tagRules ?? {};
|
|
79
91
|
return result;
|
|
80
92
|
}
|
|
81
93
|
return { steps: steps(), abandon: () => filePhase?.abandon() };
|
|
@@ -147,9 +159,23 @@ export function createChecker({ config, cwd, rules = { kind: "configured" }, cac
|
|
|
147
159
|
}) ?? []);
|
|
148
160
|
},
|
|
149
161
|
guarantees() {
|
|
150
|
-
|
|
162
|
+
const listed = config.plugins.flatMap((plugin) => plugin.editor?.guarantees?.({
|
|
151
163
|
projectSummaries: (ruleId) => summaries.get(ruleId)?.(),
|
|
152
164
|
}) ?? []);
|
|
165
|
+
// A stated declaration no plugin lists still reads "not checked", never missing; so does a
|
|
166
|
+
// declaration the ledger has references to (a function stated by its return type).
|
|
167
|
+
const known = [...listed, ...unlistedGuarantees(stated, listed)];
|
|
168
|
+
return [...known, ...ledgerGuarantees(ledgerRefs, known, tagRules)];
|
|
169
|
+
},
|
|
170
|
+
report(pluginName, reportName, place) {
|
|
171
|
+
const plugin = config.plugins.find((one) => one.name === pluginName);
|
|
172
|
+
const reports = plugin?.reports;
|
|
173
|
+
if (reports === undefined || !Object.hasOwn(reports, reportName))
|
|
174
|
+
return undefined;
|
|
175
|
+
return reports[reportName]?.run({
|
|
176
|
+
projectSummaries: (ruleId) => summaries.get(ruleId)?.(),
|
|
177
|
+
place,
|
|
178
|
+
});
|
|
153
179
|
},
|
|
154
180
|
reviewFixes(findings) {
|
|
155
181
|
const units = (lastUnits ??= backend.open(new Map()));
|
|
@@ -158,6 +184,10 @@ export function createChecker({ config, cwd, rules = { kind: "configured" }, cac
|
|
|
158
184
|
verifyFixSet(forms) {
|
|
159
185
|
return verifyFixSet(forms, (lastUnits ??= backend.open(new Map())));
|
|
160
186
|
},
|
|
187
|
+
ruleOffAt(ruleId, file) {
|
|
188
|
+
offAt ??= ruleOffAtFn(config);
|
|
189
|
+
return offAt(ruleId, toTypeScriptPath(file));
|
|
190
|
+
},
|
|
161
191
|
analysedText(file) {
|
|
162
192
|
const name = toTypeScriptPath(file);
|
|
163
193
|
for (const unit of lastUnits ?? []) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a class is named across packs: by the language, never by a library. A class of the project
|
|
3
|
+
* is its declaration's symbol id; a class of the platform (TypeScript's lib, a global in a
|
|
4
|
+
* declaration file) is `builtin:<Name>`; a package's class is `package:<name>#<Class>`, the same
|
|
5
|
+
* from its types, its source and the config. The errors pack's `errors/throws` names classes so,
|
|
6
|
+
* and a pack that reads it names the classes in its own code with `classIdOf`.
|
|
7
|
+
*/
|
|
8
|
+
import ts from "typescript";
|
|
9
|
+
import type { TypeQueries } from "./types.js";
|
|
10
|
+
/** A declaration of the platform: TypeScript's lib, or a global in a declaration file. */
|
|
11
|
+
export declare function isPlatformDeclaration(node: ts.Node, file: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The package a file outside the project belongs to: by its node_modules folder, or, for a
|
|
14
|
+
* package linked from elsewhere (a workspace package, whose real path has no node_modules), by
|
|
15
|
+
* the name in its package.json.
|
|
16
|
+
*/
|
|
17
|
+
export declare function packageNameOf(types: Pick<TypeQueries, "packageOf">, file: string): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The package a declaration outside the project belongs to: the `declare module "x"` it sits in,
|
|
20
|
+
* by the name it is written with, else its file's package (`packageNameOf`); undefined when
|
|
21
|
+
* neither names one.
|
|
22
|
+
*/
|
|
23
|
+
export declare function declaredPackageOf(types: Pick<TypeQueries, "packageOf">, declaration: {
|
|
24
|
+
readonly file: string;
|
|
25
|
+
readonly node: ts.Node;
|
|
26
|
+
}): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The id of the class a name refers to (`X` in `throw new X()`, `ns.X`, `@Catch(X)`):
|
|
29
|
+
* `builtin:<Name>` for a class of the platform, `package:<name>#<Class>` for a package's class,
|
|
30
|
+
* the symbol id (`SymbolRef.id`) for a class of the project. Undefined when the name resolves to
|
|
31
|
+
* nothing, or to a declaration outside the project whose package is not known.
|
|
32
|
+
*/
|
|
33
|
+
export declare function classIdOf(types: TypeQueries, node: ts.Node): string | undefined;
|
|
34
|
+
//# sourceMappingURL=class-id.d.ts.map
|
package/dist/class-id.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a class is named across packs: by the language, never by a library. A class of the project
|
|
3
|
+
* is its declaration's symbol id; a class of the platform (TypeScript's lib, a global in a
|
|
4
|
+
* declaration file) is `builtin:<Name>`; a package's class is `package:<name>#<Class>`, the same
|
|
5
|
+
* from its types, its source and the config. The errors pack's `errors/throws` names classes so,
|
|
6
|
+
* and a pack that reads it names the classes in its own code with `classIdOf`.
|
|
7
|
+
*/
|
|
8
|
+
import ts from "typescript";
|
|
9
|
+
const TS_LIB = /\/typescript\/lib\/lib\.[^/]*\.d\.ts$/;
|
|
10
|
+
/** The outermost of nested module declarations (`declare global { namespace X { … } }`). */
|
|
11
|
+
function outermostModule(module) {
|
|
12
|
+
const outer = ts.findAncestor(module.parent, ts.isModuleDeclaration);
|
|
13
|
+
return outer === undefined ? module : outermostModule(outer);
|
|
14
|
+
}
|
|
15
|
+
/** A declaration of the platform: TypeScript's lib, or a global in a declaration file. */
|
|
16
|
+
export function isPlatformDeclaration(node, file) {
|
|
17
|
+
if (TS_LIB.test(file))
|
|
18
|
+
return true;
|
|
19
|
+
const sourceFile = node.getSourceFile();
|
|
20
|
+
if (!sourceFile.isDeclarationFile)
|
|
21
|
+
return false;
|
|
22
|
+
const module = ts.findAncestor(node.parent, ts.isModuleDeclaration);
|
|
23
|
+
const enclosing = module === undefined ? undefined : outermostModule(module);
|
|
24
|
+
// `declare module "x"` is a package; `declare global` is the platform; a namespace is what
|
|
25
|
+
// its file is.
|
|
26
|
+
if (enclosing !== undefined && ts.isStringLiteral(enclosing.name))
|
|
27
|
+
return false;
|
|
28
|
+
if (enclosing?.name.text === "global")
|
|
29
|
+
return true;
|
|
30
|
+
return !ts.isExternalModule(sourceFile);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* `axios`, `@tanstack/react-query`, `react` for `@types/react`, `@babel/core` for
|
|
34
|
+
* `@types/babel__core`: the package of a path inside a node_modules folder (either slash).
|
|
35
|
+
* Undefined for a path outside one.
|
|
36
|
+
*/
|
|
37
|
+
function packageNameIn(file) {
|
|
38
|
+
const normal = file.replaceAll("\\", "/");
|
|
39
|
+
const at = normal.lastIndexOf("/node_modules/");
|
|
40
|
+
if (at < 0)
|
|
41
|
+
return undefined;
|
|
42
|
+
const [first = "", second = ""] = normal.slice(at + "/node_modules/".length).split("/");
|
|
43
|
+
const scoped = first.startsWith("@");
|
|
44
|
+
if (first === "" || (scoped && second === ""))
|
|
45
|
+
return undefined;
|
|
46
|
+
if (first === "@types")
|
|
47
|
+
return second.includes("__") ? `@${second.replace("__", "/")}` : second;
|
|
48
|
+
return scoped ? `${first}/${second}` : first;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The package a file outside the project belongs to: by its node_modules folder, or, for a
|
|
52
|
+
* package linked from elsewhere (a workspace package, whose real path has no node_modules), by
|
|
53
|
+
* the name in its package.json.
|
|
54
|
+
*/
|
|
55
|
+
export function packageNameOf(types, file) {
|
|
56
|
+
return packageNameIn(file) ?? types.packageOf(file);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The package a declaration outside the project belongs to: the `declare module "x"` it sits in,
|
|
60
|
+
* by the name it is written with, else its file's package (`packageNameOf`); undefined when
|
|
61
|
+
* neither names one.
|
|
62
|
+
*/
|
|
63
|
+
export function declaredPackageOf(types, declaration) {
|
|
64
|
+
const module = ts.findAncestor(declaration.node.parent, ts.isModuleDeclaration);
|
|
65
|
+
const outer = module === undefined ? undefined : outermostModule(module);
|
|
66
|
+
return outer !== undefined && ts.isStringLiteral(outer.name)
|
|
67
|
+
? outer.name.text
|
|
68
|
+
: packageNameOf(types, declaration.file);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The id of the class a name refers to (`X` in `throw new X()`, `ns.X`, `@Catch(X)`):
|
|
72
|
+
* `builtin:<Name>` for a class of the platform, `package:<name>#<Class>` for a package's class,
|
|
73
|
+
* the symbol id (`SymbolRef.id`) for a class of the project. Undefined when the name resolves to
|
|
74
|
+
* nothing, or to a declaration outside the project whose package is not known.
|
|
75
|
+
*/
|
|
76
|
+
export function classIdOf(types, node) {
|
|
77
|
+
const name = ts.isPropertyAccessExpression(node)
|
|
78
|
+
? node.name
|
|
79
|
+
: ts.isQualifiedName(node)
|
|
80
|
+
? node.right
|
|
81
|
+
: node;
|
|
82
|
+
const symbol = types.symbolAt(name);
|
|
83
|
+
const declaration = symbol === undefined ? undefined : types.declarationOf(symbol);
|
|
84
|
+
if (symbol === undefined || declaration === undefined)
|
|
85
|
+
return undefined;
|
|
86
|
+
if (types.isOwnFile(declaration.file))
|
|
87
|
+
return symbol.id;
|
|
88
|
+
if (isPlatformDeclaration(declaration.node, declaration.file))
|
|
89
|
+
return `builtin:${symbol.name}`;
|
|
90
|
+
const owner = declaredPackageOf(types, declaration);
|
|
91
|
+
return owner === undefined ? undefined : `package:${owner}#${symbol.name}`;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=class-id.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `code` on one line, as it would be written on one: no white space next to a `.` or `?.`
|
|
3
|
+
* (`z.object`, not `z .object`); a line break after `(` or `[`, or before `)`, `]` or `,`, is
|
|
4
|
+
* removed, with a trailing comma before a closing bracket; any other run of white space, inside a
|
|
5
|
+
* token too, is one space.
|
|
6
|
+
*/
|
|
7
|
+
export declare function codeOnOneLine(code: string): string;
|
|
8
|
+
//# sourceMappingURL=code-text.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code shown on one line, in a message or a `coverage --facts` line. The code is read token by
|
|
3
|
+
* token with the TypeScript scanner, so the text of a string, a template or a comment is never
|
|
4
|
+
* joined to its neighbour: only the white space between tokens changes.
|
|
5
|
+
*/
|
|
6
|
+
import ts from "typescript";
|
|
7
|
+
const MEMBER_ACCESS = new Set([ts.SyntaxKind.DotToken, ts.SyntaxKind.QuestionDotToken]);
|
|
8
|
+
const OPENING = new Set([ts.SyntaxKind.OpenParenToken, ts.SyntaxKind.OpenBracketToken]);
|
|
9
|
+
const CLOSING = new Set([ts.SyntaxKind.CloseParenToken, ts.SyntaxKind.CloseBracketToken]);
|
|
10
|
+
/**
|
|
11
|
+
* `code` on one line, as it would be written on one: no white space next to a `.` or `?.`
|
|
12
|
+
* (`z.object`, not `z .object`); a line break after `(` or `[`, or before `)`, `]` or `,`, is
|
|
13
|
+
* removed, with a trailing comma before a closing bracket; any other run of white space, inside a
|
|
14
|
+
* token too, is one space.
|
|
15
|
+
*/
|
|
16
|
+
export function codeOnOneLine(code) {
|
|
17
|
+
const scanner = ts.createScanner(ts.ScriptTarget.Latest, false, ts.LanguageVariant.Standard, code);
|
|
18
|
+
const parts = [];
|
|
19
|
+
// The brace depth at which each open template substitution (`${`) started.
|
|
20
|
+
const substitutions = [];
|
|
21
|
+
let depth = 0;
|
|
22
|
+
let gap = "none";
|
|
23
|
+
let previous;
|
|
24
|
+
for (let kind = scanner.scan(); kind !== ts.SyntaxKind.EndOfFileToken; kind = scanner.scan()) {
|
|
25
|
+
if (kind === ts.SyntaxKind.NewLineTrivia) {
|
|
26
|
+
gap = "line";
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (kind === ts.SyntaxKind.WhitespaceTrivia) {
|
|
30
|
+
if (gap === "none")
|
|
31
|
+
gap = "space";
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (kind === ts.SyntaxKind.OpenBraceToken)
|
|
35
|
+
depth += 1;
|
|
36
|
+
else if (kind === ts.SyntaxKind.CloseBraceToken) {
|
|
37
|
+
if (substitutions.at(-1) === depth) {
|
|
38
|
+
kind = scanner.reScanTemplateToken(false);
|
|
39
|
+
if (kind === ts.SyntaxKind.TemplateTail)
|
|
40
|
+
substitutions.pop();
|
|
41
|
+
}
|
|
42
|
+
else
|
|
43
|
+
depth -= 1;
|
|
44
|
+
}
|
|
45
|
+
else if (kind === ts.SyntaxKind.TemplateHead)
|
|
46
|
+
substitutions.push(depth);
|
|
47
|
+
if (gap === "line" && previous === ts.SyntaxKind.CommaToken && CLOSING.has(kind))
|
|
48
|
+
parts.pop();
|
|
49
|
+
else if (previous !== undefined && gap !== "none" && !joined(previous, kind, gap)) {
|
|
50
|
+
parts.push(" ");
|
|
51
|
+
}
|
|
52
|
+
parts.push(scanner.getTokenText().replace(/\s+/g, " "));
|
|
53
|
+
previous = kind;
|
|
54
|
+
gap = "none";
|
|
55
|
+
}
|
|
56
|
+
return parts.join("").trim();
|
|
57
|
+
}
|
|
58
|
+
/** Whether the white space between two tokens is dropped. */
|
|
59
|
+
function joined(previous, next, gap) {
|
|
60
|
+
if (MEMBER_ACCESS.has(previous) || MEMBER_ACCESS.has(next))
|
|
61
|
+
return true;
|
|
62
|
+
if (gap !== "line")
|
|
63
|
+
return false;
|
|
64
|
+
return OPENING.has(previous) || CLOSING.has(next) || next === ts.SyntaxKind.CommaToken;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=code-text.js.map
|
package/dist/config-file.js
CHANGED
|
@@ -7,8 +7,8 @@ import { MessageChannel } from "node:worker_threads";
|
|
|
7
7
|
import { createJiti } from "jiti";
|
|
8
8
|
import { configLocalImports, foreignTypeScriptWarnings } from "./implementation.js";
|
|
9
9
|
import { parseConfig } from "./config.js";
|
|
10
|
-
import {
|
|
11
|
-
import { RuleDeclarationError, RuleLoadError, loadRules } from "./lazy.js";
|
|
10
|
+
import { keyLine, quotedIdLine } from "./renamed.js";
|
|
11
|
+
import { RuleDeclarationError, RuleLoadError, RuleReadsError, loadRules } from "./lazy.js";
|
|
12
12
|
import { CONFIG_FILE_NAMES, CONFIG_FILE_PATTERN } from "./vocabulary.js";
|
|
13
13
|
/** The path of the config file in `cwd`, if there is one. */
|
|
14
14
|
export function findConfigFile(cwd) {
|
|
@@ -217,8 +217,8 @@ export async function loadConfigFile(configFile) {
|
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
219
|
// The first line that names each old rule id, for the notice that says where to rename it.
|
|
220
|
-
const
|
|
221
|
-
const parsed = parseConfig(exported, path.dirname(configFile), path.basename(configFile), (id) =>
|
|
220
|
+
const text = readFileSync(configFile, "utf8");
|
|
221
|
+
const parsed = parseConfig(exported, path.dirname(configFile), path.basename(configFile), (id) => quotedIdLine(text, id), (name, entry) => keyLine(text, name, entry));
|
|
222
222
|
if (!parsed.ok)
|
|
223
223
|
return { ok: false, errors: parsed.errors.map((e) => `${configFile}: ${e}`) };
|
|
224
224
|
// The rules that are on are loaded now, so a check can run them; the rest never load.
|
|
@@ -226,7 +226,9 @@ export async function loadConfigFile(configFile) {
|
|
|
226
226
|
await loadRules(parsed.value);
|
|
227
227
|
}
|
|
228
228
|
catch (error) {
|
|
229
|
-
if (error instanceof RuleLoadError ||
|
|
229
|
+
if (error instanceof RuleLoadError ||
|
|
230
|
+
error instanceof RuleDeclarationError ||
|
|
231
|
+
error instanceof RuleReadsError) {
|
|
230
232
|
return { ok: false, errors: [`${configFile}: ${error.message}`] };
|
|
231
233
|
}
|
|
232
234
|
throw error;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Config, ExtendedConfig, ParseResult, Plugin, Preset, UserConfig } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* What stateward checks when the config does not say: import it to add to the lists instead of
|
|
4
|
-
* replacing them, for example `exclude: [...defaults.exclude, "src/generated/**"]`.
|
|
4
|
+
* replacing them, for example `exclude: [...defaults.exclude, "src/generated/**"]`. The packs the
|
|
5
|
+
* config loads add the test patterns of their library to `exclude` (`Plugin.defaultExclude`),
|
|
6
|
+
* unless the config's own list leaves out one of these.
|
|
5
7
|
*/
|
|
6
8
|
export declare const defaults: {
|
|
7
9
|
readonly include: readonly string[];
|
|
@@ -11,6 +13,10 @@ export declare const defaults: {
|
|
|
11
13
|
export declare function defineConfig<const P extends readonly Plugin[] = readonly [], const E extends readonly ExtendedConfig[] = readonly []>(config: UserConfig<P, E>): UserConfig<P, E>;
|
|
12
14
|
/** Whether `value` is the name of a preset. */
|
|
13
15
|
export declare function isPreset(value: unknown): value is Preset;
|
|
16
|
+
/** The test patterns the packs add to the default `exclude` (`Plugin.defaultExclude`), in order. */
|
|
17
|
+
export declare function packExcludes(plugins: readonly Plugin[]): readonly string[];
|
|
18
|
+
/** The key of a package's lines in `facts` that gives the range of versions they are for. */
|
|
19
|
+
export declare const VERSIONS_KEY = "@versions";
|
|
14
20
|
/** The least `maxMemory` (MB): below it Node cannot even load TypeScript. */
|
|
15
21
|
export declare const MIN_MAX_MEMORY = 512;
|
|
16
22
|
/** Whether `value` is a memory limit stateward accepts: a whole number of MB, at least 512. */
|
|
@@ -21,5 +27,7 @@ export declare function isMaxMemory(value: unknown): value is number;
|
|
|
21
27
|
*/
|
|
22
28
|
export declare function parseConfig(given: unknown, configDir: string, configName?: string,
|
|
23
29
|
/** The line the config file names an old rule id on, so the notice says where to rename it. */
|
|
24
|
-
lineOf?: (id: string) => number | undefined
|
|
30
|
+
lineOf?: (id: string) => number | undefined,
|
|
31
|
+
/** The line the config file names a package's function or class on under `facts`. */
|
|
32
|
+
factLineOf?: (name: string, entry: string) => number | undefined): ParseResult<Config>;
|
|
25
33
|
//# sourceMappingURL=config.d.ts.map
|