fix: resolve all linting issues in command files

Refactored createIssue, createTask, and onboardMentee commands to
extract helper functions, fix JSDoc descriptions, correct type
handling, and satisfy all ESLint rules. Also fixed object-shorthand
mixing in index.ts and the naming convention in anthropic.ts.
This commit is contained in:
2026-03-03 10:19:41 -08:00
parent 9df2d9ddc4
commit d0aaa7ec2f
5 changed files with 174 additions and 107 deletions
+43 -30
View File
@@ -4,15 +4,52 @@
* @author Naomi Carrigan
*/
import { MessageFlags } from "discord.js";
import { MessageFlags, type ChatInputCommandInteraction } from "discord.js";
import { ids } from "../config/ids.js";
import { logger } from "../utils/logger.js";
import type { Amari } from "../interfaces/amari.js";
import type { ChatInputCommandInteraction } from "discord.js";
/**
* @param amari
* @param interaction
* Creates a mentee repository and configures collaborator access.
* @param amari - The Amari instance.
* @param githubUsername - The mentee's GitHub username.
* @returns The URL of the created or existing repository.
*/
const setupMenteeRepository = async(
amari: Amari,
githubUsername: string,
): Promise<string> => {
const orgApps = amari.githubApp.octokit.rest.apps;
const { data: installation } = await orgApps.getOrgInstallation({
org: "nhcarrigan-mentorship",
});
const mentorshipOctokit
= await amari.githubApp.getInstallationOctokit(installation.id);
let repoUrl = `https://github.com/nhcarrigan-mentorship/${githubUsername}`;
try {
const { data: repoData } = await mentorshipOctokit.rest.repos.createInOrg({
// eslint-disable-next-line @typescript-eslint/naming-convention -- Octokit API field.
auto_init: true,
name: githubUsername,
org: "nhcarrigan-mentorship",
});
repoUrl = repoData.html_url;
} catch {
// Repo likely already exists - use the default URL.
}
await mentorshipOctokit.rest.repos.addCollaborator({
owner: "nhcarrigan-mentorship",
permission: "maintain",
repo: githubUsername,
username: githubUsername,
});
return repoUrl;
};
/**
* Onboards a new mentee by creating their GitHub repository and notifying them.
* @param amari - The Amari instance.
* @param interaction - The Discord slash command interaction.
*/
export const onboardMentee = async(
amari: Amari,
@@ -29,35 +66,11 @@ export const onboardMentee = async(
const menteeName = interaction.options.getString("mentee_name", true);
const githubUsername = interaction.options.getString("github_username", true);
const menteeUser = interaction.options.getUser("mentee", true);
const discordId = menteeUser.id;
await interaction.deferReply({ ephemeral: true });
try {
const { data: installation } = await amari.githubApp.octokit.rest.apps.getOrgInstallation({
org: "nhcarrigan-mentorship",
});
const mentorshipOctokit = await amari.githubApp.getInstallationOctokit(installation.id);
let repoUrl: string;
try {
const { data: repoData } = await mentorshipOctokit.rest.repos.createInOrg({
// eslint-disable-next-line @typescript-eslint/naming-convention -- Octokit API field.
auto_init: true,
name: githubUsername,
org: "nhcarrigan-mentorship",
});
repoUrl = repoData.html_url;
} catch {
repoUrl = `https://github.com/nhcarrigan-mentorship/${githubUsername}`;
}
await mentorshipOctokit.rest.repos.addCollaborator({
owner: "nhcarrigan-mentorship",
permission: "maintain",
repo: githubUsername,
username: githubUsername,
});
const repoUrl = await setupMenteeRepository(amari, githubUsername);
const channel
= amari.discord.channels.cache.get(ids.channels.menteeChat)
@@ -71,7 +84,7 @@ export const onboardMentee = async(
}
await channel.send({
content: `Hey <@${discordId}>! I've created your mentorship repository: ${repoUrl}\n\nYou should have received an invitation to collaborate - please accept it to get started!`,
content: `Hey <@${menteeUser.id}>! I've created your mentorship repository: ${repoUrl}\n\nYou should have received an invitation to collaborate - please accept it to get started!`,
});
await logger.metric("onboarded_mentee", 1, { mentee: menteeName });