@ttsc/lint 0.23.0 → 0.25.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 +4 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +161 -46
- package/lib/index.js.map +1 -1
- package/lib/internal/configEvaluatorFailure.d.ts +24 -20
- package/lib/internal/configEvaluatorFailure.js +41 -54
- package/lib/internal/configEvaluatorFailure.js.map +1 -1
- package/linthost/config.go +317 -78
- package/linthost/fix.go +7 -1
- package/linthost/format.go +3 -1
- package/linthost/host.go +187 -14
- package/linthost/lsp.go +5 -1
- package/package.json +2 -2
- package/rule/project.go +12 -1
- package/src/index.ts +163 -53
- package/src/internal/configEvaluatorFailure.ts +35 -64
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
export declare const CONFIG_EVALUATOR_MAX_BUFFER: number;
|
|
2
|
-
export declare const CONFIG_EVALUATOR_TIMEOUT_MS = 60000;
|
|
3
|
-
export declare const CONFIG_EVALUATOR_TEARDOWN_GRACE_MS = 5000;
|
|
4
|
-
export declare const CONFIG_EVALUATOR_STATUS_FD = 3;
|
|
5
|
-
export declare const CONFIG_EVALUATOR_PROCESS_OPTIONS: Readonly<{
|
|
6
|
-
killSignal: "SIGKILL";
|
|
7
|
-
maxBuffer: number;
|
|
8
|
-
timeout: number;
|
|
9
|
-
}>;
|
|
10
1
|
interface ConfigEvaluatorProcessResult {
|
|
11
2
|
error?: Error;
|
|
12
|
-
output?: readonly (string | null)[] | null;
|
|
13
3
|
signal: NodeJS.Signals | null;
|
|
14
4
|
status: number | null;
|
|
15
|
-
stderr: string | null | undefined;
|
|
16
5
|
}
|
|
17
6
|
/**
|
|
18
7
|
* Classify the ways the isolated lint-config evaluator can stop.
|
|
19
8
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
9
|
+
* The evaluator writes the child's own output straight to this process's
|
|
10
|
+
* stderr, so a diagnostic has already reached the user by the time anything
|
|
11
|
+
* here runs. What is left to say is only how the process ended: it never
|
|
12
|
+
* launched, something outside killed it, or it exited non-zero after printing
|
|
13
|
+
* its own reason.
|
|
14
|
+
*
|
|
15
|
+
* Nothing is bounded here — not time, not output. Both were the compiler
|
|
16
|
+
* deciding, on numbers nobody chose for this machine, that a user's own config
|
|
17
|
+
* had run too long or said too much. A slow config is a slow build the user can
|
|
18
|
+
* watch and interrupt; a loud one is output they asked for. Neither is this
|
|
19
|
+
* process's memory to spend either, because the child's streams are no longer
|
|
20
|
+
* collected into it.
|
|
26
21
|
*/
|
|
27
22
|
export declare function configEvaluatorProcessFailure(result: ConfigEvaluatorProcessResult, configPath: string): Error | undefined;
|
|
28
23
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
24
|
+
* Read the failure envelope the evaluator writes to its result file when it
|
|
25
|
+
* stops on an error it can name.
|
|
26
|
+
*
|
|
27
|
+
* This is the other half of classifying how the evaluation ended, which is why
|
|
28
|
+
* it lives beside {@link configEvaluatorProcessFailure} rather than at the call
|
|
29
|
+
* site: the status says that it failed, and this says why.
|
|
30
|
+
*
|
|
31
|
+
* Only a well-formed envelope is honoured. A real evaluation payload never
|
|
32
|
+
* carries this key, and every other shape — an absent file, a build that failed
|
|
33
|
+
* before the loader ran, a half-written result, a payload written before a
|
|
34
|
+
* later non-zero exit — leaves the process status to speak for itself.
|
|
31
35
|
*/
|
|
32
|
-
export declare function
|
|
36
|
+
export declare function configEvaluatorFailureReason(outputPath: string): string;
|
|
33
37
|
export {};
|
|
@@ -1,40 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONFIG_EVALUATOR_PROCESS_OPTIONS = exports.CONFIG_EVALUATOR_STATUS_FD = exports.CONFIG_EVALUATOR_TEARDOWN_GRACE_MS = exports.CONFIG_EVALUATOR_TIMEOUT_MS = exports.CONFIG_EVALUATOR_MAX_BUFFER = void 0;
|
|
4
6
|
exports.configEvaluatorProcessFailure = configEvaluatorProcessFailure;
|
|
5
|
-
exports.
|
|
6
|
-
|
|
7
|
-
exports.CONFIG_EVALUATOR_TIMEOUT_MS = 60_000;
|
|
8
|
-
exports.CONFIG_EVALUATOR_TEARDOWN_GRACE_MS = 5_000;
|
|
9
|
-
exports.CONFIG_EVALUATOR_STATUS_FD = 3;
|
|
10
|
-
exports.CONFIG_EVALUATOR_PROCESS_OPTIONS = Object.freeze({
|
|
11
|
-
killSignal: "SIGKILL",
|
|
12
|
-
maxBuffer: exports.CONFIG_EVALUATOR_MAX_BUFFER,
|
|
13
|
-
timeout: exports.CONFIG_EVALUATOR_TIMEOUT_MS + exports.CONFIG_EVALUATOR_TEARDOWN_GRACE_MS,
|
|
14
|
-
});
|
|
7
|
+
exports.configEvaluatorFailureReason = configEvaluatorFailureReason;
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
15
9
|
/**
|
|
16
10
|
* Classify the ways the isolated lint-config evaluator can stop.
|
|
17
11
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
12
|
+
* The evaluator writes the child's own output straight to this process's
|
|
13
|
+
* stderr, so a diagnostic has already reached the user by the time anything
|
|
14
|
+
* here runs. What is left to say is only how the process ended: it never
|
|
15
|
+
* launched, something outside killed it, or it exited non-zero after printing
|
|
16
|
+
* its own reason.
|
|
17
|
+
*
|
|
18
|
+
* Nothing is bounded here — not time, not output. Both were the compiler
|
|
19
|
+
* deciding, on numbers nobody chose for this machine, that a user's own config
|
|
20
|
+
* had run too long or said too much. A slow config is a slow build the user can
|
|
21
|
+
* watch and interrupt; a loud one is output they asked for. Neither is this
|
|
22
|
+
* process's memory to spend either, because the child's streams are no longer
|
|
23
|
+
* collected into it.
|
|
24
24
|
*/
|
|
25
25
|
function configEvaluatorProcessFailure(result, configPath) {
|
|
26
|
-
const code = result.error?.code;
|
|
27
|
-
const nestedCode = result.output?.[exports.CONFIG_EVALUATOR_STATUS_FD]?.trim() ?? "";
|
|
28
|
-
if (code === "ETIMEDOUT" || nestedCode === "ETIMEDOUT") {
|
|
29
|
-
return new Error(`@ttsc/lint: ttsx evaluation of ${configPath} timed out after ` +
|
|
30
|
-
`${exports.CONFIG_EVALUATOR_TIMEOUT_MS / 1_000} seconds. ` +
|
|
31
|
-
"Simplify the config or move heavy work out of top-level.");
|
|
32
|
-
}
|
|
33
|
-
if (code === "ENOBUFS" || nestedCode === "ENOBUFS") {
|
|
34
|
-
return new Error(`@ttsc/lint: ttsx evaluation of ${configPath} exceeded the ` +
|
|
35
|
-
`${exports.CONFIG_EVALUATOR_MAX_BUFFER / (1024 * 1024)} MiB output limit. ` +
|
|
36
|
-
"Reduce console output from the config and its dependencies.");
|
|
37
|
-
}
|
|
38
26
|
if (result.error) {
|
|
39
27
|
return new Error(`@ttsc/lint: failed to spawn ttsx for ${configPath}: ${result.error.message}`);
|
|
40
28
|
}
|
|
@@ -42,35 +30,34 @@ function configEvaluatorProcessFailure(result, configPath) {
|
|
|
42
30
|
return new Error(`@ttsc/lint: ttsx evaluation of ${configPath} was killed by signal ${result.signal}.`);
|
|
43
31
|
}
|
|
44
32
|
if (result.status !== 0) {
|
|
45
|
-
|
|
46
|
-
return new Error(`@ttsc/lint: lint config ${configPath} evaluation failed with exit code ${String(result.status)}` +
|
|
47
|
-
(reason === "" ? "" : "\n" + reason));
|
|
33
|
+
return new Error(`@ttsc/lint: lint config ${configPath} evaluation failed with exit code ${String(result.status)}`);
|
|
48
34
|
}
|
|
49
35
|
return undefined;
|
|
50
36
|
}
|
|
51
37
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* Return the useful tail of evaluator stderr without turning an exception into
|
|
64
|
-
* an unbounded duplicate of the already-forwarded child stream.
|
|
38
|
+
* Read the failure envelope the evaluator writes to its result file when it
|
|
39
|
+
* stops on an error it can name.
|
|
40
|
+
*
|
|
41
|
+
* This is the other half of classifying how the evaluation ended, which is why
|
|
42
|
+
* it lives beside {@link configEvaluatorProcessFailure} rather than at the call
|
|
43
|
+
* site: the status says that it failed, and this says why.
|
|
44
|
+
*
|
|
45
|
+
* Only a well-formed envelope is honoured. A real evaluation payload never
|
|
46
|
+
* carries this key, and every other shape — an absent file, a build that failed
|
|
47
|
+
* before the loader ran, a half-written result, a payload written before a
|
|
48
|
+
* later non-zero exit — leaves the process status to speak for itself.
|
|
65
49
|
*/
|
|
66
|
-
function configEvaluatorFailureReason(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
50
|
+
function configEvaluatorFailureReason(outputPath) {
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(node_fs_1.default.readFileSync(outputPath, "utf8"));
|
|
53
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
54
|
+
return "";
|
|
55
|
+
const message = parsed
|
|
56
|
+
.__ttscLoaderError;
|
|
57
|
+
return typeof message === "string" ? message.trim() : "";
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
73
62
|
}
|
|
74
|
-
const CONFIG_EVALUATOR_REASON_LINES = 5;
|
|
75
|
-
const CONFIG_EVALUATOR_REASON_MAX_CHARS = 8 * 1024;
|
|
76
63
|
//# sourceMappingURL=configEvaluatorFailure.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configEvaluatorFailure.js","sourceRoot":"","sources":["../../src/internal/configEvaluatorFailure.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configEvaluatorFailure.js","sourceRoot":"","sources":["../../src/internal/configEvaluatorFailure.ts"],"names":[],"mappings":";;;;;;;AAAA,sDAAyB;AAQzB;;;;;;;;;;;;;;;GAeG;AACH,uCACE,MAAoC,EACpC,UAAkB;IAElB,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,IAAI,KAAK,CACd,wCAAwC,UAAU,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAC9E,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,IAAI,KAAK,CACd,kCAAkC,UAAU,yBAAyB,MAAM,CAAC,MAAM,GAAG,CACtF,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,KAAK,CACd,2BAA2B,UAAU,qCAAqC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAClG,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,sCAA6C,UAAkB;IAC7D,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QACxE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QAC7D,MAAM,OAAO,GAAI,MAA0C;aACxD,iBAAiB,CAAC;QACrB,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|