diff --git a/backend/src/entities/assignments/submission.entity.ts b/backend/src/entities/assignments/submission.entity.ts index fbaa2791..e4330e0d 100644 --- a/backend/src/entities/assignments/submission.entity.ts +++ b/backend/src/entities/assignments/submission.entity.ts @@ -16,7 +16,7 @@ export class Submission { learningObjectLanguage!: Language; @PrimaryKey({ type: 'numeric' }) - learningObjectVersion: number = 1; + learningObjectVersion = 1; @PrimaryKey({ type: 'integer', autoincrement: true }) submissionNumber?: number; diff --git a/backend/src/entities/content/learning-object.entity.ts b/backend/src/entities/content/learning-object.entity.ts index a0da9d7b..e352a10a 100644 --- a/backend/src/entities/content/learning-object.entity.ts +++ b/backend/src/entities/content/learning-object.entity.ts @@ -20,7 +20,7 @@ export class LearningObject { language!: Language; @PrimaryKey({ type: 'number' }) - version: number = 1; + version = 1; @Property({ type: 'uuid', unique: true }) uuid = v4(); @@ -46,7 +46,7 @@ export class LearningObject { targetAges?: number[] = []; @Property({ type: 'bool' }) - teacherExclusive: boolean = false; + teacherExclusive = false; @Property({ type: 'array' }) skosConcepts: string[] = []; @@ -58,10 +58,10 @@ export class LearningObject { educationalGoals: EducationalGoal[] = []; @Property({ type: 'string' }) - copyright: string = ''; + copyright = ''; @Property({ type: 'string' }) - license: string = ''; + license = ''; @Property({ type: 'smallint', nullable: true }) difficulty?: number; @@ -75,7 +75,7 @@ export class LearningObject { returnValue!: ReturnValue; @Property({ type: 'bool' }) - available: boolean = true; + available = true; @Property({ type: 'string', nullable: true }) contentLocation?: string; diff --git a/backend/src/entities/questions/question.entity.ts b/backend/src/entities/questions/question.entity.ts index 058ba6b3..09e3cd46 100644 --- a/backend/src/entities/questions/question.entity.ts +++ b/backend/src/entities/questions/question.entity.ts @@ -15,7 +15,7 @@ export class Question { learningObjectLanguage!: Language; @PrimaryKey({ type: 'number' }) - learningObjectVersion: number = 1; + learningObjectVersion = 1; @PrimaryKey({ type: 'integer', autoincrement: true }) sequenceNumber?: number; diff --git a/backend/src/entities/users/user.entity.ts b/backend/src/entities/users/user.entity.ts index 1f35a0f8..15637110 100644 --- a/backend/src/entities/users/user.entity.ts +++ b/backend/src/entities/users/user.entity.ts @@ -6,8 +6,8 @@ export abstract class User { username!: string; @Property() - firstName: string = ''; + firstName = ''; @Property() - lastName: string = ''; + lastName = ''; } diff --git a/backend/src/exceptions/badRequestException.ts b/backend/src/exceptions/badRequestException.ts index 7249fcc8..ae672755 100644 --- a/backend/src/exceptions/badRequestException.ts +++ b/backend/src/exceptions/badRequestException.ts @@ -5,7 +5,7 @@ import { HttpException } from './httpException.js'; */ export class BadRequestException extends HttpException { - constructor(message: string = 'Bad Request') { + constructor(message = 'Bad Request') { super(400, message); } } diff --git a/backend/src/exceptions/forbiddenException.ts b/backend/src/exceptions/forbiddenException.ts index f452e390..9c58c43d 100644 --- a/backend/src/exceptions/forbiddenException.ts +++ b/backend/src/exceptions/forbiddenException.ts @@ -4,7 +4,7 @@ import { HttpException } from './httpException.js'; * Exception for HTTP 403 Forbidden */ export class ForbiddenException extends HttpException { - constructor(message: string = 'Forbidden') { + constructor(message = 'Forbidden') { super(403, message); } } diff --git a/backend/src/exceptions/notFoundException.ts b/backend/src/exceptions/notFoundException.ts index b5c6a916..6f682410 100644 --- a/backend/src/exceptions/notFoundException.ts +++ b/backend/src/exceptions/notFoundException.ts @@ -4,7 +4,7 @@ import { HttpException } from './httpException.js'; * Exception for HTTP 404 Not Found */ export class NotFoundException extends HttpException { - constructor(message: string = 'Not Found') { + constructor(message = 'Not Found') { super(404, message); } } diff --git a/backend/src/exceptions/unauthorizedException.ts b/backend/src/exceptions/unauthorizedException.ts index 51ce04d4..a171084e 100644 --- a/backend/src/exceptions/unauthorizedException.ts +++ b/backend/src/exceptions/unauthorizedException.ts @@ -4,7 +4,7 @@ import { HttpException } from './httpException.js'; * Exception for HTTP 401 Unauthorized */ export class UnauthorizedException extends HttpException { - constructor(message: string = 'Unauthorized') { + constructor(message = 'Unauthorized') { super(401, message); } } diff --git a/backend/src/mikro-orm.config.ts b/backend/src/mikro-orm.config.ts index ffa12c82..86ceafe5 100644 --- a/backend/src/mikro-orm.config.ts +++ b/backend/src/mikro-orm.config.ts @@ -43,7 +43,7 @@ const entities = [ Question, ]; -function config(testingMode: boolean = false): Options { +function config(testingMode = false): Options { if (testingMode) { return { driver: SqliteDriver, diff --git a/backend/src/orm.ts b/backend/src/orm.ts index 419d5990..3e6e26c8 100644 --- a/backend/src/orm.ts +++ b/backend/src/orm.ts @@ -4,7 +4,7 @@ import { envVars, getEnvVar } from './util/envVars.js'; import { getLogger, Logger } from './logging/initalize.js'; let orm: MikroORM | undefined; -export async function initORM(testingMode: boolean = false): Promise { +export async function initORM(testingMode = false): Promise { const logger: Logger = getLogger(); logger.info('Initializing ORM'); diff --git a/backend/src/sqlite-autoincrement-workaround.ts b/backend/src/sqlite-autoincrement-workaround.ts index 29d02ffc..e45a5141 100644 --- a/backend/src/sqlite-autoincrement-workaround.ts +++ b/backend/src/sqlite-autoincrement-workaround.ts @@ -14,7 +14,7 @@ import { EntityProperty, EventArgs, EventSubscriber } from '@mikro-orm/core'; * the sequence number will not be filled in. */ export class SqliteAutoincrementSubscriber implements EventSubscriber { - private sequenceNumbersForEntityType: Map = new Map(); + private sequenceNumbersForEntityType = new Map(); /** * When an entity with an autoincremented property which is part of the composite private key is created, diff --git a/backend/src/util/envVars.ts b/backend/src/util/envVars.ts index 09287788..61f6289c 100644 --- a/backend/src/util/envVars.ts +++ b/backend/src/util/envVars.ts @@ -11,7 +11,7 @@ interface EnvVar { defaultValue?: number | string | boolean; } -export const envVars: { [key: string]: EnvVar } = { +export const envVars: Record = { Port: { key: PREFIX + 'PORT', defaultValue: 3000 }, DbHost: { key: DB_PREFIX + 'HOST', required: true }, DbPort: { key: DB_PREFIX + 'PORT', defaultValue: 5432 }, diff --git a/backend/tests/test-assets/learning-objects/learning-object-example.d.ts b/backend/tests/test-assets/learning-objects/learning-object-example.d.ts index 5053ca75..3054644f 100644 --- a/backend/tests/test-assets/learning-objects/learning-object-example.d.ts +++ b/backend/tests/test-assets/learning-objects/learning-object-example.d.ts @@ -3,6 +3,6 @@ import { Attachment } from '../../../src/entities/content/attachment.entity'; interface LearningObjectExample { createLearningObject: () => LearningObject; - createAttachment: { [key: string]: (owner: LearningObject) => Attachment }; + createAttachment: Record Attachment>; getHTMLRendering: () => string; } diff --git a/eslint.config.ts b/eslint.config.ts index a262f812..0a08619f 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -82,6 +82,10 @@ export default [ // 'no-empty-function': 'off', '@typescript-eslint/no-empty-function': 'error', + '@typescript-eslint/no-for-in-array': 'error', + + '@typescript-eslint/no-inferrable-types': 'warn', + 'no-loop-func': 'off', '@typescript-eslint/no-loop-func': 'error',