diff --git a/backend/eslint.config.ts b/backend/eslint.config.ts index 6b696021..f5f225b2 100644 --- a/backend/eslint.config.ts +++ b/backend/eslint.config.ts @@ -8,14 +8,4 @@ export default [ globals: globals.node, }, }, - - { - files: ['tests/**/*.ts'], - languageOptions: { - globals: globals.node, - }, - rules: { - 'no-console': 'off', - }, - }, ]; diff --git a/backend/package.json b/backend/package.json index 4e3b890d..c08fb1dc 100644 --- a/backend/package.json +++ b/backend/package.json @@ -11,7 +11,7 @@ "format": "prettier --write src/", "format-check": "prettier --check src/", "lint": "eslint . --fix", - "test:unit": "vitest" + "test:unit": "vitest --run" }, "dependencies": { "@mikro-orm/core": "6.4.9", diff --git a/backend/src/controllers/assignments.ts b/backend/src/controllers/assignments.ts index e1a39448..c66e8799 100644 --- a/backend/src/controllers/assignments.ts +++ b/backend/src/controllers/assignments.ts @@ -2,7 +2,7 @@ import { Request, Response } from 'express'; import { createAssignment, getAllAssignments, getAssignment, getAssignmentsSubmissions } from '../services/assignments.js'; import { AssignmentDTO } from '../interfaces/assignment.js'; -// Typescript is annoy with with parameter forwarding from class.ts +// Typescript is annoying with parameter forwarding from class.ts interface AssignmentParams { classid: string; id: string; diff --git a/backend/src/controllers/groups.ts b/backend/src/controllers/groups.ts index 787d3761..7b1f5a1e 100644 --- a/backend/src/controllers/groups.ts +++ b/backend/src/controllers/groups.ts @@ -80,7 +80,7 @@ export async function getGroupSubmissionsHandler(req: Request, res: Response): P return; } - const groupId = Number(req.params.groupid!); // Can't be undefined + const groupId = Number(req.params.groupid); // Can't be undefined if (isNaN(groupId)) { res.status(400).json({ error: 'Group id must be a number' }); diff --git a/backend/src/controllers/themes.ts b/backend/src/controllers/themes.ts index 1ef113cd..37539690 100644 --- a/backend/src/controllers/themes.ts +++ b/backend/src/controllers/themes.ts @@ -3,18 +3,16 @@ import { themes } from '../data/themes.js'; import { loadTranslations } from '../util/translation-helper.js'; interface Translations { - curricula_page: { - [key: string]: { title: string; description?: string }; - }; + curricula_page: Record; } export function getThemes(req: Request, res: Response): void { - const language = (req.query.language as string)?.toLowerCase() || 'nl'; + const language = (req.query.language as string).toLowerCase() || 'nl'; const translations = loadTranslations(language); const themeList = themes.map((theme) => ({ key: theme.title, - title: translations.curricula_page[theme.title]?.title || theme.title, - description: translations.curricula_page[theme.title]?.description, + title: translations.curricula_page[theme.title].title || theme.title, + description: translations.curricula_page[theme.title].description, image: `https://dwengo.org/images/curricula/logo_${theme.title}.png`, })); diff --git a/backend/src/services/learning-paths/database-learning-path-provider.ts b/backend/src/services/learning-paths/database-learning-path-provider.ts index c8ab41ca..3d883ef2 100644 --- a/backend/src/services/learning-paths/database-learning-path-provider.ts +++ b/backend/src/services/learning-paths/database-learning-path-provider.ts @@ -25,7 +25,7 @@ async function getLearningObjectsForNodes(nodes: LearningPathNode[]): Promise ([node, learningObject] as [LearningPathNode, FilteredLearningObject | null])) + .then((learningObject) => [node, learningObject] as [LearningPathNode, FilteredLearningObject | null]) ) ) ); diff --git a/backend/tests/data/content/learning-path-repository.test.ts b/backend/tests/data/content/learning-path-repository.test.ts index 8dbff3c1..4424fced 100644 --- a/backend/tests/data/content/learning-path-repository.test.ts +++ b/backend/tests/data/content/learning-path-repository.test.ts @@ -10,7 +10,7 @@ import { Language } from '../../../src/entities/content/language.js'; function expectToHaveFoundPrecisely(expected: LearningPath, result: LearningPath[]): void { expect(result).toHaveProperty('length'); expect(result.length).toBe(1); - expectToBeCorrectEntity({ entity: result[0]! }, { entity: expected }); + expectToBeCorrectEntity({ entity: result[0] }, { entity: expected }); } function expectToHaveFoundNothing(result: LearningPath[]): void { diff --git a/backend/tests/services/learning-path/database-learning-path-provider.test.ts b/backend/tests/services/learning-path/database-learning-path-provider.test.ts index 8d9dd530..a5943f5f 100644 --- a/backend/tests/services/learning-path/database-learning-path-provider.test.ts +++ b/backend/tests/services/learning-path/database-learning-path-provider.test.ts @@ -46,8 +46,6 @@ async function initPersonalizationTestData(): Promise<{ await learningObjectRepo.save(learningContent.extraExerciseObject); await learningPathRepo.save(learningContent.learningPath); - console.log(await getSubmissionRepository().findAll({})); - const studentA = studentRepo.create({ username: 'student_a', firstName: 'Aron', diff --git a/eslint.config.ts b/eslint.config.ts index 0541aa4a..ad4a831f 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -32,12 +32,23 @@ export default [ reportUnusedInlineConfigs: 'error', }, rules: { + // All @typescript-eslint configuration options are listed. + // If the rules are commented, they are configured by the inherited configurations. + + '@typescript-eslint/adjacent-overload-signatures': 'warn', '@typescript-eslint/array-type': 'warn', '@typescript-eslint/await-thenable': 'error', - + '@typescript-eslint/ban-ts-comment': [ + 'error', + { minimumDescriptionLength: 10 }, + ], + '@typescript-eslint/ban-tslint-comment': 'error', + 'camelcase': 'off', + '@typescript-eslint/class-literal-property-style': 'warn', 'class-methods-use-this': 'off', '@typescript-eslint/class-methods-use-this': [ 'error', { ignoreOverrideMethods: true } ], - + '@typescript-eslint/consistent-generic-constructors': 'warn', + '@typescript-eslint/consistent-indexed-object-style': 'error', 'consistent-return': 'off', '@typescript-eslint/consistent-return': 'off', '@typescript-eslint/consistent-type-assertions': 'error', @@ -46,9 +57,13 @@ export default [ '@typescript-eslint/consistent-type-imports': 'off', 'default-param-last': 'off', '@typescript-eslint/default-param-last': 'error', - + 'dot-notation': 'off', + '@typescript-eslint/dot-notation': 'warn', '@typescript-eslint/explicit-function-return-type': 'warn', - + '@typescript-eslint/explicit-member-accessibility': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'warn', + 'init-declarations': 'off', + '@typescript-eslint/init-declarations': 'off', 'max-params': 'off', '@typescript-eslint/max-params': ['error', { 'max': 6 }], '@typescript-eslint/member-ordering': 'warn', @@ -76,22 +91,41 @@ export default [ 'no-array-constructor': 'off', '@typescript-eslint/no-array-constructor': 'error', '@typescript-eslint/no-array-delete': 'error', - + '@typescript-eslint/no-base-to-string': 'off', + '@typescript-eslint/no-confusing-non-null-assertion': 'error', + '@typescript-eslint/no-confusing-void-expression': 'error', + '@typescript-eslint/no-deprecated': 'error', 'no-dupe-class-members': 'off', '@typescript-eslint/no-dupe-class-members': 'off', '@typescript-eslint/no-duplicate-enum-values': 'error', 'no-duplicate-imports': 'off', '@typescript-eslint/no-duplicate-type-constituents': 'off', - - // 'no-empty-function': 'off', + '@typescript-eslint/no-dynamic-delete': 'error', + 'no-empty-function': 'off', '@typescript-eslint/no-empty-function': 'error', - + '@typescript-eslint/no-empty-interface': 'off', + '@typescript-eslint/no-empty-object-type': 'error', + '@typescript-eslint/no-explicit-any': 'warn', // Once in production, this should be an error. + '@typescript-eslint/no-extra-non-null-assertion': 'error', + '@typescript-eslint/no-extraneous-class': 'error', + '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-for-in-array': 'error', - + 'no-implied-eval': 'off', + '@typescript-eslint/no-implied-eval': 'error', + '@typescript-eslint/no-import-type-side-effects': 'error', '@typescript-eslint/no-inferrable-types': 'warn', - + 'no-invalid-this': 'off', + '@typescript-eslint/no-invalid-this': 'off', + '@typescript-eslint/no-invalid-void-type': 'error', 'no-loop-func': 'off', '@typescript-eslint/no-loop-func': 'error', + 'no-loss-of-precision': 'off', + '@typescript-eslint/no-loss-of-precision': 'off', + 'no-magic-numbers': 'off', + '@typescript-eslint/no-magic-numbers': 'off', + + 'no-redeclare': 'off', + '@typescript-eslint/no-redeclare': 'off', '@typescript-eslint/no-type-alias': 'off', @@ -149,7 +183,6 @@ export default [ curly: 'error', 'default-case': 'error', 'default-case-last': 'error', - 'dot-notation': 'warn', eqeqeq: 'error', 'func-names': 'warn', 'func-style': ['warn', 'declaration'],