diff --git a/src/handlers/shared/start.ts b/src/handlers/shared/start.ts index 03a78033..4caf110e 100644 --- a/src/handlers/shared/start.ts +++ b/src/handlers/shared/start.ts @@ -39,16 +39,16 @@ export async function start(context: Context, issue: Context["payload"]["issue"] throw new Error("Issue is closed"); } - const assignees = issue?.assignees ?? [] + const assignees = issue?.assignees ?? []; if (assignees.length !== 0) { - const currentUserAssigned = !!assignees.find((assignee) => assignee?.login === sender.login); - const comment = currentUserAssigned ? "You are already assigned to this task." : "The issue is already assigned. Please choose another unassigned task."; + const isCurrentUserAssigned = !!assignees.find((assignee) => assignee?.login === sender.login); + const comment = isCurrentUserAssigned ? "You are already assigned to this task." : "The issue is already assigned. Please choose another unassigned task."; await addCommentToIssue(context, `\`\`\`diff\n! ${comment}`); throw new Error(comment); } - teammates.push(sender.login) + teammates.push(sender.login); // check max assigned issues for (const user of teammates) { @@ -116,4 +116,4 @@ async function handleTaskLimitChecks(username: string, context: Context, maxConc await addCommentToIssue(context, `\`\`\`diff\n! ${comment}\n\`\`\``); throw new Error(`Too many assigned issues, you have reached your max limit of ${maxConcurrentTasks} issues.`); } -} \ No newline at end of file +} diff --git a/src/utils/issue.ts b/src/utils/issue.ts index 7cb8785e..6eb3cd19 100644 --- a/src/utils/issue.ts +++ b/src/utils/issue.ts @@ -1,5 +1,5 @@ import { Context } from "../types/context"; -import { Issue, ISSUE_TYPE } from "../types/payload"; +import { Issue } from "../types/payload"; import { getLinkedPullRequests, GetLinkedResults } from "./get-linked-prs"; export function isParentIssue(body: string) { @@ -8,12 +8,14 @@ export function isParentIssue(body: string) { } export async function getAssignedIssues(context: Context, username: string): Promise { - const { payload } = context + const { payload } = context; try { - return await context.octokit.search.issuesAndPullRequests({ - q: `is:open assignee:${username} org:${payload.repository.owner.login}`, - }).then((response) => response.data.items) as Issue[]; + return (await context.octokit.search + .issuesAndPullRequests({ + q: `is:open assignee:${username} org:${payload.repository.owner.login}`, + }) + .then((response) => response.data.items)) as Issue[]; } catch (err: unknown) { context.logger.error("Fetching assigned issues failed!", { error: err as Error }); return []; diff --git a/tests/main.test.ts b/tests/main.test.ts index 8975036f..08a711cc 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -86,7 +86,7 @@ describe("User start/stop", () => { }); test("Stopping an issue should close the author's linked PR", async () => { - const infoSpy = jest.spyOn(console, "info").mockImplementation(() => { }); + const infoSpy = jest.spyOn(console, "info").mockImplementation(() => {}); // using the second issue const issue = db.issue.findFirst({ where: { id: { equals: 2 } } }) as unknown as Issue; const sender = db.users.findFirst({ where: { id: { equals: 2 } } }) as unknown as Sender; @@ -587,17 +587,17 @@ function getSupabase(withData = true) { single: jest.fn().mockResolvedValue({ data: withData ? { - id: 1, - wallets: { - address: "0x123", - }, - } + id: 1, + wallets: { + address: "0x123", + }, + } : { - id: 1, - wallets: { - address: undefined, + id: 1, + wallets: { + address: undefined, + }, }, - }, }), }), }),