refactor: no-inferrable-types

This commit is contained in:
Tibo De Peuter 2025-03-23 13:22:39 +01:00
parent e1aba11222
commit e84c772916
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
14 changed files with 22 additions and 18 deletions

View file

@ -16,7 +16,7 @@ export class Submission {
learningObjectLanguage!: Language;
@PrimaryKey({ type: 'numeric' })
learningObjectVersion: number = 1;
learningObjectVersion = 1;
@PrimaryKey({ type: 'integer', autoincrement: true })
submissionNumber?: number;

View file

@ -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;

View file

@ -15,7 +15,7 @@ export class Question {
learningObjectLanguage!: Language;
@PrimaryKey({ type: 'number' })
learningObjectVersion: number = 1;
learningObjectVersion = 1;
@PrimaryKey({ type: 'integer', autoincrement: true })
sequenceNumber?: number;

View file

@ -6,8 +6,8 @@ export abstract class User {
username!: string;
@Property()
firstName: string = '';
firstName = '';
@Property()
lastName: string = '';
lastName = '';
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -43,7 +43,7 @@ const entities = [
Question,
];
function config(testingMode: boolean = false): Options {
function config(testingMode = false): Options {
if (testingMode) {
return {
driver: SqliteDriver,

View file

@ -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<void> {
export async function initORM(testingMode = false): Promise<void> {
const logger: Logger = getLogger();
logger.info('Initializing ORM');

View file

@ -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<string, number> = new Map();
private sequenceNumbersForEntityType = new Map<string, number>();
/**
* When an entity with an autoincremented property which is part of the composite private key is created,

View file

@ -11,7 +11,7 @@ interface EnvVar {
defaultValue?: number | string | boolean;
}
export const envVars: { [key: string]: EnvVar } = {
export const envVars: Record<string, EnvVar> = {
Port: { key: PREFIX + 'PORT', defaultValue: 3000 },
DbHost: { key: DB_PREFIX + 'HOST', required: true },
DbPort: { key: DB_PREFIX + 'PORT', defaultValue: 5432 },

View file

@ -3,6 +3,6 @@ import { Attachment } from '../../../src/entities/content/attachment.entity';
interface LearningObjectExample {
createLearningObject: () => LearningObject;
createAttachment: { [key: string]: (owner: LearningObject) => Attachment };
createAttachment: Record<string, (owner: LearningObject) => Attachment>;
getHTMLRendering: () => string;
}

View file

@ -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',