mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-09 02:02:55 +00:00
chore(lint): enable stricter error rules
This commit is contained in:
@@ -240,9 +240,16 @@ snapshots:
|
||||
fetchImpl: ((_url, init) => {
|
||||
signal = init?.signal ?? undefined;
|
||||
return new Promise((_resolve, reject) => {
|
||||
signal?.addEventListener("abort", () => reject(signal?.reason ?? new Error("aborted")), {
|
||||
once: true,
|
||||
});
|
||||
signal?.addEventListener(
|
||||
"abort",
|
||||
() =>
|
||||
reject(
|
||||
toLintErrorObject(signal?.reason ?? new Error("aborted"), "Non-Error rejection"),
|
||||
),
|
||||
{
|
||||
once: true,
|
||||
},
|
||||
);
|
||||
});
|
||||
}) as typeof fetch,
|
||||
});
|
||||
@@ -339,3 +346,17 @@ snapshots:
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function toLintErrorObject(value: unknown, fallbackMessage: string): Error {
|
||||
if (value instanceof Error) {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return new Error(value);
|
||||
}
|
||||
const error = new Error(fallbackMessage, { cause: value });
|
||||
if ((typeof value === "object" && value !== null) || typeof value === "function") {
|
||||
Object.assign(error, value);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,9 @@ describe("real-behavior-proof-check GitHub lookups", () => {
|
||||
it("aborts stalled proof comment fetches", async () => {
|
||||
const fetch = vi.fn((_url: URL, init: RequestInit) => {
|
||||
return new Promise((_resolve, reject) => {
|
||||
init.signal?.addEventListener("abort", () => reject(init.signal?.reason));
|
||||
init.signal?.addEventListener("abort", () =>
|
||||
reject(toLintErrorObject(init.signal?.reason, "Non-Error rejection")),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -177,3 +179,17 @@ describe("real-behavior-proof-check GitHub lookups", () => {
|
||||
).toEqual(["100:1", "1:1", "1:2", "1:3"]);
|
||||
});
|
||||
});
|
||||
|
||||
function toLintErrorObject(value: unknown, fallbackMessage: string): Error {
|
||||
if (value instanceof Error) {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return new Error(value);
|
||||
}
|
||||
const error = new Error(fallbackMessage, { cause: value });
|
||||
if ((typeof value === "object" && value !== null) || typeof value === "function") {
|
||||
Object.assign(error, value);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -309,27 +309,24 @@ describe("real-behavior-proof-policy", () => {
|
||||
"did not test.",
|
||||
"could not test",
|
||||
"could not test.",
|
||||
])(
|
||||
"fails external PRs with fenced missing-proof field values: %s",
|
||||
(missingProof) => {
|
||||
const evidence = [
|
||||
"Terminal transcript:",
|
||||
"```text",
|
||||
"$ openclaw gateway status",
|
||||
"discord ready",
|
||||
"```",
|
||||
].join("\n");
|
||||
const notTested = ["```text", missingProof, "```"].join("\n");
|
||||
])("fails external PRs with fenced missing-proof field values: %s", (missingProof) => {
|
||||
const evidence = [
|
||||
"Terminal transcript:",
|
||||
"```text",
|
||||
"$ openclaw gateway status",
|
||||
"discord ready",
|
||||
"```",
|
||||
].join("\n");
|
||||
const notTested = ["```text", missingProof, "```"].join("\n");
|
||||
|
||||
const evaluation = evaluateRealBehaviorProof({
|
||||
pullRequest: externalPr(proofBody(evidence, { notTested })),
|
||||
});
|
||||
const evaluation = evaluateRealBehaviorProof({
|
||||
pullRequest: externalPr(proofBody(evidence, { notTested })),
|
||||
});
|
||||
|
||||
expect(evaluation.status).toBe("missing");
|
||||
expect(evaluation.missingFields).toEqual(["notTested"]);
|
||||
expect(labelsForRealBehaviorProof(evaluation)).toEqual([NEEDS_REAL_BEHAVIOR_PROOF_LABEL]);
|
||||
},
|
||||
);
|
||||
expect(evaluation.status).toBe("missing");
|
||||
expect(evaluation.missingFields).toEqual(["notTested"]);
|
||||
expect(labelsForRealBehaviorProof(evaluation)).toEqual([NEEDS_REAL_BEHAVIOR_PROOF_LABEL]);
|
||||
});
|
||||
|
||||
it("fails external PRs whose proof is only tests, mocks, snapshots, lint, typecheck, or CI", () => {
|
||||
const evaluation = evaluateRealBehaviorProof({
|
||||
@@ -580,7 +577,9 @@ describe("isMaintainerTeamMember", () => {
|
||||
it("aborts stalled membership fetches", async () => {
|
||||
const fetch = vi.fn((_url: string, init: RequestInit) => {
|
||||
return new Promise((_resolve, reject) => {
|
||||
init.signal?.addEventListener("abort", () => reject(init.signal?.reason));
|
||||
init.signal?.addEventListener("abort", () =>
|
||||
reject(toLintErrorObject(init.signal?.reason, "Non-Error rejection")),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -645,3 +644,17 @@ describe("readBoundedGitHubApiJson", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function toLintErrorObject(value: unknown, fallbackMessage: string): Error {
|
||||
if (value instanceof Error) {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return new Error(value);
|
||||
}
|
||||
const error = new Error(fallbackMessage, { cause: value });
|
||||
if ((typeof value === "object" && value !== null) || typeof value === "function") {
|
||||
Object.assign(error, value);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ describe("resolve-openclaw-package-candidate", () => {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
execFile("tar", ["-czf", tarball, "-C", dir, "package"], (error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
reject(toLintErrorObject(error, "Non-Error rejection"));
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
@@ -521,3 +521,17 @@ describe("resolve-openclaw-package-candidate", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function toLintErrorObject(value: unknown, fallbackMessage: string): Error {
|
||||
if (value instanceof Error) {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return new Error(value);
|
||||
}
|
||||
const error = new Error(fallbackMessage, { cause: value });
|
||||
if ((typeof value === "object" && value !== null) || typeof value === "function") {
|
||||
Object.assign(error, value);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user