Skip to content

Commit

Permalink
chore: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutV committed May 21, 2024
1 parent f13ea45 commit e40e10a
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 32 deletions.
1 change: 0 additions & 1 deletion frontend/src/components/forms/ErrorMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Message from 'primevue/message';
/* Props */
defineProps<{ field: any }>();
</script>

<template>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/projects/ProjectForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const rules = computed(() => {
});
const v$ = useVuelidate(rules, form, {
$scope: 'form'
$scope: 'form',
});
/**
Expand Down Expand Up @@ -119,7 +119,7 @@ watchEffect(() => {
<div class="grid">
<!-- Start date of the project -->
<div class="field col">
<label for="projectStartDate">{{ t('views.projects.start_date') }}</label>
<label for="projectStartDate">{{ t('views.projects.startDate') }}</label>
<Calendar
id="projectStartDate"
class="w-full"
Expand Down Expand Up @@ -152,15 +152,15 @@ watchEffect(() => {
<!-- Group size for the project -->
<div class="field col">
<label for="groupSize">
{{ t('views.projects.group_size') }}
{{ t('views.projects.groupSize') }}
</label>
<InputNumber input-id="groupSize" class="w-full" v-model="form.group_size" :min="1" />
<ErrorMessage :field="v$.group_size" />
</div>

<!-- Max score for the project -->
<div class="field col">
<label for="maxScore">{{ t('views.projects.max_score') }}</label>
<label for="maxScore">{{ t('views.projects.maxScore') }}</label>
<InputNumber
input-id="maxScore"
class="w-full"
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/projects/ProjectStructureTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function deleteStructureCheck(check: StructureCheck): void {
*/
function updateStructureCheckName(input: HTMLInputElement): void {
if (editingStructureCheck.value !== null && structureChecks.value !== undefined) {
const editing = editingStructureCheck.value;
const oldPath = editing.path;
const editing: StructureCheck = editingStructureCheck.value;
const oldPath: string = editing.path;
editing.setLastFolderName(input.value);
Expand Down Expand Up @@ -196,6 +196,7 @@ function newTreeNode(check: StructureCheck, key: string, label: string, leaf: bo
<InputText
:model-value="node.label"
@change="updateStructureCheckName($event.target as HTMLInputElement)"
@keydown.enter="updateStructureCheckName($event.target as HTMLInputElement)"
>
</InputText>
</template>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/test/unit/services/project_service.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { describe, it, expect } from 'vitest';
import { describe, it } from 'vitest';

describe('placeholder', (): void => {
it('aaaaaaaa', () => {});
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/test/unit/types/structureCheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { describe, it } from 'vitest';
// import { createStructureCheck } from './helper';

describe('structureCheck type', () => {
it('aaaa')
it('aaaa');
// it('create instance of structureCheck with correct properties', () => {
// const structureCheck = createStructureCheck(structureCheckData);
//
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/ApiResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type HyperlinkedRelation = string;
21 changes: 9 additions & 12 deletions frontend/src/types/Course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ export class Course {
public id: string = '',
public name: string = '',
public excerpt: string = '',
public description: string | null = '',
public description: string = '',
public academic_startyear: number = getAcademicYear(),
public private_course: boolean = false,
public invitation_link: string | null = null,
public invitation_link_expires: Date | null = null,
public invitation_link: string = '',
public invitation_link_expires: Date = new Date(),
public parent_course: Course | null = null,
public faculty: Faculty | null = null,
public teachers: Teacher[] | null = null,
public assistants: Assistant[] | null = null,
public students: Student[] | null = null,
public projects: Project[] | null = null,
public faculty: Faculty = new Faculty(),
public teachers: Teacher[] = [],
public assistants: Assistant[] = [],
public students: Student[] = [],
public projects: Project[] = [],
) {}

/**
Expand Down Expand Up @@ -63,9 +63,6 @@ export class Course {
* @param course
*/
static fromJSON(course: Course): Course {
const faculty =
course.faculty !== undefined && course.faculty !== null ? Faculty.fromJSON(course.faculty) : null;

return new Course(
course.id,
course.name,
Expand All @@ -76,7 +73,7 @@ export class Course {
course.invitation_link,
course.invitation_link_expires,
course.parent_course,
faculty,
course.faculty,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/types/Faculty.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class Faculty {
constructor(
public id: string,
public name: string,
public id: string = '',
public name: string = '',
) {}

/**
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/types/FileExtension.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
export class FileExtension {
constructor(public extension: string) {}
constructor(
public id: string = '',
public extension: string = '',
) {}

/**
* Convert a file extension object to a file extension instance.
*
* @param extension
*/
static fromJSON(extension: FileExtension): FileExtension {
return new FileExtension(extension.extension);
return new FileExtension(extension.id, extension.extension);
}
}
15 changes: 10 additions & 5 deletions frontend/src/types/StructureCheck.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FileExtension } from './FileExtension.ts';
import { type Project } from './Project.ts';
import { Project } from './Project.ts';

export class StructureCheck {
constructor(
public id: string = '',
public path: string = '',
public obligated_extensions: FileExtension[] = [],
public blocked_extensions: FileExtension[] = [],
public project: Project | null = null,
public project: Project = new Project(),
) {}

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ export class StructureCheck {
* @param extensions
*/
public setBlockedExtensionList(extensions: string[]): void {
this.blocked_extensions = extensions.map((extension) => new FileExtension(extension));
this.blocked_extensions = extensions.map((extension) => new FileExtension('', extension));
}

/**
Expand All @@ -60,7 +60,7 @@ export class StructureCheck {
* @param extensions
*/
public setObligatedExtensionList(extensions: string[]): void {
this.obligated_extensions = extensions.map((extension) => new FileExtension(extension));
this.obligated_extensions = extensions.map((extension) => new FileExtension('', extension));
}

/**
Expand Down Expand Up @@ -103,6 +103,11 @@ export class StructureCheck {
* @param structureCheck
*/
static fromJSON(structureCheck: StructureCheck): StructureCheck {
return new StructureCheck(structureCheck.id, structureCheck.path);
return new StructureCheck(
structureCheck.id,
structureCheck.path,
structureCheck.obligated_extensions.map(FileExtension.fromJSON),
structureCheck.blocked_extensions.map(FileExtension.fromJSON),
);
}
}
5 changes: 3 additions & 2 deletions frontend/src/views/projects/UpdateProjectView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ async function saveProject(newProject: Project): Promise<void> {
await setExtraChecks(newProject.extra_checks ?? [], project.value.id);
// Delete the deleted checks
const deletedChecks = (project.value.extra_checks ?? []).filter(
(check) => !(newProject.extra_checks ?? []).find((newCheck: ExtraCheck) => newCheck.id === check.id),
const deletedChecks = project.value.extra_checks.filter(
(check) =>
newProject.extra_checks.find((newCheck: ExtraCheck) => newCheck.id === check.id) === undefined,
);
for (const check of deletedChecks) {
Expand Down

0 comments on commit e40e10a

Please sign in to comment.