chore: fix lint errors; tweak lint rules
This commit is contained in:
parent
9b3d6f5d68
commit
5f194bf1ef
115 changed files with 176 additions and 264 deletions
|
@ -1,6 +1,6 @@
|
|||
import { BaseRepository } from "./BaseRepository";
|
||||
|
||||
export class BaseGuildRepository<TEntity extends unknown = unknown> extends BaseRepository<TEntity> {
|
||||
export class BaseGuildRepository<TEntity = unknown> extends BaseRepository<TEntity> {
|
||||
private static guildInstances: Map<string, any>;
|
||||
|
||||
protected guildId: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { asyncMap } from "../utils/async";
|
||||
|
||||
export class BaseRepository<TEntity extends unknown = unknown> {
|
||||
export class BaseRepository<TEntity = unknown> {
|
||||
private nextRelations: string[];
|
||||
|
||||
constructor() {
|
||||
|
|
|
@ -6,15 +6,16 @@ import { cleanupConfigs } from "./cleanup/configs";
|
|||
import { connection } from "./db";
|
||||
import { Config } from "./entities/Config";
|
||||
|
||||
const CLEANUP_INTERVAL = 1 * HOURS;
|
||||
|
||||
async function cleanup() {
|
||||
await cleanupConfigs();
|
||||
setTimeout(cleanup, CLEANUP_INTERVAL);
|
||||
}
|
||||
|
||||
if (isAPI()) {
|
||||
const CLEANUP_INTERVAL = 1 * HOURS;
|
||||
|
||||
async function cleanup() {
|
||||
await cleanupConfigs();
|
||||
setTimeout(cleanup, CLEANUP_INTERVAL);
|
||||
}
|
||||
|
||||
// Start first cleanup 30 seconds after startup
|
||||
// TODO: Move to bot startup code
|
||||
setTimeout(cleanup, 30 * SECONDS);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@ import { connection } from "./db";
|
|||
import { Case } from "./entities/Case";
|
||||
import { CaseNote } from "./entities/CaseNote";
|
||||
|
||||
const CASE_SUMMARY_REASON_MAX_LENGTH = 300;
|
||||
|
||||
export class GuildCases extends BaseGuildRepository {
|
||||
private cases: Repository<Case>;
|
||||
private caseNotes: Repository<CaseNote>;
|
||||
|
|
|
@ -5,15 +5,16 @@ import { BaseGuildRepository } from "./BaseGuildRepository";
|
|||
import { cleanupNicknames } from "./cleanup/nicknames";
|
||||
import { NicknameHistoryEntry } from "./entities/NicknameHistoryEntry";
|
||||
|
||||
const CLEANUP_INTERVAL = 5 * MINUTES;
|
||||
|
||||
async function cleanup() {
|
||||
await cleanupNicknames();
|
||||
setTimeout(cleanup, CLEANUP_INTERVAL);
|
||||
}
|
||||
|
||||
if (!isAPI()) {
|
||||
const CLEANUP_INTERVAL = 5 * MINUTES;
|
||||
|
||||
async function cleanup() {
|
||||
await cleanupNicknames();
|
||||
setTimeout(cleanup, CLEANUP_INTERVAL);
|
||||
}
|
||||
|
||||
// Start first cleanup 30 seconds after startup
|
||||
// TODO: Move to bot startup code
|
||||
setTimeout(cleanup, 30 * SECONDS);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ export class GuildSavedMessages extends BaseGuildRepository<SavedMessage> {
|
|||
return entity;
|
||||
}
|
||||
|
||||
entity.data = await decryptJson(entity.data as unknown as string);
|
||||
entity.data = (await decryptJson(entity.data as unknown as string)) as ISavedMessageData;
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,15 +5,16 @@ import { BaseRepository } from "./BaseRepository";
|
|||
import { cleanupUsernames } from "./cleanup/usernames";
|
||||
import { UsernameHistoryEntry } from "./entities/UsernameHistoryEntry";
|
||||
|
||||
const CLEANUP_INTERVAL = 5 * MINUTES;
|
||||
|
||||
async function cleanup() {
|
||||
await cleanupUsernames();
|
||||
setTimeout(cleanup, CLEANUP_INTERVAL);
|
||||
}
|
||||
|
||||
if (!isAPI()) {
|
||||
const CLEANUP_INTERVAL = 5 * MINUTES;
|
||||
|
||||
async function cleanup() {
|
||||
await cleanupUsernames();
|
||||
setTimeout(cleanup, CLEANUP_INTERVAL);
|
||||
}
|
||||
|
||||
// Start first cleanup 30 seconds after startup
|
||||
// TODO: Move to bot startup code
|
||||
setTimeout(cleanup, 30 * SECONDS);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@ export type RemoveApiPermissionEventData = {
|
|||
target_id: string;
|
||||
};
|
||||
|
||||
export type EditConfigEventData = {};
|
||||
|
||||
export interface AuditLogEventData extends Record<AuditLogEventType, unknown> {
|
||||
ADD_API_PERMISSION: {
|
||||
type: ApiPermissionTypes;
|
||||
|
@ -41,7 +39,7 @@ export interface AuditLogEventData extends Record<AuditLogEventType, unknown> {
|
|||
target_id: string;
|
||||
};
|
||||
|
||||
EDIT_CONFIG: {};
|
||||
EDIT_CONFIG: Record<string, never>;
|
||||
}
|
||||
|
||||
export type AnyAuditLogEventData = AuditLogEventData[AuditLogEventType];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export function buildEntity<T extends any>(Entity: new () => T, data: Partial<T>): T {
|
||||
export function buildEntity<T extends object>(Entity: new () => T, data: Partial<T>): T {
|
||||
const instance = new Entity();
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
instance[key] = value;
|
||||
|
|
|
@ -5,6 +5,7 @@ import { backendDir } from "../paths";
|
|||
import { QueryLogger } from "./queryLogger";
|
||||
|
||||
const ormconfigPath = path.join(backendDir, "ormconfig.js");
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const connectionOptions = require(ormconfigPath);
|
||||
|
||||
let connectionPromise: Promise<Connection>;
|
||||
|
|
|
@ -19,7 +19,7 @@ export class ApiLogin {
|
|||
@Column()
|
||||
expires_at: string;
|
||||
|
||||
@ManyToOne((type) => ApiUserInfo, (userInfo) => userInfo.logins)
|
||||
@ManyToOne(() => ApiUserInfo, (userInfo) => userInfo.logins)
|
||||
@JoinColumn({ name: "user_id" })
|
||||
userInfo: ApiUserInfo;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export class ApiPermissionAssignment {
|
|||
@Column({ type: String, nullable: true })
|
||||
expires_at: string | null;
|
||||
|
||||
@ManyToOne((type) => ApiUserInfo, (userInfo) => userInfo.permissionAssignments)
|
||||
@ManyToOne(() => ApiUserInfo, (userInfo) => userInfo.permissionAssignments)
|
||||
@JoinColumn({ name: "target_id" })
|
||||
userInfo: ApiUserInfo;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ export class ApiUserInfo {
|
|||
@Column()
|
||||
updated_at: string;
|
||||
|
||||
@OneToMany((type) => ApiLogin, (login) => login.userInfo)
|
||||
@OneToMany(() => ApiLogin, (login) => login.userInfo)
|
||||
logins: ApiLogin[];
|
||||
|
||||
@OneToMany((type) => ApiPermissionAssignment, (p) => p.userInfo)
|
||||
@OneToMany(() => ApiPermissionAssignment, (p) => p.userInfo)
|
||||
permissionAssignments: ApiPermissionAssignment[];
|
||||
}
|
||||
|
|
|
@ -35,6 +35,6 @@ export class Case {
|
|||
*/
|
||||
@Column({ type: String, nullable: true }) log_message_id: string | null;
|
||||
|
||||
@OneToMany((type) => CaseNote, (note) => note.case)
|
||||
@OneToMany(() => CaseNote, (note) => note.case)
|
||||
notes: CaseNote[];
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ export class CaseNote {
|
|||
|
||||
@Column() created_at: string;
|
||||
|
||||
@ManyToOne((type) => Case, (theCase) => theCase.notes)
|
||||
@ManyToOne(() => Case, (theCase) => theCase.notes)
|
||||
@JoinColumn({ name: "case_id" })
|
||||
case: Case;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export class Config {
|
|||
@Column()
|
||||
edited_at: string;
|
||||
|
||||
@ManyToOne((type) => ApiUserInfo)
|
||||
@ManyToOne(() => ApiUserInfo)
|
||||
@JoinColumn({ name: "edited_by" })
|
||||
userInfo: ApiUserInfo;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export class StarboardMessage {
|
|||
@Column()
|
||||
guild_id: string;
|
||||
|
||||
@OneToOne((type) => SavedMessage)
|
||||
@OneToOne(() => SavedMessage)
|
||||
@JoinColumn({ name: "message_id" })
|
||||
message: SavedMessage;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export class StarboardReaction {
|
|||
@Column()
|
||||
reactor_id: string;
|
||||
|
||||
@OneToOne((type) => SavedMessage)
|
||||
@OneToOne(() => SavedMessage)
|
||||
@JoinColumn({ name: "message_id" })
|
||||
message: SavedMessage;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import type { QueryRunner } from "typeorm";
|
||||
import { AdvancedConsoleLogger } from "typeorm/logger/AdvancedConsoleLogger";
|
||||
|
||||
let groupedQueryStats: Map<string, number> = new Map();
|
||||
|
@ -9,7 +8,7 @@ const deleteTableRegex = /FROM `?([^\s`]+)/;
|
|||
const insertTableRegex = /INTO `?([^\s`]+)/;
|
||||
|
||||
export class QueryLogger extends AdvancedConsoleLogger {
|
||||
logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner): any {
|
||||
logQuery(query: string): any {
|
||||
let type: string | undefined;
|
||||
let table: string | undefined;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue