@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.
Files changed (75) hide show
  1. package/dist/analyses.d.ts +37 -0
  2. package/dist/analyses.js +57 -0
  3. package/dist/backend/program-record.d.ts +7 -0
  4. package/dist/backend/typescript6.d.ts +35 -32
  5. package/dist/backend/typescript6.js +3804 -163
  6. package/dist/baseline.d.ts +1 -1
  7. package/dist/baseline.js +14 -10
  8. package/dist/cache.d.ts +89 -5
  9. package/dist/cache.js +271 -40
  10. package/dist/checker.d.ts +11 -1
  11. package/dist/checker.js +32 -2
  12. package/dist/class-id.d.ts +34 -0
  13. package/dist/class-id.js +93 -0
  14. package/dist/code-text.d.ts +8 -0
  15. package/dist/code-text.js +66 -0
  16. package/dist/config-file.js +7 -5
  17. package/dist/config.d.ts +10 -2
  18. package/dist/config.js +541 -49
  19. package/dist/define.d.ts +8 -2
  20. package/dist/disk-cache.d.ts +2 -0
  21. package/dist/disk-cache.js +77 -11
  22. package/dist/engine.d.ts +51 -1
  23. package/dist/engine.js +517 -42
  24. package/dist/fact-lines.d.ts +31 -0
  25. package/dist/fact-lines.js +197 -0
  26. package/dist/facts-versions.d.ts +27 -0
  27. package/dist/facts-versions.js +99 -0
  28. package/dist/fixes.js +9 -4
  29. package/dist/guarantees.d.ts +63 -11
  30. package/dist/guarantees.js +151 -21
  31. package/dist/ignores.d.ts +11 -0
  32. package/dist/ignores.js +74 -27
  33. package/dist/implementation.d.ts +0 -6
  34. package/dist/implementation.js +0 -17
  35. package/dist/index.d.ts +10 -9
  36. package/dist/index.js +14 -7
  37. package/dist/internal.d.ts +9 -5
  38. package/dist/internal.js +6 -3
  39. package/dist/lazy.d.ts +8 -1
  40. package/dist/lazy.js +27 -2
  41. package/dist/ledger.d.ts +77 -0
  42. package/dist/ledger.js +423 -0
  43. package/dist/off-by-default.d.ts +13 -0
  44. package/dist/off-by-default.js +15 -0
  45. package/dist/options.d.ts +21 -5
  46. package/dist/options.js +22 -7
  47. package/dist/package-facts.d.ts +211 -17
  48. package/dist/package-facts.js +520 -38
  49. package/dist/plan.d.ts +1 -1
  50. package/dist/plan.js +7 -2
  51. package/dist/release.d.ts +12 -21
  52. package/dist/release.js +28 -38
  53. package/dist/renamed.d.ts +22 -3
  54. package/dist/renamed.js +50 -16
  55. package/dist/rollout.js +7 -4
  56. package/dist/safe-calls.d.ts +26 -0
  57. package/dist/safe-calls.js +345 -0
  58. package/dist/severity.d.ts +1 -1
  59. package/dist/severity.js +17 -3
  60. package/dist/stated.d.ts +37 -0
  61. package/dist/stated.js +123 -0
  62. package/dist/test-runner.d.ts +18 -0
  63. package/dist/test-runner.js +483 -0
  64. package/dist/testing-tsc.d.ts +16 -0
  65. package/dist/testing-tsc.js +86 -0
  66. package/dist/testing.d.ts +5 -4
  67. package/dist/testing.js +6 -6
  68. package/dist/timing.d.ts +15 -0
  69. package/dist/timing.js +41 -2
  70. package/dist/types.d.ts +1068 -16
  71. package/dist/unread.d.ts +90 -0
  72. package/dist/unread.js +405 -0
  73. package/dist/vocabulary.d.ts +1 -1
  74. package/dist/vocabulary.js +1 -1
  75. package/package.json +4 -2
