From 084dc0be08555891cad4c2bb984822a62ec5ec9f Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Fri, 20 Jan 2023 18:10:47 +1100 Subject: Add ESLint (#941) * Add eslint, switch to lint-staged for precommit * Fix all ESLint errors * Update GH workflow to check prettier and eslint --- src/util/entities/Member.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/util/entities/Member.ts') diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index 801b5738..c68fe215 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -33,7 +33,7 @@ import { RelationId, } from "typeorm"; import { Guild } from "./Guild"; -import { Config, emitEvent, FieldErrors } from "../util"; +import { Config, emitEvent } from "../util"; import { GuildCreateEvent, GuildDeleteEvent, @@ -212,12 +212,16 @@ export class Member extends BaseClassWithoutId { } static async addRole(user_id: string, guild_id: string, role_id: string) { - const [member, role] = await Promise.all([ + const [member] = await Promise.all([ Member.findOneOrFail({ where: { id: user_id, guild_id }, relations: ["user", "roles"], // we don't want to load the role objects just the ids - //@ts-ignore - select: ["index", "roles.id"], // TODO fix type + select: { + index: true, + roles: { + id: true, + }, + }, }), Role.findOneOrFail({ where: { id: role_id, guild_id }, @@ -249,8 +253,12 @@ export class Member extends BaseClassWithoutId { Member.findOneOrFail({ where: { id: user_id, guild_id }, relations: ["user", "roles"], // we don't want to load the role objects just the ids - //@ts-ignore - select: ["roles.id", "index"], // TODO: fix type + select: { + index: true, + roles: { + id: true, + }, + }, }), await Role.findOneOrFail({ where: { id: role_id, guild_id } }), ]); @@ -327,7 +335,7 @@ export class Member extends BaseClassWithoutId { guild_id, user: { sessions: { - status: Not("invisible" as "invisible"), // lol typescript? + status: Not("invisible" as const), // lol typescript? }, }, }, @@ -506,8 +514,7 @@ export const PublicMemberProjection: PublicMemberKeys[] = [ "premium_since", ]; -// @ts-ignore -export type PublicMember = Pick> & { +export type PublicMember = Omit, "roles"> & { user: PublicUser; roles: string[]; // only role ids not objects }; -- cgit 1.5.1