Kaynağa Gözat

fix: Fix remaining backend eslint issues

Owen Diffey 1 yıl önce
ebeveyn
işleme
a2dd0ff7e4

+ 2 - 0
backend/src/@types/mongoose.d.ts

@@ -2,10 +2,12 @@ declare module "mongoose" {
 	// Add some additional possible config options to Mongoose's schema options
 	interface SchemaOptions<
 		DocType = unknown,
+		/* eslint-disable */
 		TInstanceMethods = {},
 		QueryHelpers = {},
 		TStaticMethods = {},
 		TVirtuals = {},
+		/* eslint-enable */
 		THydratedDocumentType = HydratedDocument<
 			DocType,
 			TInstanceMethods,

+ 1 - 0
backend/src/JobContext.ts

@@ -57,6 +57,7 @@ export default class JobContext {
 	}
 
 	public executeJob(
+		// eslint-disable-next-line @typescript-eslint/ban-types
 		JobClass: Function,
 		payload?: unknown,
 		options?: JobOptions

+ 2 - 0
backend/src/JobQueue.ts

@@ -55,6 +55,7 @@ export class JobQueue {
 	 * runJob - Run a job
 	 */
 	public async runJob(
+		// eslint-disable-next-line @typescript-eslint/ban-types
 		JobClass: Function,
 		payload?: unknown,
 		options?: JobOptions
@@ -73,6 +74,7 @@ export class JobQueue {
 	 * queueJob - Queue a job
 	 */
 	public async queueJob(
+		// eslint-disable-next-line @typescript-eslint/ban-types
 		JobClass: Function,
 		payload?: unknown,
 		options?: JobOptions

+ 2 - 0
backend/src/modules/DataModule/models/news/schema.ts

@@ -58,6 +58,7 @@ export interface NewsModel
 	) => Promise<NewsSchema[]>;
 }
 
+// eslint-disable-next-line @typescript-eslint/ban-types
 export const schema = new Schema<NewsSchema, NewsModel, {}, NewsQueryHelpers>(
 	{
 		title: {
@@ -90,4 +91,5 @@ export const schema = new Schema<NewsSchema, NewsModel, {}, NewsQueryHelpers>(
 
 export type NewsSchemaType = typeof schema;
 
+// eslint-disable-next-line @typescript-eslint/ban-types
 export type NewsSchemaOptions = SchemaOptions<NewsSchema, {}, NewsQueryHelpers>;

+ 6 - 4
backend/src/modules/DataModule/models/stations/jobs/Index.ts

@@ -1,9 +1,11 @@
+import { HydratedDocument } from "mongoose";
 import DataModule from "@/modules/DataModule";
 import DataModuleJob from "@/modules/DataModule/DataModuleJob";
 import isDj from "@/modules/DataModule/permissions/isDj";
 import isOwner from "@/modules/DataModule/permissions/isOwner";
 import isPublic from "@/modules/DataModule/permissions/isPublic";
-import { StationModel } from "../schema";
+import { StationModel, StationSchema } from "../schema";
+import { forEachIn } from "@/utils/forEachIn";
 
 export default class Index extends DataModuleJob {
 	protected static _modelName = "stations";
@@ -37,9 +39,9 @@ export default class Index extends DataModuleJob {
 
 		const user = await this._context.getUser().catch(() => null);
 
-		const stations = [];
+		const stations: HydratedDocument<StationSchema>[] = [];
 
-		for (const station of data) {
+		await forEachIn(data, async station => {
 			if (
 				isPublic(station) ||
 				(user && (isOwner(station, user) || isDj(station, user))) ||
@@ -50,7 +52,7 @@ export default class Index extends DataModuleJob {
 						.catch(() => false)))
 			)
 				stations.push(station);
-		}
+		});
 
 		return stations;
 	}

+ 1 - 5
backend/src/modules/EventsModule.ts

@@ -354,11 +354,7 @@ export class EventsModule extends BaseModule {
 
 	public async subscribeSocket(channel: string, socketId: string) {
 		if (!this._socketSubscriptions[channel]) {
-			await this.subscribe(
-				"event",
-				channel,
-				() => new Promise<void>(resolve => resolve())
-			);
+			await this.subscribe("event", channel, () => Promise.resolve());
 
 			this._socketSubscriptions[channel] = new Set();
 		}

+ 1 - 0
backend/src/utils/assertJobDerived.ts

@@ -1,5 +1,6 @@
 import Job from "@/Job";
 
+// eslint-disable-next-line @typescript-eslint/ban-types
 export default (JobClass: Function) => {
 	// Make sure the provided JobClass has Job as the parent somewhere as a parent. Not Job itself, as that constructor requires an additional constructor parameter
 	// So any class that extends Job, or that extends another class that extends Job, will be allowed.

+ 3 - 0
backend/tsconfig.json

@@ -104,5 +104,8 @@
 		// "skipDefaultLibCheck": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */
 		"skipLibCheck": true /* Skip type checking all .d.ts files. */,
 		"pretty": true
+	},
+	"ts-node": {
+		"files": true
 	}
 }