refactor: no-inferrable-types
This commit is contained in:
		
							parent
							
								
									e1aba11222
								
							
						
					
					
						commit
						e84c772916
					
				
					 14 changed files with 22 additions and 18 deletions
				
			
		|  | @ -16,7 +16,7 @@ export class Submission { | ||||||
|     learningObjectLanguage!: Language; |     learningObjectLanguage!: Language; | ||||||
| 
 | 
 | ||||||
|     @PrimaryKey({ type: 'numeric' }) |     @PrimaryKey({ type: 'numeric' }) | ||||||
|     learningObjectVersion: number = 1; |     learningObjectVersion = 1; | ||||||
| 
 | 
 | ||||||
|     @PrimaryKey({ type: 'integer', autoincrement: true }) |     @PrimaryKey({ type: 'integer', autoincrement: true }) | ||||||
|     submissionNumber?: number; |     submissionNumber?: number; | ||||||
|  |  | ||||||
|  | @ -20,7 +20,7 @@ export class LearningObject { | ||||||
|     language!: Language; |     language!: Language; | ||||||
| 
 | 
 | ||||||
|     @PrimaryKey({ type: 'number' }) |     @PrimaryKey({ type: 'number' }) | ||||||
|     version: number = 1; |     version = 1; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'uuid', unique: true }) |     @Property({ type: 'uuid', unique: true }) | ||||||
|     uuid = v4(); |     uuid = v4(); | ||||||
|  | @ -46,7 +46,7 @@ export class LearningObject { | ||||||
|     targetAges?: number[] = []; |     targetAges?: number[] = []; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'bool' }) |     @Property({ type: 'bool' }) | ||||||
|     teacherExclusive: boolean = false; |     teacherExclusive = false; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'array' }) |     @Property({ type: 'array' }) | ||||||
|     skosConcepts: string[] = []; |     skosConcepts: string[] = []; | ||||||
|  | @ -58,10 +58,10 @@ export class LearningObject { | ||||||
|     educationalGoals: EducationalGoal[] = []; |     educationalGoals: EducationalGoal[] = []; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'string' }) |     @Property({ type: 'string' }) | ||||||
|     copyright: string = ''; |     copyright = ''; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'string' }) |     @Property({ type: 'string' }) | ||||||
|     license: string = ''; |     license = ''; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'smallint', nullable: true }) |     @Property({ type: 'smallint', nullable: true }) | ||||||
|     difficulty?: number; |     difficulty?: number; | ||||||
|  | @ -75,7 +75,7 @@ export class LearningObject { | ||||||
|     returnValue!: ReturnValue; |     returnValue!: ReturnValue; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'bool' }) |     @Property({ type: 'bool' }) | ||||||
|     available: boolean = true; |     available = true; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'string', nullable: true }) |     @Property({ type: 'string', nullable: true }) | ||||||
|     contentLocation?: string; |     contentLocation?: string; | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ export class Question { | ||||||
|     learningObjectLanguage!: Language; |     learningObjectLanguage!: Language; | ||||||
| 
 | 
 | ||||||
|     @PrimaryKey({ type: 'number' }) |     @PrimaryKey({ type: 'number' }) | ||||||
|     learningObjectVersion: number = 1; |     learningObjectVersion = 1; | ||||||
| 
 | 
 | ||||||
|     @PrimaryKey({ type: 'integer', autoincrement: true }) |     @PrimaryKey({ type: 'integer', autoincrement: true }) | ||||||
|     sequenceNumber?: number; |     sequenceNumber?: number; | ||||||
|  |  | ||||||
|  | @ -6,8 +6,8 @@ export abstract class User { | ||||||
|     username!: string; |     username!: string; | ||||||
| 
 | 
 | ||||||
|     @Property() |     @Property() | ||||||
|     firstName: string = ''; |     firstName = ''; | ||||||
| 
 | 
 | ||||||
|     @Property() |     @Property() | ||||||
|     lastName: string = ''; |     lastName = ''; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ import { HttpException } from './httpException.js'; | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| export class BadRequestException extends HttpException { | export class BadRequestException extends HttpException { | ||||||
|     constructor(message: string = 'Bad Request') { |     constructor(message = 'Bad Request') { | ||||||
|         super(400, message); |         super(400, message); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import { HttpException } from './httpException.js'; | ||||||
|  * Exception for HTTP 403 Forbidden |  * Exception for HTTP 403 Forbidden | ||||||
|  */ |  */ | ||||||
| export class ForbiddenException extends HttpException { | export class ForbiddenException extends HttpException { | ||||||
|     constructor(message: string = 'Forbidden') { |     constructor(message = 'Forbidden') { | ||||||
|         super(403, message); |         super(403, message); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import { HttpException } from './httpException.js'; | ||||||
|  * Exception for HTTP 404 Not Found |  * Exception for HTTP 404 Not Found | ||||||
|  */ |  */ | ||||||
| export class NotFoundException extends HttpException { | export class NotFoundException extends HttpException { | ||||||
|     constructor(message: string = 'Not Found') { |     constructor(message = 'Not Found') { | ||||||
|         super(404, message); |         super(404, message); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import { HttpException } from './httpException.js'; | ||||||
|  * Exception for HTTP 401 Unauthorized |  * Exception for HTTP 401 Unauthorized | ||||||
|  */ |  */ | ||||||
| export class UnauthorizedException extends HttpException { | export class UnauthorizedException extends HttpException { | ||||||
|     constructor(message: string = 'Unauthorized') { |     constructor(message = 'Unauthorized') { | ||||||
|         super(401, message); |         super(401, message); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -43,7 +43,7 @@ const entities = [ | ||||||
|     Question, |     Question, | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
| function config(testingMode: boolean = false): Options { | function config(testingMode = false): Options { | ||||||
|     if (testingMode) { |     if (testingMode) { | ||||||
|         return { |         return { | ||||||
|             driver: SqliteDriver, |             driver: SqliteDriver, | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import { envVars, getEnvVar } from './util/envVars.js'; | ||||||
| import { getLogger, Logger } from './logging/initalize.js'; | import { getLogger, Logger } from './logging/initalize.js'; | ||||||
| 
 | 
 | ||||||
| let orm: MikroORM | undefined; | 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(); |     const logger: Logger = getLogger(); | ||||||
| 
 | 
 | ||||||
|     logger.info('Initializing ORM'); |     logger.info('Initializing ORM'); | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ import { EntityProperty, EventArgs, EventSubscriber } from '@mikro-orm/core'; | ||||||
|  *   the sequence number will not be filled in. |  *   the sequence number will not be filled in. | ||||||
|  */ |  */ | ||||||
| export class SqliteAutoincrementSubscriber implements EventSubscriber { | 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, |      * When an entity with an autoincremented property which is part of the composite private key is created, | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ interface EnvVar { | ||||||
|     defaultValue?: number | string | boolean; |     defaultValue?: number | string | boolean; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export const envVars: { [key: string]: EnvVar } = { | export const envVars: Record<string, EnvVar> = { | ||||||
|     Port: { key: PREFIX + 'PORT', defaultValue: 3000 }, |     Port: { key: PREFIX + 'PORT', defaultValue: 3000 }, | ||||||
|     DbHost: { key: DB_PREFIX + 'HOST', required: true }, |     DbHost: { key: DB_PREFIX + 'HOST', required: true }, | ||||||
|     DbPort: { key: DB_PREFIX + 'PORT', defaultValue: 5432 }, |     DbPort: { key: DB_PREFIX + 'PORT', defaultValue: 5432 }, | ||||||
|  |  | ||||||
|  | @ -3,6 +3,6 @@ import { Attachment } from '../../../src/entities/content/attachment.entity'; | ||||||
| 
 | 
 | ||||||
| interface LearningObjectExample { | interface LearningObjectExample { | ||||||
|     createLearningObject: () => LearningObject; |     createLearningObject: () => LearningObject; | ||||||
|     createAttachment: { [key: string]: (owner: LearningObject) => Attachment }; |     createAttachment: Record<string, (owner: LearningObject) => Attachment>; | ||||||
|     getHTMLRendering: () => string; |     getHTMLRendering: () => string; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -82,6 +82,10 @@ export default [ | ||||||
|             // 'no-empty-function': 'off',
 |             // 'no-empty-function': 'off',
 | ||||||
|             '@typescript-eslint/no-empty-function': 'error', |             '@typescript-eslint/no-empty-function': 'error', | ||||||
| 
 | 
 | ||||||
|  |             '@typescript-eslint/no-for-in-array': 'error', | ||||||
|  | 
 | ||||||
|  |             '@typescript-eslint/no-inferrable-types': 'warn', | ||||||
|  | 
 | ||||||
|             'no-loop-func': 'off', |             'no-loop-func': 'off', | ||||||
|             '@typescript-eslint/no-loop-func': 'error', |             '@typescript-eslint/no-loop-func': 'error', | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue