From 14e1508d000d0b03512672cfdb5a0703f09e654f Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Sat, 22 Mar 2025 17:22:28 +0100 Subject: [PATCH] refactor(backend): no-unused-vars --- backend/src/config.ts | 1 - backend/src/controllers/students.ts | 8 ------- backend/src/controllers/teachers.ts | 4 ---- backend/src/data/repositories.ts | 2 -- backend/src/data/users/student-repository.ts | 4 ---- backend/src/data/users/teacher-repository.ts | 1 - .../entities/assignments/assignment.entity.ts | 2 +- .../src/entities/assignments/group.entity.ts | 2 +- backend/src/interfaces/assignment.ts | 2 +- backend/src/interfaces/question.ts | 2 -- backend/src/interfaces/submission.ts | 2 -- backend/src/middleware/auth/auth.ts | 4 ++-- backend/src/routes/assignments.ts | 2 +- backend/src/routes/auth.ts | 8 +++---- backend/src/routes/groups.ts | 2 +- backend/src/routes/students.ts | 4 ++-- backend/src/routes/submissions.ts | 2 +- backend/src/routes/teachers.ts | 2 +- backend/src/services/assignments.ts | 2 +- backend/src/services/groups.ts | 1 - backend/src/services/learning-objects.ts | 2 +- .../category-question-renderer.ts | 2 +- .../description-question-renderer.ts | 2 +- .../matching-question-renderer.ts | 2 +- .../numerical-question-renderer.ts | 2 +- .../short-question-renderer.ts | 2 +- .../true-false-question-renderer.ts | 2 +- .../processing/markdown/markdown-processor.ts | 8 +++---- backend/src/services/questions.ts | 6 ++---- backend/src/services/students.ts | 3 --- backend/src/services/submissions.ts | 4 ++-- backend/src/services/teachers.ts | 11 +--------- backend/src/util/links.ts | 2 +- .../data/classes/class-join-request.test.ts | 2 -- .../tests/data/questions/questions.test.ts | 5 +---- .../learning-paths/test-conditions-example.ts | 2 +- eslint.config.ts | 21 +++++++++++++++---- 37 files changed, 51 insertions(+), 84 deletions(-) diff --git a/backend/src/config.ts b/backend/src/config.ts index 69af5d74..7e1b3b6a 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -1,5 +1,4 @@ import { EnvVars, getEnvVar } from './util/envvars.js'; -import { Language } from './entities/content/language.js'; // API export const DWENGO_API_BASE = getEnvVar(EnvVars.LearningContentRepoApiBaseUrl); diff --git a/backend/src/controllers/students.ts b/backend/src/controllers/students.ts index 3ab89e31..96cdd4dd 100644 --- a/backend/src/controllers/students.ts +++ b/backend/src/controllers/students.ts @@ -9,13 +9,7 @@ import { getStudentGroups, getStudentSubmissions, } from '../services/students.js'; -import { ClassDTO } from '../interfaces/class.js'; -import { getAllAssignments } from '../services/assignments.js'; -import { getUserHandler } from './users.js'; -import { Student } from '../entities/users/student.entity.js'; import { StudentDTO } from '../interfaces/student.js'; -import { getStudentRepository } from '../data/repositories.js'; -import { UserDTO } from '../interfaces/user.js'; import { getLogger } from '../logging/initalize.js'; // TODO: accept arguments (full, ...) @@ -23,8 +17,6 @@ import { getLogger } from '../logging/initalize.js'; export async function getAllStudentsHandler(req: Request, res: Response): Promise { const full = req.query.full === 'true'; - const studentRepository = getStudentRepository(); - const students: StudentDTO[] | string[] = full ? await getAllStudents() : await getAllStudents(); if (!students) { diff --git a/backend/src/controllers/teachers.ts b/backend/src/controllers/teachers.ts index 55213bc0..7bcbb5f4 100644 --- a/backend/src/controllers/teachers.ts +++ b/backend/src/controllers/teachers.ts @@ -14,16 +14,12 @@ import { import { ClassDTO } from '../interfaces/class.js'; import { StudentDTO } from '../interfaces/student.js'; import { QuestionDTO, QuestionId } from '../interfaces/question.js'; -import { Teacher } from '../entities/users/teacher.entity.js'; import { TeacherDTO } from '../interfaces/teacher.js'; -import { getTeacherRepository } from '../data/repositories.js'; import { getLogger } from '../logging/initalize.js'; export async function getAllTeachersHandler(req: Request, res: Response): Promise { const full = req.query.full === 'true'; - const teacherRepository = getTeacherRepository(); - const teachers: TeacherDTO[] | string[] = full ? await getAllTeachers() : await getAllTeachers(); if (!teachers) { diff --git a/backend/src/data/repositories.ts b/backend/src/data/repositories.ts index 02385109..cdeb50c1 100644 --- a/backend/src/data/repositories.ts +++ b/backend/src/data/repositories.ts @@ -2,8 +2,6 @@ import { AnyEntity, EntityManager, EntityName, EntityRepository } from '@mikro-o import { forkEntityManager } from '../orm.js'; import { StudentRepository } from './users/student-repository.js'; import { Student } from '../entities/users/student.entity.js'; -import { User } from '../entities/users/user.entity.js'; -import { UserRepository } from './users/user-repository.js'; import { Teacher } from '../entities/users/teacher.entity.js'; import { TeacherRepository } from './users/teacher-repository.js'; import { Class } from '../entities/classes/class.entity.js'; diff --git a/backend/src/data/users/student-repository.ts b/backend/src/data/users/student-repository.ts index 0792678d..34b24b8b 100644 --- a/backend/src/data/users/student-repository.ts +++ b/backend/src/data/users/student-repository.ts @@ -1,9 +1,5 @@ import { Student } from '../../entities/users/student.entity.js'; -import { User } from '../../entities/users/user.entity.js'; import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; -// Import { UserRepository } from './user-repository.js'; - -// Export class StudentRepository extends UserRepository {} export class StudentRepository extends DwengoEntityRepository { public findByUsername(username: string): Promise { diff --git a/backend/src/data/users/teacher-repository.ts b/backend/src/data/users/teacher-repository.ts index 2b2bee75..825b4d18 100644 --- a/backend/src/data/users/teacher-repository.ts +++ b/backend/src/data/users/teacher-repository.ts @@ -1,6 +1,5 @@ import { Teacher } from '../../entities/users/teacher.entity.js'; import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; -import { UserRepository } from './user-repository.js'; export class TeacherRepository extends DwengoEntityRepository { public findByUsername(username: string): Promise { diff --git a/backend/src/entities/assignments/assignment.entity.ts b/backend/src/entities/assignments/assignment.entity.ts index 692e2112..daa71ed6 100644 --- a/backend/src/entities/assignments/assignment.entity.ts +++ b/backend/src/entities/assignments/assignment.entity.ts @@ -1,4 +1,4 @@ -import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; +import { Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; import { Class } from '../classes/class.entity.js'; import { Group } from './group.entity.js'; import { Language } from '../content/language.js'; diff --git a/backend/src/entities/assignments/group.entity.ts b/backend/src/entities/assignments/group.entity.ts index 213e0f38..cfe21f7f 100644 --- a/backend/src/entities/assignments/group.entity.ts +++ b/backend/src/entities/assignments/group.entity.ts @@ -1,4 +1,4 @@ -import { Collection, Entity, ManyToMany, ManyToOne, PrimaryKey } from '@mikro-orm/core'; +import { Entity, ManyToMany, ManyToOne, PrimaryKey } from '@mikro-orm/core'; import { Assignment } from './assignment.entity.js'; import { Student } from '../users/student.entity.js'; import { GroupRepository } from '../../data/assignments/group-repository.js'; diff --git a/backend/src/interfaces/assignment.ts b/backend/src/interfaces/assignment.ts index 45023399..698b5b40 100644 --- a/backend/src/interfaces/assignment.ts +++ b/backend/src/interfaces/assignment.ts @@ -2,7 +2,7 @@ import { FALLBACK_LANG } from '../config.js'; import { Assignment } from '../entities/assignments/assignment.entity.js'; import { Class } from '../entities/classes/class.entity.js'; import { languageMap } from '../entities/content/language.js'; -import { GroupDTO, mapToGroupDTO } from './group.js'; +import { GroupDTO } from './group.js'; import { getLogger } from '../logging/initalize.js'; export interface AssignmentDTO { diff --git a/backend/src/interfaces/question.ts b/backend/src/interfaces/question.ts index 8cca42f6..0da87eb7 100644 --- a/backend/src/interfaces/question.ts +++ b/backend/src/interfaces/question.ts @@ -1,8 +1,6 @@ import { Question } from '../entities/questions/question.entity.js'; -import { UserDTO } from './user.js'; import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js'; import { mapToStudentDTO, StudentDTO } from './student.js'; -import { TeacherDTO } from './teacher.js'; export interface QuestionDTO { learningObjectIdentifier: LearningObjectIdentifier; diff --git a/backend/src/interfaces/submission.ts b/backend/src/interfaces/submission.ts index fbaf520d..522d48cf 100644 --- a/backend/src/interfaces/submission.ts +++ b/backend/src/interfaces/submission.ts @@ -2,8 +2,6 @@ import { Submission } from '../entities/assignments/submission.entity.js'; import { Language } from '../entities/content/language.js'; import { GroupDTO, mapToGroupDTO } from './group.js'; import { mapToStudent, mapToStudentDTO, StudentDTO } from './student.js'; -import { mapToUser } from './user'; -import { Student } from '../entities/users/student.entity'; export interface SubmissionDTO { learningObjectHruid: string; diff --git a/backend/src/middleware/auth/auth.ts b/backend/src/middleware/auth/auth.ts index 5ff5a53c..0c8d31ff 100644 --- a/backend/src/middleware/auth/auth.ts +++ b/backend/src/middleware/auth/auth.ts @@ -100,7 +100,7 @@ function getAuthenticationInfo(req: AuthenticatedRequest): AuthenticationInfo | * Add the AuthenticationInfo object with the information about the current authentication to the request in order * to avoid that the routers have to deal with the JWT token. */ -const addAuthenticationInfo = (req: AuthenticatedRequest, res: express.Response, next: express.NextFunction) => { +const addAuthenticationInfo = (req: AuthenticatedRequest, _res: express.Response, next: express.NextFunction) => { req.auth = getAuthenticationInfo(req); next(); }; @@ -115,7 +115,7 @@ export const authenticateUser = [verifyJwtToken, addAuthenticationInfo]; */ export const authorize = (accessCondition: (auth: AuthenticationInfo) => boolean) => - (req: AuthenticatedRequest, res: express.Response, next: express.NextFunction): void => { + (req: AuthenticatedRequest, _res: express.Response, next: express.NextFunction): void => { if (!req.auth) { throw new UnauthorizedException(); } else if (!accessCondition(req.auth)) { diff --git a/backend/src/routes/assignments.ts b/backend/src/routes/assignments.ts index a733d093..3652dcc6 100644 --- a/backend/src/routes/assignments.ts +++ b/backend/src/routes/assignments.ts @@ -19,7 +19,7 @@ router.get('/:id', getAssignmentHandler); router.get('/:id/submissions', getAssignmentsSubmissionsHandler); -router.get('/:id/questions', (req, res) => { +router.get('/:id/questions', (_req, res) => { res.json({ questions: ['0'], }); diff --git a/backend/src/routes/auth.ts b/backend/src/routes/auth.ts index 778e51fd..4a1f27d2 100644 --- a/backend/src/routes/auth.ts +++ b/backend/src/routes/auth.ts @@ -4,21 +4,21 @@ import { authenticatedOnly, studentsOnly, teachersOnly } from '../middleware/aut const router = express.Router(); // Returns auth configuration for frontend -router.get('/config', (req, res) => { +router.get('/config', (_req, res) => { res.json(getFrontendAuthConfig()); }); -router.get('/testAuthenticatedOnly', authenticatedOnly, (req, res) => { +router.get('/testAuthenticatedOnly', authenticatedOnly, (_req, res) => { /* #swagger.security = [{ "student": [ ] }, { "teacher": [ ] }] */ res.json({ message: 'If you see this, you should be authenticated!' }); }); -router.get('/testStudentsOnly', studentsOnly, (req, res) => { +router.get('/testStudentsOnly', studentsOnly, (_req, res) => { /* #swagger.security = [{ "student": [ ] }] */ res.json({ message: 'If you see this, you should be a student!' }); }); -router.get('/testTeachersOnly', teachersOnly, (req, res) => { +router.get('/testTeachersOnly', teachersOnly, (_req, res) => { /* #swagger.security = [{ "teacher": [ ] }] */ res.json({ message: 'If you see this, you should be a teacher!' }); }); diff --git a/backend/src/routes/groups.ts b/backend/src/routes/groups.ts index 0c9692b0..dc8917bd 100644 --- a/backend/src/routes/groups.ts +++ b/backend/src/routes/groups.ts @@ -14,7 +14,7 @@ router.get('/:groupid', getGroupHandler); router.get('/:groupid', getGroupSubmissionsHandler); // The list of questions a group has made -router.get('/:id/questions', (req, res) => { +router.get('/:id/questions', (_req, res) => { res.json({ questions: ['0'], }); diff --git a/backend/src/routes/students.ts b/backend/src/routes/students.ts index 7ed7a666..d58c2adc 100644 --- a/backend/src/routes/students.ts +++ b/backend/src/routes/students.ts @@ -9,7 +9,7 @@ import { getStudentHandler, getStudentSubmissionsHandler, } from '../controllers/students.js'; -import { getStudentGroups } from '../services/students.js'; + const router = express.Router(); // Root endpoint used to search objects @@ -37,7 +37,7 @@ router.get('/:id/assignments', getStudentAssignmentsHandler); router.get('/:id/groups', getStudentGroupsHandler); // A list of questions a user has created -router.get('/:id/questions', (req, res) => { +router.get('/:id/questions', (_req, res) => { res.json({ questions: ['0'], }); diff --git a/backend/src/routes/submissions.ts b/backend/src/routes/submissions.ts index 4db93027..8e9831b9 100644 --- a/backend/src/routes/submissions.ts +++ b/backend/src/routes/submissions.ts @@ -3,7 +3,7 @@ import { createSubmissionHandler, deleteSubmissionHandler, getSubmissionHandler const router = express.Router({ mergeParams: true }); // Root endpoint used to search objects -router.get('/', (req, res) => { +router.get('/', (_req, res) => { res.json({ submissions: ['0', '1'], }); diff --git a/backend/src/routes/teachers.ts b/backend/src/routes/teachers.ts index c04e1575..3782a6ca 100644 --- a/backend/src/routes/teachers.ts +++ b/backend/src/routes/teachers.ts @@ -28,7 +28,7 @@ router.get('/:username/students', getTeacherStudentHandler); router.get('/:username/questions', getTeacherQuestionHandler); // Invitations to other classes a teacher received -router.get('/:id/invitations', (req, res) => { +router.get('/:id/invitations', (_req, res) => { res.json({ invitations: ['0'], }); diff --git a/backend/src/services/assignments.ts b/backend/src/services/assignments.ts index be121810..c637b822 100644 --- a/backend/src/services/assignments.ts +++ b/backend/src/services/assignments.ts @@ -37,7 +37,7 @@ export async function createAssignment(classid: string, assignmentData: Assignme await assignmentRepository.save(newAssignment); return newAssignment; - } catch (e) { + } catch (_) { return null; } } diff --git a/backend/src/services/groups.ts b/backend/src/services/groups.ts index 329d230d..ecc92293 100644 --- a/backend/src/services/groups.ts +++ b/backend/src/services/groups.ts @@ -1,4 +1,3 @@ -import { GroupRepository } from '../data/assignments/group-repository.js'; import { getAssignmentRepository, getClassRepository, diff --git a/backend/src/services/learning-objects.ts b/backend/src/services/learning-objects.ts index 87856bc9..5298e5b3 100644 --- a/backend/src/services/learning-objects.ts +++ b/backend/src/services/learning-objects.ts @@ -86,6 +86,6 @@ export async function getLearningObjectsFromPath(hruid: string, language: string export async function getLearningObjectIdsFromPath(hruid: string, language: string): Promise { return (await fetchLearningObjects(hruid, false, language)) as string[]; } -function fetchLearningPaths(arg0: string[], language: string, arg2: string): LearningPathResponse | PromiseLike { +function fetchLearningPaths(_arg0: string[], _language: string, _arg2: string): LearningPathResponse | PromiseLike { throw new Error('Function not implemented.'); } diff --git a/backend/src/services/learning-objects/processing/gift/question-renderers/category-question-renderer.ts b/backend/src/services/learning-objects/processing/gift/question-renderers/category-question-renderer.ts index 507e5ada..256a38a7 100644 --- a/backend/src/services/learning-objects/processing/gift/question-renderers/category-question-renderer.ts +++ b/backend/src/services/learning-objects/processing/gift/question-renderers/category-question-renderer.ts @@ -3,7 +3,7 @@ import { Category } from 'gift-pegjs'; import { ProcessingError } from '../../processing-error.js'; export class CategoryQuestionRenderer extends GIFTQuestionRenderer { - render(question: Category, questionNumber: number): string { + render(_question: Category, _questionNumber: number): string { throw new ProcessingError("The question type 'Category' is not supported yet!"); } } diff --git a/backend/src/services/learning-objects/processing/gift/question-renderers/description-question-renderer.ts b/backend/src/services/learning-objects/processing/gift/question-renderers/description-question-renderer.ts index 0238d76a..7bab255f 100644 --- a/backend/src/services/learning-objects/processing/gift/question-renderers/description-question-renderer.ts +++ b/backend/src/services/learning-objects/processing/gift/question-renderers/description-question-renderer.ts @@ -3,7 +3,7 @@ import { Description } from 'gift-pegjs'; import { ProcessingError } from '../../processing-error.js'; export class DescriptionQuestionRenderer extends GIFTQuestionRenderer { - render(question: Description, questionNumber: number): string { + render(_question: Description, _questionNumber: number): string { throw new ProcessingError("The question type 'Description' is not supported yet!"); } } diff --git a/backend/src/services/learning-objects/processing/gift/question-renderers/matching-question-renderer.ts b/backend/src/services/learning-objects/processing/gift/question-renderers/matching-question-renderer.ts index bb6e9737..21713920 100644 --- a/backend/src/services/learning-objects/processing/gift/question-renderers/matching-question-renderer.ts +++ b/backend/src/services/learning-objects/processing/gift/question-renderers/matching-question-renderer.ts @@ -3,7 +3,7 @@ import { Matching } from 'gift-pegjs'; import { ProcessingError } from '../../processing-error.js'; export class MatchingQuestionRenderer extends GIFTQuestionRenderer { - render(question: Matching, questionNumber: number): string { + render(_question: Matching, _questionNumber: number): string { throw new ProcessingError("The question type 'Matching' is not supported yet!"); } } diff --git a/backend/src/services/learning-objects/processing/gift/question-renderers/numerical-question-renderer.ts b/backend/src/services/learning-objects/processing/gift/question-renderers/numerical-question-renderer.ts index 32fdb06e..2286cd42 100644 --- a/backend/src/services/learning-objects/processing/gift/question-renderers/numerical-question-renderer.ts +++ b/backend/src/services/learning-objects/processing/gift/question-renderers/numerical-question-renderer.ts @@ -3,7 +3,7 @@ import { Numerical } from 'gift-pegjs'; import { ProcessingError } from '../../processing-error.js'; export class NumericalQuestionRenderer extends GIFTQuestionRenderer { - render(question: Numerical, questionNumber: number): string { + render(_question: Numerical, _questionNumber: number): string { throw new ProcessingError("The question type 'Numerical' is not supported yet!"); } } diff --git a/backend/src/services/learning-objects/processing/gift/question-renderers/short-question-renderer.ts b/backend/src/services/learning-objects/processing/gift/question-renderers/short-question-renderer.ts index 5a63531f..1e5527e0 100644 --- a/backend/src/services/learning-objects/processing/gift/question-renderers/short-question-renderer.ts +++ b/backend/src/services/learning-objects/processing/gift/question-renderers/short-question-renderer.ts @@ -3,7 +3,7 @@ import { ShortAnswer } from 'gift-pegjs'; import { ProcessingError } from '../../processing-error.js'; export class ShortQuestionRenderer extends GIFTQuestionRenderer { - render(question: ShortAnswer, questionNumber: number): string { + render(_question: ShortAnswer, _questionNumber: number): string { throw new ProcessingError("The question type 'ShortAnswer' is not supported yet!"); } } diff --git a/backend/src/services/learning-objects/processing/gift/question-renderers/true-false-question-renderer.ts b/backend/src/services/learning-objects/processing/gift/question-renderers/true-false-question-renderer.ts index 98148130..fabbc634 100644 --- a/backend/src/services/learning-objects/processing/gift/question-renderers/true-false-question-renderer.ts +++ b/backend/src/services/learning-objects/processing/gift/question-renderers/true-false-question-renderer.ts @@ -3,7 +3,7 @@ import { TrueFalse } from 'gift-pegjs'; import { ProcessingError } from '../../processing-error.js'; export class TrueFalseQuestionRenderer extends GIFTQuestionRenderer { - render(question: TrueFalse, questionNumber: number): string { + render(_question: TrueFalse, _questionNumber: number): string { throw new ProcessingError("The question type 'TrueFalse' is not supported yet!"); } } diff --git a/backend/src/services/learning-objects/processing/markdown/markdown-processor.ts b/backend/src/services/learning-objects/processing/markdown/markdown-processor.ts index 1de6b3d5..39f2adc8 100644 --- a/backend/src/services/learning-objects/processing/markdown/markdown-processor.ts +++ b/backend/src/services/learning-objects/processing/markdown/markdown-processor.ts @@ -15,22 +15,20 @@ class MarkdownProcessor extends StringProcessor { } override renderFn(mdText: string) { - let html = ''; try { marked.use({ renderer: dwengoMarkedRenderer }); - html = marked(mdText, { async: false }); - html = this.replaceLinks(html); // Replace html image links path + const html = marked(mdText, { async: false }); + return this.replaceLinks(html); // Replace html image links path } catch (e: any) { throw new ProcessingError(e.message); } - return html; } replaceLinks(html: string) { const proc = new InlineImageProcessor(); html = html.replace( //g, - (match: string, src: string, alt: string, altText: string, title: string, titleText: string) => proc.render(src) + (_match: string, src: string, _alt: string, _altText: string, _title: string, _titleText: string) => proc.render(src) ); return html; } diff --git a/backend/src/services/questions.ts b/backend/src/services/questions.ts index ee003bcd..0433b69f 100644 --- a/backend/src/services/questions.ts +++ b/backend/src/services/questions.ts @@ -5,8 +5,6 @@ import { Answer } from '../entities/questions/answer.entity.js'; import { mapToAnswerDTO, mapToAnswerId } from '../interfaces/answer.js'; import { QuestionRepository } from '../data/questions/question-repository.js'; import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js'; -import { mapToUser } from '../interfaces/user.js'; -import { Student } from '../entities/users/student.entity.js'; import { mapToStudent } from '../interfaces/student.js'; export async function getAllQuestions(id: LearningObjectIdentifier, full: boolean): Promise { @@ -81,7 +79,7 @@ export async function createQuestion(questionDTO: QuestionDTO) { author, content: questionDTO.content, }); - } catch (e) { + } catch (_) { return null; } @@ -99,7 +97,7 @@ export async function deleteQuestion(questionId: QuestionId) { try { await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(questionId.learningObjectIdentifier, questionId.sequenceNumber); - } catch (e) { + } catch (_) { return null; } diff --git a/backend/src/services/students.ts b/backend/src/services/students.ts index 98fdfe0a..935cfe54 100644 --- a/backend/src/services/students.ts +++ b/backend/src/services/students.ts @@ -1,13 +1,10 @@ import { getClassRepository, getGroupRepository, getStudentRepository, getSubmissionRepository } from '../data/repositories.js'; -import { Class } from '../entities/classes/class.entity.js'; -import { Student } from '../entities/users/student.entity.js'; import { AssignmentDTO } from '../interfaces/assignment.js'; import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student.js'; import { mapToSubmissionDTO, SubmissionDTO } from '../interfaces/submission.js'; import { getAllAssignments } from './assignments.js'; -import { UserService } from './users.js'; import { getLogger } from '../logging/initalize.js'; export async function getAllStudents(): Promise { diff --git a/backend/src/services/submissions.ts b/backend/src/services/submissions.ts index a8fa96c7..153ce169 100644 --- a/backend/src/services/submissions.ts +++ b/backend/src/services/submissions.ts @@ -1,4 +1,4 @@ -import { getGroupRepository, getSubmissionRepository } from '../data/repositories.js'; +import { getSubmissionRepository } from '../data/repositories.js'; import { Language } from '../entities/content/language.js'; import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js'; import { mapToSubmission, mapToSubmissionDTO, SubmissionDTO } from '../interfaces/submission.js'; @@ -28,7 +28,7 @@ export async function createSubmission(submissionDTO: SubmissionDTO) { try { const newSubmission = await submissionRepository.create(submission); await submissionRepository.save(newSubmission); - } catch (e) { + } catch (_) { return null; } diff --git a/backend/src/services/teachers.ts b/backend/src/services/teachers.ts index 5e52b822..1949152f 100644 --- a/backend/src/services/teachers.ts +++ b/backend/src/services/teachers.ts @@ -1,17 +1,8 @@ -import { - getClassRepository, - getLearningObjectRepository, - getQuestionRepository, - getStudentRepository, - getTeacherRepository, -} from '../data/repositories.js'; -import { Teacher } from '../entities/users/teacher.entity.js'; +import { getClassRepository, getLearningObjectRepository, getQuestionRepository, getTeacherRepository } from '../data/repositories.js'; import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; import { getClassStudents } from './class.js'; import { StudentDTO } from '../interfaces/student.js'; import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from '../interfaces/question.js'; -import { UserService } from './users.js'; -import { mapToUser } from '../interfaces/user.js'; import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js'; import { getLogger } from '../logging/initalize.js'; diff --git a/backend/src/util/links.ts b/backend/src/util/links.ts index 73e27965..c4b54c72 100644 --- a/backend/src/util/links.ts +++ b/backend/src/util/links.ts @@ -4,7 +4,7 @@ export function isValidHttpUrl(url: string): boolean { try { const parsedUrl = new URL(url, 'http://test.be'); return parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:'; - } catch (e) { + } catch (_) { return false; } } diff --git a/backend/tests/data/classes/class-join-request.test.ts b/backend/tests/data/classes/class-join-request.test.ts index f0aa2f62..cd53bf05 100644 --- a/backend/tests/data/classes/class-join-request.test.ts +++ b/backend/tests/data/classes/class-join-request.test.ts @@ -3,9 +3,7 @@ import { setupTestApp } from '../../setup-tests'; import { ClassJoinRequestRepository } from '../../../src/data/classes/class-join-request-repository'; import { getClassJoinRequestRepository, getClassRepository, getStudentRepository } from '../../../src/data/repositories'; import { StudentRepository } from '../../../src/data/users/student-repository'; -import { Class } from '../../../src/entities/classes/class.entity'; import { ClassRepository } from '../../../src/data/classes/class-repository'; -import { Student } from '../../../src/entities/users/student.entity'; describe('ClassJoinRequestRepository', () => { let classJoinRequestRepository: ClassJoinRequestRepository; diff --git a/backend/tests/data/questions/questions.test.ts b/backend/tests/data/questions/questions.test.ts index 7b408df4..c1d2b483 100644 --- a/backend/tests/data/questions/questions.test.ts +++ b/backend/tests/data/questions/questions.test.ts @@ -1,22 +1,19 @@ import { beforeAll, describe, expect, it } from 'vitest'; import { setupTestApp } from '../../setup-tests'; import { QuestionRepository } from '../../../src/data/questions/question-repository'; -import { getLearningObjectRepository, getQuestionRepository, getStudentRepository } from '../../../src/data/repositories'; +import { getQuestionRepository, getStudentRepository } from '../../../src/data/repositories'; import { StudentRepository } from '../../../src/data/users/student-repository'; -import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository'; import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; import { Language } from '../../../src/entities/content/language'; describe('QuestionRepository', () => { let questionRepository: QuestionRepository; let studentRepository: StudentRepository; - let learningObjectRepository: LearningObjectRepository; beforeAll(async () => { await setupTestApp(); questionRepository = getQuestionRepository(); studentRepository = getStudentRepository(); - learningObjectRepository = getLearningObjectRepository(); }); it('should return all questions part of the given learning object', async () => { diff --git a/backend/tests/test-assets/learning-paths/test-conditions-example.ts b/backend/tests/test-assets/learning-paths/test-conditions-example.ts index 07857235..ee957f91 100644 --- a/backend/tests/test-assets/learning-paths/test-conditions-example.ts +++ b/backend/tests/test-assets/learning-paths/test-conditions-example.ts @@ -79,6 +79,6 @@ export function createConditionTestLearningPathAndLearningObjects() { }; } -const example: LearningPathExample = { +const _example: LearningPathExample = { createLearningPath: () => createConditionTestLearningPathAndLearningObjects().learningPath, }; diff --git a/eslint.config.ts b/eslint.config.ts index 52a36775..a3001cc5 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -28,6 +28,23 @@ export default [ reportUnusedInlineConfigs: 'error', }, rules: { + 'no-unused-expressions': 'off', + '@typescript-eslint/no-unused-expressions': 'warn', + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': [ + 'warn', + { + 'args': 'all', + 'argsIgnorePattern': '^_', + 'caughtErrors': 'all', + 'caughtErrorsIgnorePattern': '^_', + 'varsIgnorePattern': '^_', + 'ignoreRestSiblings': true, + } + ], + 'no-use-before-define': 'off', + '@typescript-eslint/no-use-before-define': 'off', + 'no-await-in-loop': 'warn', 'no-constructor-return': 'error', 'no-duplicate-imports': 'error', @@ -36,12 +53,8 @@ export default [ 'no-template-curly-in-string': 'error', 'no-unmodified-loop-condition': 'warn', 'no-unreachable-loop': 'warn', - 'no-use-before-define': 'error', 'no-useless-assignment': 'error', - 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': 'error', - 'arrow-body-style': ['warn', 'as-needed'], 'block-scoped-var': 'warn', camelcase: 'warn',