From a4913dc25ffc14994e25affdd1c2f48502805509 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 19 Apr 2026 21:54:08 +0200 Subject: [PATCH] eslint: more rules, no-duplicate-imports --- assets/openapi.json | Bin 968976 -> 968774 bytes assets/schemas.json | Bin 436389 -> 436219 bytes eslint.config.mjs | 6 ++++++ .../channels/#channel_id/attachments.ts | 3 +-- src/api/routes/guilds/#guild_id/bulk-ban.ts | 3 +-- src/cdn/routes/attachments.ts | 3 +-- src/gateway/opcodes/VoiceStateUpdate.ts | 3 +-- src/util/entities/Message.ts | 2 +- src/util/util/Event.ts | 6 ++---- src/util/util/Rights.ts | 3 +-- src/util/util/lambert-server/Server.ts | 3 +-- 11 files changed, 15 insertions(+), 17 deletions(-) diff --git a/assets/openapi.json b/assets/openapi.json index 89e190bbe01f4505ee68c0d586a0af403e16b80b..178e208afdb45d913060e9bd74ea2c280a003e8d 100644 GIT binary patch delta 92 zcmbO*$@xLG_EljCG(;K9jb*BeJGIMPIEyPsI1mcTM-=NGa)h-~$1jNih%mT!$ eK+Fcj>_E%`#GF9P1;pGy%mc){%LT;vHUj|8_7>;> delta 139 zcmX>$!Fs|Z>xLG_EljCG(*>kigr+BaV&5;03FYRbiB$uJ6ZWG~HnVtJGu%eu?P@Of2l}siI6k%nZaVK+FonY(NYW=Kx|( VAm##MZXo6XV&3hkqI?fG0RU;gC=37q diff --git a/assets/schemas.json b/assets/schemas.json index 56f784901bf713727e0cb3c83c086a30f1867e3d..65b6edba7dca91247d894dbde5a898a578517213 100644 GIT binary patch delta 68 zcmZ2_QR?@3sfI0#w#QkLGSf4sA539Vp1weck#+m7* RnShuXh*`FqonpWhue-8kH CA}weD diff --git a/eslint.config.mjs b/eslint.config.mjs index b52ab1f7c..cc1cb8313 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -48,6 +48,12 @@ export default defineConfig([ "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-deprecated": "warn", "array-callback-return": "error", + "no-constructor-return": "error", + "no-duplicate-imports": "error", + // unsure what the defaults are here, but we want them to error + "for-direction": "error", + "constructor-super": "error", + "getter-return": "error", "no-restricted-imports": [ "error", { name: "@spacebar/api*", message: "Did you mean @spacebar/api?" }, diff --git a/src/api/routes/channels/#channel_id/attachments.ts b/src/api/routes/channels/#channel_id/attachments.ts index 0e595ccc5..7e59c0a69 100644 --- a/src/api/routes/channels/#channel_id/attachments.ts +++ b/src/api/routes/channels/#channel_id/attachments.ts @@ -17,9 +17,8 @@ */ import { randomString, route } from "@spacebar/api"; -import { Channel, Config, Permissions } from "@spacebar/util"; +import { CloudAttachment, Channel, Config, Permissions } from "@spacebar/util"; import { Request, Response, Router } from "express"; -import { CloudAttachment } from "@spacebar/util"; import { UploadAttachmentRequestSchema, UploadAttachmentResponseSchema } from "@spacebar/schemas"; const router: Router = Router({ mergeParams: true }); diff --git a/src/api/routes/guilds/#guild_id/bulk-ban.ts b/src/api/routes/guilds/#guild_id/bulk-ban.ts index 6b25acebb..1831deb5a 100644 --- a/src/api/routes/guilds/#guild_id/bulk-ban.ts +++ b/src/api/routes/guilds/#guild_id/bulk-ban.ts @@ -17,10 +17,9 @@ */ import { route } from "@spacebar/api"; -import { Ban, DiscordApiErrors, GuildBanAddEvent, Member, User, emitEvent } from "@spacebar/util"; +import { Ban, Config, DiscordApiErrors, GuildBanAddEvent, Member, User, emitEvent } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; -import { Config } from "@spacebar/util"; const router: Router = Router({ mergeParams: true }); diff --git a/src/cdn/routes/attachments.ts b/src/cdn/routes/attachments.ts index 054089c51..39980db38 100644 --- a/src/cdn/routes/attachments.ts +++ b/src/cdn/routes/attachments.ts @@ -16,13 +16,12 @@ along with this program. If not, see . */ -import { Config, hasValidSignature, NewUrlUserSignatureData, Snowflake, UrlSignResult } from "@spacebar/util"; +import { Config, CloudAttachment, hasValidSignature, NewUrlUserSignatureData, Snowflake, UrlSignResult } from "@spacebar/util"; import { Request, Response, Router } from "express"; import imageSize from "image-size"; import { HTTPError } from "lambert-server"; import { multer } from "../util/multer"; import { storage } from "@spacebar/cdn"; -import { CloudAttachment } from "@spacebar/util"; import { fileTypeFromBuffer } from "file-type"; import { cache } from "../util/cache"; diff --git a/src/gateway/opcodes/VoiceStateUpdate.ts b/src/gateway/opcodes/VoiceStateUpdate.ts index 4c34ccccd..0bc098526 100644 --- a/src/gateway/opcodes/VoiceStateUpdate.ts +++ b/src/gateway/opcodes/VoiceStateUpdate.ts @@ -16,9 +16,8 @@ along with this program. If not, see . */ -import { Payload, WebSocket } from "@spacebar/gateway"; +import { Payload, WebSocket, genVoiceToken } from "@spacebar/gateway"; import { Config, emitEvent, Guild, Member, VoiceServerUpdateEvent, VoiceState, VoiceStateUpdateEvent } from "@spacebar/util"; -import { genVoiceToken } from "@spacebar/gateway"; import { check } from "./instanceOf"; import { Region, VoiceStateUpdateSchema } from "@spacebar/schemas"; // TODO: check if a voice server is setup diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts index c2628e2c1..c35b3f60c 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts @@ -41,8 +41,8 @@ import { PublicMessage, Reaction, UnfurledMediaItem, + PartialUser, } from "@spacebar/schemas"; -import { PartialUser } from "@spacebar/schemas"; import { MessageFlags } from "@spacebar/util"; import { JsonRemoveEmpty } from "../util/Decorators"; diff --git a/src/util/util/Event.ts b/src/util/util/Event.ts index 9dda083c1..0e6628864 100644 --- a/src/util/util/Event.ts +++ b/src/util/util/Event.ts @@ -22,12 +22,10 @@ import EventEmitter from "node:events"; import { EVENT, Event } from "../interfaces"; import { randomUUID } from "node:crypto"; import path from "node:path"; -import { Socket } from "node:net"; -import { FSWatcher } from "node:fs"; +import net, { Socket } from "node:net"; +import fs, { FSWatcher } from "node:fs"; import { Stopwatch } from "./Stopwatch"; import { Config } from "./Config"; -import net from "node:net"; -import fs from "node:fs"; import { red } from "picocolors"; export const events = new EventEmitter(); diff --git a/src/util/util/Rights.ts b/src/util/util/Rights.ts index 6b90f7489..41b6d93b9 100644 --- a/src/util/util/Rights.ts +++ b/src/util/util/Rights.ts @@ -16,8 +16,7 @@ along with this program. If not, see . */ -import { BitField } from "./BitField"; -import { BitFieldResolvable, BitFlag } from "./BitField"; +import { BitField, BitFieldResolvable, BitFlag } from "./BitField"; import { User } from "../entities"; import { HTTPError } from "lambert-server"; diff --git a/src/util/util/lambert-server/Server.ts b/src/util/util/lambert-server/Server.ts index c291fbfe3..0d3458150 100644 --- a/src/util/util/lambert-server/Server.ts +++ b/src/util/util/lambert-server/Server.ts @@ -1,6 +1,5 @@ import express, { Application, Router } from "express"; -import { Server as HTTPServer } from "node:http"; -import http from "node:http"; +import http, { Server as HTTPServer } from "node:http"; export type ServerOptions = { port: number;