package/dist/release.d.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  /**
2
2
  * The release trait: a value that must be released once it is no longer used (a subscription, a
3
3
  * listener, a connection). Core reads where the trait is stated, in the plainest form first, and
4
- * knows no library: a standard `Disposable` type, the project's `Release<T>` marker, a `facts`
5
- * line in the config, or the facts a plugin ships (`Plugin.facts`).
4
+ * knows no library: a standard `Disposable` type, a `facts` line in the config, or the facts a
5
+ * plugin ships (`Plugin.facts`).
6
6
  */
7
7
  import ts from "typescript";
8
8
  import { type FactContext } from "./package-facts.js";
9
9
  import type { TraitSource } from "./types.js";
10
- /** The trait name the `Release<T>` marker states: `"__guarantee:release"?: true`. */
11
- export declare const RELEASE = "release";
10
+ import type { Unread } from "./unread.js";
12
11
  /**
13
12
  * How a value with the release trait is released: calling it (`unsubscribe()`), calling a method
14
13
  * on it (`subscription.unsubscribe()`), or disposing of it (`using`, `[Symbol.dispose]()`).
@@ -24,34 +23,26 @@ export type ReleaseWay = {
24
23
  };
25
24
  /** The release trait of a call's result, and where it is stated. */
26
25
  export type ReleaseTrait = {
26
+ readonly kind: "trait";
27
27
  readonly way: ReleaseWay;
28
28
  readonly source: TraitSource;
29
29
  /** The function called, as the note names it: `onSnapshot`, `Observable.subscribe`. */
30
30
  readonly callee: string;
31
31
  };
32
32
  /**
33
- * What a rule tells `releaseTraitOf`: `platformPackages`, packages whose `Disposable` types do not
34
- * state the trait (Node's types add `[Symbol.dispose]` to child processes, streams and timers,
35
- * which end by themselves).
33
+ * The release trait of what a call returns, from the plainest statement of it: the config's
34
+ * `facts` line for the package function, the facts a plugin ships for it, then a standard
35
+ * `Disposable` or `AsyncDisposable` type. Undefined
36
+ * when nothing states it. A `Disposable` declared outside the project (the platform, a package) is
37
+ * left out, and so is a method that returns its own receiver (`stream.on(…)`).
36
38
  */
37
- export type ReleaseOptions = {
38
- readonly platformPackages?: readonly string[];
39
- };
40
- /**
41
- * The release trait of what a call returns, from the plainest statement of it: the project's
42
- * `Release<T>` marker on the return type, the config's `facts` line for the package function, the
43
- * facts a plugin ships for it, then a standard `Disposable` or `AsyncDisposable` type. Undefined
44
- * when nothing states it. A `Disposable` declared in one of `options.platformPackages` is left
45
- * out, and so is a method that returns its own receiver (`stream.on(…)`).
46
- */
47
- export declare function releaseTraitOf(call: ts.CallExpression | ts.NewExpression, ctx: FactContext, options?: ReleaseOptions): ReleaseTrait | undefined;
39
+ export declare function releaseTraitOf(call: ts.CallExpression | ts.NewExpression, ctx: FactContext): ReleaseTrait | Unread | undefined;
48
40
  /** A call `releaseCandidates` keeps or drops. */
49
41
  export type ReleaseCandidate = (call: ts.CallExpression | ts.NewExpression) => boolean;
50
42
  /**
51
43
  * A test, from the syntax alone, of whether `releaseTraitOf` can find the trait for a call of the
52
- * file, so a rule asks no type question about the others. When the program states `Release`
53
- * somewhere, or a project file declares a `[Symbol.dispose]` or `[Symbol.asyncDispose]` member,
54
- * every call is kept. Otherwise only a `facts` line with `returns` can state the trait, and a call
44
+ * file, so a rule asks no type question about the others. When a project file declares a
45
+ * `[Symbol.dispose]` or `[Symbol.asyncDispose]` member, every call is kept. Otherwise only a `facts` line with `returns` can state the trait, and a call
55
46
  * is kept when its callee's name (`onSnapshot`, `store.subscribe`) is the last part of such a
56
47
  * line's name or a name the project gives it with `as`, or when the call is made through a name
57
48
  * imported from a package such a line is listed under. Built once per file.
package/dist/release.js CHANGED
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  * The release trait: a value that must be released once it is no longer used (a subscription, a
3
3
  * listener, a connection). Core reads where the trait is stated, in the plainest form first, and
4
- * knows no library: a standard `Disposable` type, the project's `Release<T>` marker, a `facts`
5
- * line in the config, or the facts a plugin ships (`Plugin.facts`).
4
+ * knows no library: a standard `Disposable` type, a `facts` line in the config, or the facts a
5
+ * plugin ships (`Plugin.facts`).
6
6
  */
