diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 15a75b0e..00000000 --- a/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules -dist -README.md -COPYING -src/webrtc -scripts/ -assets \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs index 0d6cfbba..e321115c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -39,7 +39,9 @@ export default [{ rules: { "no-mixed-spaces-and-tabs": "off", - "@typescript-eslint/no-inferrable-types": "off", - "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-inferrable-types": "off", // Required by typeorm + "@typescript-eslint/no-var-requires": "off", // Sometimes requred by typeorm to resolve circular deps + "@typescript-eslint/no-require-imports": "off", + "@typescript-eslint/no-unused-vars": "off", }, }]; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c8f04aa5..20593506 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1205,7 +1205,6 @@ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", "dev": true, - "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", @@ -1257,7 +1256,6 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=18" }, @@ -1290,7 +1288,6 @@ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", "dev": true, - "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } @@ -5899,7 +5896,6 @@ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.13.0.tgz", "integrity": "sha512-IFLyoY4d72Z5y/6o/BazFBezupzI/taV8sGumxTAVw3lXG9A6md1Dc34T9s1FoD/an9pJH8RHbAxsaEbBed9lA==", "dev": true, - "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } @@ -6765,7 +6761,6 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-15.12.0.tgz", "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=18" }, @@ -11791,4 +11786,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/api/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts index b5204ffc..b4f48477 100644 --- a/src/api/middlewares/Authentication.ts +++ b/src/api/middlewares/Authentication.ts @@ -108,7 +108,6 @@ export async function Authentication( req.rights = new Rights(Number(user.rights)); return next(); } catch (error) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion return next(new HTTPError(error!.toString(), 400)); } } diff --git a/src/api/routes/auth/reset.ts b/src/api/routes/auth/reset.ts index b3ca1e9e..da4d3334 100644 --- a/src/api/routes/auth/reset.ts +++ b/src/api/routes/auth/reset.ts @@ -72,7 +72,6 @@ router.post( await User.update({ id: user.id }, data); // come on, the user has to have an email to reset their password in the first place - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion await Email.sendPasswordChanged(user, user.email!); res.json({ token: await generateToken(user.id) }); diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts index 94320eee..c6f987fc 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts @@ -171,7 +171,6 @@ export async function onIdentify(this: WebSocket, data: Payload) { // but we do want almost everything from guild. // How do you do that without just enumerating the guild props? guild: Object.fromEntries( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion getDatabase()! .getMetadata(Guild) .columns.map((x) => [x.propertyName, true]), diff --git a/src/gateway/opcodes/LazyRequest.ts b/src/gateway/opcodes/LazyRequest.ts index 45eaccfa..eba284b2 100644 --- a/src/gateway/opcodes/LazyRequest.ts +++ b/src/gateway/opcodes/LazyRequest.ts @@ -214,7 +214,6 @@ async function subscribeToMemberEvents(this: WebSocket, user_id: string) { export async function onLazyRequest(this: WebSocket, { d }: Payload) { // TODO: check data check.call(this, LazyRequestSchema, d); - // eslint-disable-next-line @typescript-eslint/no-unused-vars const { guild_id, typing, channels, activities, members } = d as LazyRequestSchema; diff --git a/src/gateway/opcodes/RequestGuildMembers.ts b/src/gateway/opcodes/RequestGuildMembers.ts index f83cf376..e1cae95a 100644 --- a/src/gateway/opcodes/RequestGuildMembers.ts +++ b/src/gateway/opcodes/RequestGuildMembers.ts @@ -27,7 +27,7 @@ import { } from "@spacebar/util"; import { WebSocket, Payload, OPCODES, Send } from "@spacebar/gateway"; import { check } from "./instanceOf"; -import { FindManyOptions, In, Like } from "typeorm"; +import { FindManyOptions, ILike, In } from "typeorm"; export async function onRequestGuildMembers(this: WebSocket, { d }: Payload) { // Schema validation can only accept either string or array, so transforming it here to support both @@ -114,7 +114,7 @@ export async function onRequestGuildMembers(this: WebSocket, { d }: Payload) { if (query) { // @ts-expect-error memberFind.where is very much defined memberFind.where.user = { - username: Like(query + "%"), + username: ILike(query + "%"), }; } else if (user_ids && user_ids.length > 0) { // @ts-expect-error memberFind.where is still very much defined @@ -166,15 +166,17 @@ export async function onRequestGuildMembers(this: WebSocket, { d }: Payload) { }); } + if (chunks.length == 0) { + chunks.push({ + ...baseData, + members: [], + presences: presences ? [] : undefined, + chunk_index: 0, + chunk_count: 1, + }); + } + if (notFound.length > 0) { - if (chunks.length == 0) - chunks.push({ - ...baseData, - members: [], - presences: presences ? [] : undefined, - chunk_index: 0, - chunk_count: 1, - }); chunks[0].not_found = notFound; } diff --git a/src/gateway/opcodes/VoiceStateUpdate.ts b/src/gateway/opcodes/VoiceStateUpdate.ts index ffc143ed..b45c8203 100644 --- a/src/gateway/opcodes/VoiceStateUpdate.ts +++ b/src/gateway/opcodes/VoiceStateUpdate.ts @@ -99,7 +99,6 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { voiceState.token = genVoiceToken(); voiceState.session_id = this.session_id; - // eslint-disable-next-line @typescript-eslint/no-unused-vars const { id, ...newObj } = voiceState; await Promise.all([ diff --git a/src/util/entities/BaseClass.ts b/src/util/entities/BaseClass.ts index f4b3cf59..0171e010 100644 --- a/src/util/entities/BaseClass.ts +++ b/src/util/entities/BaseClass.ts @@ -46,7 +46,7 @@ export class BaseClassWithoutId extends BaseEntity { // eslint-disable-next-line @typescript-eslint/no-explicit-any toJSON(): any { return Object.fromEntries( - // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/no-non-null-assertion + // eslint-disable-next-line @typescript-eslint/ban-ts-comment this.metadata!.columns // @ts-ignore .map((x) => [x.propertyName, this[x.propertyName]]) .concat( diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index 84d0b90c..caa52eb3 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -466,8 +466,8 @@ export class Member extends BaseClassWithoutId { member[x] = this[x]; }); - if (member.roles) member.roles = member.roles.map((x: Role) => x.id); - if (member.user) member.user = member.user.toPublicUser(); + if (this.roles) member.roles = this.roles.map((x: Role) => x.id); + if (this.user) member.user = this.user.toPublicUser(); return member as PublicMember; } diff --git a/src/util/schemas/MessageCreateSchema.ts b/src/util/schemas/MessageCreateSchema.ts index 15537ca8..4eaf7c96 100644 --- a/src/util/schemas/MessageCreateSchema.ts +++ b/src/util/schemas/MessageCreateSchema.ts @@ -69,7 +69,6 @@ export interface MessageCreateSchema { } // TypeScript complains once this is used above -// eslint-disable-next-line @typescript-eslint/no-unused-vars interface PollCreationSchema { question: PollMedia; answers: PollAnswer[]; diff --git a/src/util/schemas/responses/TeamListResponse.ts b/src/util/schemas/responses/TeamListResponse.ts index 375f0ae6..c4a7d177 100644 --- a/src/util/schemas/responses/TeamListResponse.ts +++ b/src/util/schemas/responses/TeamListResponse.ts @@ -18,4 +18,5 @@ import { Team } from "@spacebar/util"; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface TeamListResponse extends Array {} diff --git a/src/util/util/AutoUpdate.ts b/src/util/util/AutoUpdate.ts index b7721cdb..9a3c0a2a 100644 --- a/src/util/util/AutoUpdate.ts +++ b/src/util/util/AutoUpdate.ts @@ -70,7 +70,6 @@ export function enableAutoUpdate(opts: { }); } -// eslint-disable-next-line @typescript-eslint/no-unused-vars async function download(url: string, dir: string) { try { // TODO: use file stream instead of buffer (to prevent crash because of high memory usage for big files) diff --git a/src/util/util/Event.ts b/src/util/util/Event.ts index 01f4911a..bbc93aac 100644 --- a/src/util/util/Event.ts +++ b/src/util/util/Event.ts @@ -100,6 +100,7 @@ export async function listenEvent( }; const listener = (msg: ProcessEvent) => { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions msg.type === "event" && msg.id === event && callback({ ...msg.event, cancel }); diff --git a/src/util/util/Sentry.ts b/src/util/util/Sentry.ts index 510ed453..005b09e7 100644 --- a/src/util/util/Sentry.ts +++ b/src/util/util/Sentry.ts @@ -117,7 +117,7 @@ export const Sentry = { Integrations.setupExpressErrorHandler(app); // The typings for this are broken? - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars + // eslint-disable-next-line @typescript-eslint/no-explicit-any app.use(function onError(err: any, req: any, res: any, next: any) { res.statusCode = 500; res.end(res.sentry + "\n");