Skip to content

Commit

Permalink
chore: fix eslint naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Jul 16, 2024
1 parent 29d4964 commit 5e76c45
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/handlers/shared/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.`);
}
}
}
12 changes: 7 additions & 5 deletions src/utils/issue.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -8,12 +8,14 @@ export function isParentIssue(body: string) {
}

export async function getAssignedIssues(context: Context, username: string): Promise<Issue[]> {
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 [];
Expand Down
20 changes: 10 additions & 10 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
},
},
},
}),
}),
}),
Expand Down

0 comments on commit 5e76c45

Please sign in to comment.