Turn on promise-function-async and init-declarations and satisfy them with async functions and null-initialized lets

This commit is contained in:
Danny Kim
2026-10-19 19:44:35 +09:00
parent a65bf353ab
commit d879b04e46
14 changed files with 147 additions and 99 deletions
+9 -7
View File
@@ -121,7 +121,7 @@ async function readAgentArtifact(
if (profile === undefined) {
throw new Error(`${name}: outside profile home`);
}
let stat: Stats;
let stat: Stats | null = null;
try {
stat = await lstat(path);
} catch (error) {
@@ -152,7 +152,7 @@ export async function postRuntime(
const reviewerText = await readFile(manifest.reviewerFile, "utf8");
const reviewerToken = reviewerText.trim();
const request = async (path: string, body: unknown): Promise<void> => {
let response: Response;
let response: Response | null = null;
try {
response = await fetcher(`${context.apiUrl}/${path}`, {
method: "POST",
@@ -170,12 +170,13 @@ export async function postRuntime(
throw new GiteaRequestError(`${path}: ${response.status} ${await response.text()}`);
}
};
const postComment = (body: string): Promise<void> =>
request(`repos/${context.repository}/issues/${context.issueIndex}/comments`, {
const postComment = async (body: string): Promise<void> => {
await request(`repos/${context.repository}/issues/${context.issueIndex}/comments`, {
body: stripAnsi(body),
});
};
let outcome: RuntimeOutcome;
let outcome: RuntimeOutcome | null = null;
try {
outcome = await readOutcome(manifest.outcomeFile);
} catch (error) {
@@ -201,8 +202,8 @@ export async function postRuntime(
const [event, mark] = VERDICTS.get(verdict.trim()) ?? ["COMMENT", "💬"];
const anchorText = await readAgentArtifact(manifest, outcome.anchorsPath, "anchors.json");
const anchors = anchorText === null ? [] : parseAnchors(anchorText, outcome.anchorsPath);
const postReview = (entries: Anchor[]): Promise<void> =>
request(`repos/${context.repository}/pulls/${context.issueIndex}/reviews`, {
const postReview = async (entries: Anchor[]): Promise<void> => {
await request(`repos/${context.repository}/pulls/${context.issueIndex}/reviews`, {
body: stripAnsi(
withProfile([`${mark} ${verdict.trim()}`, ...rest].join("\n"), outcome.profile),
),
@@ -214,6 +215,7 @@ export async function postRuntime(
old_position: side === "old" ? line : 0,
})),
});
};
await postReview(anchors).catch(async (error: unknown) => {
if (anchors.length === 0) {
throw error;