7
7
  import ts from "typescript";
8
- import { calleeName, importedFrom, packageFactOf, packageFunctionOf, pathOf, rootName, } from "./package-facts.js";
9
- /** The trait name the `Release<T>` marker states: `"__guarantee:release"?: true`. */
10
- export const RELEASE = "release";
8
+ import { calleeName, importedFrom, withReceiverOf, packageFactOf, packageFunctionOf, pathOf, rootName, } from "./package-facts.js";
11
9
  function unwrapped(expression) {
12
10
  let node = expression;
13
11
  while (ts.isParenthesizedExpression(node) || ts.isNonNullExpression(node)) {
@@ -19,41 +17,36 @@ function wayOf(fact) {
19
17
  return fact === "release" ? { kind: "call" } : { kind: "method", name: fact.release };
20
18
  }
21
19
  /**
22
- * The release trait of what a call returns, from the plainest statement of it: the project's
23
- * `Release<T>` marker on the return type, the config's `facts` line for the package function, the
24
- * facts a plugin ships for it, then a standard `Disposable` or `AsyncDisposable` type. Undefined
25
- * when nothing states it. A `Disposable` declared in one of `options.platformPackages` is left
26
- * out, and so is a method that returns its own receiver (`stream.on(…)`).
20
+ * The release trait of what a call returns, from the plainest statement of it: the config's
21
+ * `facts` line for the package function, the facts a plugin ships for it, then a standard
22
+ * `Disposable` or `AsyncDisposable` type. Undefined
23
+ * when nothing states it. A `Disposable` declared outside the project (the platform, a package) is
24
+ * left out, and so is a method that returns its own receiver (`stream.on(…)`).
27
25
  */
28
- export function releaseTraitOf(call, ctx, options = {}) {
26
+ export function releaseTraitOf(call, ctx) {
29
27
  const { types } = ctx;
30
28
  const name = calleeName(call);
31
29
  const symbol = name === undefined ? undefined : types.symbolAt(name);
32
30
  const declared = symbol === undefined ? undefined : types.declarationOf(symbol);
33
31
  const path = declared === undefined ? [] : pathOf(declared.node);
34
32
  const calleeText = path.length > 0 ? path.join(".") : (name?.text ?? "the call");
35
- if (types.guaranteesOf(call).includes(RELEASE)) {
36
- const kind = types.disposeOf(call)?.kind;
37
- const way = types.isCallable(call)
38
- ? { kind: "call" }
39
- : kind === undefined
40
- ? undefined
41
- : { kind: "dispose", async: kind === "async" };
42
- if (way !== undefined)
43
- return { way, source: { kind: "marker" }, callee: calleeText };
44
- }
45
33
  // A name the project gives a package function (`const listen = onSnapshot`) is followed to it.
46
34
  const aliased = declared !== undefined && types.isOwnFile(declared.file) && ts.isIdentifier(call.expression)
47
35
  ? packageFunctionOf(call.expression, ctx)
48
36
  : undefined;
49
37
  const found = aliased !== undefined
50
- ? packageFactOf(aliased.declared, aliased.through, ctx)
38
+ ? packageFactOf(aliased.declared, ctx, "returns")
51
39
  : declared === undefined
52
40
  ? undefined
53
- : packageFactOf(declared, call.expression, ctx);
54
- if (found?.fact.returns !== undefined) {
41
+ : packageFactOf(name === undefined ? declared : withReceiverOf(declared, name), ctx, "returns");
42
+ // A `returns` line left out for the version the project runs: not checked, never a pass.
43
+ if (found?.kind === "unread")
44
+ return found;
45
+ const returns = found?.fact.returns;
46
+ if (found !== undefined && returns !== undefined) {
55
47
  return {
56
- way: wayOf(found.fact.returns),
48
+ kind: "trait",
49
+ way: wayOf(returns),
57
50
  source: { kind: found.source, package: found.package },
58
51
  callee: calleeText,
59
52
  };
@@ -66,10 +59,6 @@ export function releaseTraitOf(call, ctx, options = {}) {
66
59
  // test mocks, Node's timers and streams): a package's value has the trait only through `facts`.
67
60
  if (!types.isOwnFile(disposed.file))
68
61
  return undefined;
69
- const platform = types.packageOf(disposed.file);
70
- if (platform !== undefined && (options.platformPackages ?? []).includes(platform)) {
71
- return undefined;
72
- }
73
62
  // `stream.on(…)`, `hash.update(…)`: a method that returns its receiver starts nothing new.
74
63
  const callee = unwrapped(call.expression);
75
64
  if (ts.isPropertyAccessExpression(callee) &&
@@ -78,6 +67,7 @@ export function releaseTraitOf(call, ctx, options = {}) {
78
67
  }
79
68
  const kind = disposed.kind;
80
69
  return {
70
+ kind: "trait",
81
71
  way: { kind: "dispose", async: kind === "async" },
82
72
  source: { kind: "type", name: kind === "async" ? "AsyncDisposable" : "Disposable" },
83
73
  callee: calleeText,
@@ -85,20 +75,21 @@ export function releaseTraitOf(call, ctx, options = {}) {
85
75
  }
86
76
  /**
87
77
  * A test, from the syntax alone, of whether `releaseTraitOf` can find the trait for a call of the
88
- * file, so a rule asks no type question about the others. When the program states `Release`
89
- * somewhere, or a project file declares a `[Symbol.dispose]` or `[Symbol.asyncDispose]` member,
90
- * every call is kept. Otherwise only a `facts` line with `returns` can state the trait, and a call
78
+ * file, so a rule asks no type question about the others. When a project file declares a
79
+ * `[Symbol.dispose]` or `[Symbol.asyncDispose]` member, every call is kept. Otherwise only a `facts` line with `returns` can state the trait, and a call
91
80
  * is kept when its callee's name (`onSnapshot`, `store.subscribe`) is the last part of such a
92
81
  * line's name or a name the project gives it with `as`, or when the call is made through a name
93
82
  * imported from a package such a line is listed under. Built once per file.
94
83
  */
95
84
  export function releaseCandidates(ctx) {
96
85
  const { types } = ctx;
97
- if (types.declaresTrait(RELEASE) || types.declaresDispose())
86
+ if (types.declaresDispose())
98
87
  return () => true;
99
88
  const names = new Set();
100
89
  const packages = new Set();
101
- for (const facts of [ctx.facts, ctx.shippedFacts]) {
90
+ // A line left out for the project's version is a candidate too: its call is "not checked".
91
+ const withheld = Object.fromEntries(ctx.withheldFacts.map((one) => [one.package, one.functions]));
92
+ for (const facts of [ctx.facts, ctx.shippedFacts, withheld]) {
102
93
  for (const [name, functions] of Object.entries(facts)) {
103
94
  for (const [key, fact] of Object.entries(functions)) {
104
95
  if (fact.returns === undefined)
@@ -145,6 +136,8 @@ export function describeTraitSource(source) {
145
136
  return `the config's facts for ${source.package}`;
146
137
  case "shipped":
147
138
  return `stateward's facts for ${source.package}`;
139
+ case "tag":
140
+ return `the JSDoc tag \`@${source.tag}\``;
148
141
  default: {
149
142
  const unreachable = source;
150
143
  return unreachable;
@@ -164,9 +157,6 @@ export function describeRelease(trait) {
164
157
  : trait.way.async
165
158
  ? "a value released with `await using` or `[Symbol.asyncDispose]()`"
166
159
  : "a value released with `using` or `[Symbol.dispose]()`";
167
- const stated = trait.source.kind === "marker"
168
- ? "its return type is stated `Release`"
169
- : describeTraitSource(trait.source);
170
- return `\`${trait.callee}\` returns ${what} (${stated})`;
160
+ return `\`${trait.callee}\` returns ${what} (${describeTraitSource(trait.source)})`;
171
161
  }
172
162
  //# sourceMappingURL=release.js.map
package/dist/renamed.d.ts CHANGED
@@ -1,10 +1,21 @@
1
1
  /**
2
2
  * Rule ids a release renamed, so that a rule's name says what is wrong. The old id keeps working:
3
3
  * a config, an ignore comment, the rollout file and the baseline that still use one are read under
4
- * the new id, with a warning that says what to rename. Ids only: core still knows no library.
4
+ * the new id, with a warning that says what to rename. A rule a release removed is skipped the same
5
+ * way, with a warning that says to delete it. Each pack declares its own (`Plugin.renamed`,
6
+ * `Plugin.removed`): core keeps no rule id of a pack.
5
7
  */
8
+ import type { Plugin } from "./types.js";
9
+ /** Old rule ids to the ids the rules have now, from the loaded packs. */
10
+ export type Renames = ReadonlyMap<string, string>;
11
+ /** The renamed rule ids the packs declare (`Plugin.renamed`), in plugin order; the first wins. */
12
+ export declare function renamesOf(plugins: readonly Plugin[]): Renames;
6
13
  /** The id a renamed rule has now, or undefined when `ruleId` was not renamed. */
7
- export declare function renamedRule(ruleId: string): string | undefined;
14
+ export declare function renamedRule(renames: Renames, ruleId: string): string | undefined;
15
+ /** Rule ids a release removed, with their add-ons of the same id (`Plugin.removed`), from the loaded packs. */
16
+ export declare function removedOf(plugins: readonly Plugin[]): ReadonlySet<string>;
17
+ /** What a config that names a removed rule or add-on is told: the entry has no effect; delete it. */
18
+ export declare function removedNotice(id: string, where: string): string;
8
19
  /** What a config that names an old id is told: `a` is now `b`; rename it in `where`. */
9
20
  export declare function renameNotice(before: string, now: string, where: string): string;
10
21
  /**
@@ -25,5 +36,13 @@ export type RenamedIdPlace = {
25
36
  * config file has to rename, and where. Only whole quoted ids count, so a longer id or a comment
26
37
  * that mentions one in other words is left alone.
27
38
  */
28
- export declare function renamedIdsIn(text: string): RenamedIdPlace[];
39
+ export declare function renamedIdsIn(renames: Renames, text: string): RenamedIdPlace[];
40
+ /** The line of the first place a text names `id` in quotes, for a notice that says where it is. */
41
+ export declare function quotedIdLine(text: string, id: string): number | undefined;
42
+ /**
43
+ * The 1-based line of `text` where the key `entry` is written after the key `name` (quoted or
44
+ * not): the line of a `facts` entry, `facts: { "@scope/pkg": { JwtGuard: … } }`. Undefined when
45
+ * the text does not write them so.
46
+ */
47
+ export declare function keyLine(text: string, name: string, entry: string): number | undefined;
29
48
  //# sourceMappingURL=renamed.d.ts.map
package/dist/renamed.js CHANGED
@@ -1,18 +1,25 @@
1
- /**
2
- * Rule ids a release renamed, so that a rule's name says what is wrong. The old id keeps working:
3
- * a config, an ignore comment, the rollout file and the baseline that still use one are read under
4
- * the new id, with a warning that says what to rename. Ids only: core still knows no library.
5
- */
6
- const RULES = new Map(Object.entries({
7
- // 1.2.0
8
- "unions/default-hides-cases": "unions/non-exhaustive-switch",
9
- "unions/tag-does-not-discriminate": "unions/ambiguous-discriminant",
10
- "records/table-type-too-loose": "records/ambiguous-table",
11
- "react/provider-value-changes-every-render": "react-context/provider-value-changes-every-render",
12
- }));
1
+ /** The renamed rule ids the packs declare (`Plugin.renamed`), in plugin order; the first wins. */
2
+ export function renamesOf(plugins) {
3
+ const found = new Map();
4
+ for (const plugin of plugins) {
5
+ for (const [before, now] of Object.entries(plugin.renamed ?? {})) {
6
+ if (!found.has(before))
7
+ found.set(before, now);
8
+ }
9
+ }
10
+ return found;
11
+ }
13
12
  /** The id a renamed rule has now, or undefined when `ruleId` was not renamed. */
14
- export function renamedRule(ruleId) {
15
- return RULES.get(ruleId);
13
+ export function renamedRule(renames, ruleId) {
14
+ return renames.get(ruleId);
15
+ }
16
+ /** Rule ids a release removed, with their add-ons of the same id (`Plugin.removed`), from the loaded packs. */
17
+ export function removedOf(plugins) {
18
+ return new Set(plugins.flatMap((plugin) => plugin.removed ?? []));
19
+ }
20
+ /** What a config that names a removed rule or add-on is told: the entry has no effect; delete it. */
21
+ export function removedNotice(id, where) {
22
+ return `\`${id}\` was removed from stateward and has no effect; delete it from ${where}`;
16
23
  }
17
24
  /** What a config that names an old id is told: `a` is now `b`; rename it in `where`. */
18
25
  export function renameNotice(before, now, where) {
@@ -31,12 +38,12 @@ export function movedNotice(before, now, where) {
31
38
  * config file has to rename, and where. Only whole quoted ids count, so a longer id or a comment
32
39
  * that mentions one in other words is left alone.
33
40
  */
34
- export function renamedIdsIn(text) {
41
+ export function renamedIdsIn(renames, text) {
35
42
  const places = [];
36
43
  const quoted = /(["'`])([^"'`\n]+)\1/g;
37
44
  for (const match of text.matchAll(quoted)) {
38
45
  const id = match[2];
39
- const now = id === undefined ? undefined : RULES.get(id);
46
+ const now = id === undefined ? undefined : renames.get(id);
40
47
  if (id === undefined || now === undefined)
41
48
  continue;
42
49
  const start = match.index + 1;
@@ -45,4 +52,31 @@ export function renamedIdsIn(text) {
45
52
  }
46
53
  return places;
47
54
  }
55
+ /** The line of the first place a text names `id` in quotes, for a notice that says where it is. */
56
+ export function quotedIdLine(text, id) {
57
+ const quoted = /(["'`])([^"'`\n]+)\1/g;
58
+ for (const match of text.matchAll(quoted)) {
59
+ if (match[2] === id)
60
+ return text.slice(0, match.index + 1).split("\n").length;
61
+ }
62
+ return undefined;
63
+ }
64
+ function escaped(text) {
65
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
66
+ }
67
+ /**
68
+ * The 1-based line of `text` where the key `entry` is written after the key `name` (quoted or
69
+ * not): the line of a `facts` entry, `facts: { "@scope/pkg": { JwtGuard: … } }`. Undefined when
70
+ * the text does not write them so.
71
+ */
72
+ export function keyLine(text, name, entry) {
73
+ const key = (word) => new RegExp(`(?<![\\w$])(["'\`]?)${escaped(word)}\\1\\s*:`, "g");
74
+ const outer = key(name).exec(text);
75
+ if (outer === null)
76
+ return undefined;
77
+ const inner = key(entry);
78
+ inner.lastIndex = outer.index + outer[0].length;
79
+ const found = inner.exec(text);
80
+ return found === null ? undefined : text.slice(0, found.index + 1).split("\n").length;
81
+ }
48
82
  //# sourceMappingURL=renamed.js.map
package/dist/rollout.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { ruleIds } from "./severity.js";
4
- import { renamedRule } from "./renamed.js";
4
+ import { removedOf, renamedRule, renamesOf } from "./renamed.js";
5
5
  export const ROLLOUT_FILE = "stateward.rollout.json";
6
6
  const ROLLOUT_VERSION = 1;
7
7
  /**
@@ -35,7 +35,7 @@ function broken(file, why, fix) {
35
35
  return new RolloutError(`${path.basename(file)} ${why}; ${fix}`);
36
36
  }
37
37
  const REPAIR = "fix it, or delete it to start again with `stateward next`";
38
- function parseEnabled(text, file, known) {
38
+ function parseEnabled(text, file, known, renames, removed) {
39
39
  let parsed;
40
40
  try {
41
41
  parsed = JSON.parse(text);
@@ -59,8 +59,11 @@ function parseEnabled(text, file, known) {
59
59
  const seen = new Set();
60
60
  const kept = [];
61
61
  for (const listed of enabled) {
62
+ // A removed rule turns nothing on; the next write leaves it out.
63
+ if (!known.has(listed) && removed.has(listed))
64
+ continue;
62
65
  // A renamed rule is read under its new id; the next write saves that one.
63
- const id = known.has(listed) ? listed : (renamedRule(listed) ?? listed);
66
+ const id = known.has(listed) ? listed : (renamedRule(renames, listed) ?? listed);
64
67
  if (!known.has(id)) {
65
68
  throw broken(file, `lists "${id}", which is not a rule of your packs`, `remove "${id}" from its "enabled" list; the other rules stay on`);
66
69
  }
@@ -86,7 +89,7 @@ export function readRollout(config) {
86
89
  return [];
87
90
  throw new RolloutError(`${path.basename(file)} cannot be read (${reasonOf(error)}); fix the file or its permissions, then run again`, { cause: error });
88
91
  }
89
- return parseEnabled(text, file, new Set(ruleIds(config.plugins)));
92
+ return parseEnabled(text, file, new Set(ruleIds(config.plugins)), renamesOf(config.plugins), removedOf(config.plugins));
90
93
  }
91
94
  /**
92
95
  * Saves the rules turned on. Atomic: the text goes to a temp file beside the target, then one
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Calls of the platform that do not throw on values their types allow: the closed list the proofs
3
+ * share. An entry holds only on the platform's own types, as the type checker sees them: the value
4
+ * a method is called on is typed by the platform's type itself (not an interface or a class of the
5
+ * project, and not a type the project extends), and the arguments' types make the call safe
6
+ * (`String(x)` on a primitive, `join` on an array of primitives). Every other call of the platform
7
+ * or a package may throw (`new URL("x")`, `[].reduce(add)`, `JSON.parse(text)`, `n.toString(36)`,
8
+ * `headers.set(…)`). A function of the project is not on the list: a proof reads it, or counts it
9
+ * as a call that may throw. Core knows no library; these are the language's own built-ins.
10
+ */
11
+ import ts from "typescript";
12
+ import type { TypeQueries } from "./types.js";
13
+ /**
14
+ * Whether a `for…of` over an expression runs no code of the project and cannot throw: over the
15
+ * platform's array, a string, or an iterator of a `Map` or `Set` (`for (const v of m.values())`).
16
+ */
17
+ export declare function iteratesPlainly(node: ts.Expression, types: TypeQueries): boolean;
18
+ /**
19
+ * Whether a call or `new` is on the closed list of the platform's calls that do not throw, on the
20
+ * platform's own types: `console.log(…)`, `Math.max(a, b)` on numbers, `Object.keys(…)` on a
21
+ * known type, `new Map()`, `list.push(…)` on an array, `String(x)` on a primitive, `d.getTime()`,
22
+ * `n.toFixed(2)`, `Array.from(xs)` on an array, a string method on a branded string. The caller checks what a
23
+ * callback given to the call does.
24
+ */
25
+ export declare function isSafePlatformCall(node: ts.CallExpression | ts.NewExpression, types: TypeQueries): boolean;
26
+ //# sourceMappingURL=safe-calls.d.ts.map