@stateward/plugin-errors 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/README.md +9 -8
- package/dist/catch-hides-unexpected.d.ts +4 -1
- package/dist/catch-hides-unexpected.js +12 -5
- package/dist/catch-misses-error.d.ts +1 -1
- package/dist/catch-misses-error.js +1 -1
- package/dist/finally-can-throw.js +3 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/inference/analysis.d.ts +109 -0
- package/dist/inference/analysis.js +170 -0
- package/dist/inference/builtins.d.ts +0 -2
- package/dist/inference/builtins.js +0 -33
- package/dist/inference/deps.js +2 -2
- package/dist/inference/needs.d.ts +16 -0
- package/dist/inference/needs.js +27 -0
- package/dist/inference/packages.d.ts +24 -32
- package/dist/inference/packages.js +156 -680
- package/dist/inference/project.d.ts +2 -2
- package/dist/inference/project.js +3 -2
- package/dist/inference/solve.d.ts +29 -4
- package/dist/inference/solve.js +34 -5
- package/dist/inference/summarize.d.ts +27 -15
- package/dist/inference/summarize.js +247 -130
- package/dist/inference/summary.d.ts +41 -5
- package/dist/inference/summary.js +84 -12
- package/dist/inference/unreachable.d.ts +5 -0
- package/dist/inference/unreachable.js +160 -0
- package/dist/must-handle-error.d.ts +2 -1
- package/dist/must-handle-error.js +4 -4
- package/dist/plugin.d.ts +12 -2
- package/dist/plugin.js +4 -2
- package/dist/react/tree.js +8 -4
- package/dist/render-throw-without-boundary.d.ts +13 -4
- package/dist/result-ignored.d.ts +4 -1
- package/dist/result-type.js +2 -2
- package/dist/result-unchecked.d.ts +4 -1
- package/dist/result-unchecked.js +139 -61
- package/dist/rules.meta.d.ts +26 -14
- package/dist/rules.meta.js +18 -14
- package/dist/syntax.d.ts +0 -13
- package/dist/syntax.js +0 -79
- package/dist/text.d.ts +5 -2
- package/dist/text.js +11 -5
- package/dist/throws-doc-mismatch.d.ts +1 -1
- package/dist/throws-doc-mismatch.js +7 -1
- package/package.json +2 -2
package/dist/text.d.ts
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
export declare const HEADLINE_MAX = 100;
|
|
3
3
|
/** The first line of a fix is at most this long. */
|
|
4
4
|
export declare const HINT_MAX = 140;
|
|
5
|
-
/** The text on one line: all whitespace becomes a single space. */
|
|
6
|
-
export declare function oneLine(text: string): string;
|
|
7
5
|
/** The text as it is, or its first `max - 1` characters and `…` when it is longer than `max`. */
|
|
8
6
|
export declare function shorten(text: string, max: number): string;
|
|
7
|
+
/**
|
|
8
|
+
* The text as it is, or `…` and its last `max - 1` characters when it is longer than `max`: for a
|
|
9
|
+
* called function, whose name is at the end (`…delete().from` of a long chain).
|
|
10
|
+
*/
|
|
11
|
+
export declare function shortenStart(text: string, max: number): string;
|
|
9
12
|
/**
|
|
10
13
|
* Builds a message whose inserted names are shown whole, on one line: a developer's name is never
|
|
11
14
|
* cut. A headline that is longer than the limit because of its names is allowed to be.
|
package/dist/text.js
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
|
+
import { codeOnOneLine } from "@stateward/core";
|
|
1
2
|
/** A headline is at most this long. */
|
|
2
3
|
export const HEADLINE_MAX = 100;
|
|
3
4
|
/** The first line of a fix is at most this long. */
|
|
4
5
|
export const HINT_MAX = 140;
|
|
5
|
-
/** The text on one line: all whitespace becomes a single space. */
|
|
6
|
-
export function oneLine(text) {
|
|
7
|
-
return text.replace(/\s+/g, " ").trim();
|
|
8
|
-
}
|
|
9
6
|
/** The text as it is, or its first `max - 1` characters and `…` when it is longer than `max`. */
|
|
10
7
|
export function shorten(text, max) {
|
|
11
8
|
if (text.length <= max)
|
|
12
9
|
return text;
|
|
13
10
|
return `${text.slice(0, max - 1)}…`;
|
|
14
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The text as it is, or `…` and its last `max - 1` characters when it is longer than `max`: for a
|
|
14
|
+
* called function, whose name is at the end (`…delete().from` of a long chain).
|
|
15
|
+
*/
|
|
16
|
+
export function shortenStart(text, max) {
|
|
17
|
+
if (text.length <= max)
|
|
18
|
+
return text;
|
|
19
|
+
return `…${text.slice(text.length - (max - 1))}`;
|
|
20
|
+
}
|
|
15
21
|
/**
|
|
16
22
|
* Builds a message whose inserted names are shown whole, on one line: a developer's name is never
|
|
17
23
|
* cut. A headline that is longer than the limit because of its names is allowed to be.
|
|
18
24
|
* `build` applies the given `cut` to every name it inserts.
|
|
19
25
|
*/
|
|
20
26
|
export function fitted(build) {
|
|
21
|
-
return build(
|
|
27
|
+
return build(codeOnOneLine);
|
|
22
28
|
}
|
|
23
29
|
/** The names that a list shows, at most this many; the rest are counted. */
|
|
24
30
|
const MAX_LISTED = 3;
|
|
@@ -3,5 +3,5 @@ export declare const GROUP = "callers";
|
|
|
3
3
|
export declare const throwsDocMismatch: import("@stateward/core").ProjectRule<import("./index.js").ThrowsSummary, {
|
|
4
4
|
severities: import("@stateward/core").SeveritiesOption<"missing" | "extra">;
|
|
5
5
|
ignoreClasses: import("@stateward/core").StringsOption;
|
|
6
|
-
}, "callers"
|
|
6
|
+
}, "callers", Readonly<Record<string, import("@stateward/core").Json>>>;
|
|
7
7
|
//# sourceMappingURL=throws-doc-mismatch.d.ts.map
|
|
@@ -2,6 +2,7 @@ import { defineRule, matchesName, option } from "@stateward/core";
|
|
|
2
2
|
import { catchName, className } from "./inference/format.js";
|
|
3
3
|
import { analyse, collected, evaluated, relation } from "./inference/solve.js";
|
|
4
4
|
import { REASON } from "./inference/summarize.js";
|
|
5
|
+
import { decidingFacts } from "./inference/needs.js";
|
|
5
6
|
import { summarizeOnce } from "./inference/project.js";
|
|
6
7
|
import { codeList, fitted } from "./text.js";
|
|
7
8
|
import { markThrowsReferences } from "./throws-reads.js";
|
|
@@ -136,6 +137,8 @@ function check(entry, analysis, ctx, reported) {
|
|
|
136
137
|
hint: `remove \`${listed}\` from the tag if \`${name}\` cannot throw it; otherwise add \`@throws\` where it comes from`,
|
|
137
138
|
location,
|
|
138
139
|
against,
|
|
140
|
+
// Every call the function cannot follow decides it, not only the one the message names.
|
|
141
|
+
...decidingFacts(all.unknowns.values()),
|
|
139
142
|
});
|
|
140
143
|
continue;
|
|
141
144
|
}
|
|
@@ -160,9 +163,12 @@ function check(entry, analysis, ctx, reported) {
|
|
|
160
163
|
message: fitted((cut) => isCall(source)
|
|
161
164
|
? `not checked: the call \`${cut(source.text)}(…)\` cannot be followed (${source.reason})`
|
|
162
165
|
: `not checked: what \`${cut(source.text)}\` throws is not known (${source.reason}), so \`@throws\` of \`${cut(name)}\` cannot be checked`),
|
|
163
|
-
hint: fitted((cut) =>
|
|
166
|
+
hint: fitted((cut) => source.fact?.kind === "untyped"
|
|
167
|
+
? `import the module with \`import … from\`, so its types load and the call can be named in \`facts\`; then \`${cut(name)}\`'s tag can be checked`
|
|
168
|
+
: `call the function itself, or state what it throws with \`@throws\` on it or \`facts\`, so \`${cut(name)}\`'s tag can be checked`),
|
|
164
169
|
location: locationOf(source.file, [source.start, source.end]),
|
|
165
170
|
against,
|
|
171
|
+
...decidingFacts([source]),
|
|
166
172
|
});
|
|
167
173
|
}
|
|
168
174
|
const missing = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stateward/plugin-errors",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "stateward rules for errors: errors are handled where they can happen.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"!dist/**/*.tsbuildinfo"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@stateward/core": "1.
|
|
35
|
+
"@stateward/core": "1.3.0"
|
|
36
36
|
}
|
|
37
37
|
}
|