Skip to content

Commit

Permalink
BC-8011 - Fix & evaluate disabled linter rules (#3574)
Browse files Browse the repository at this point in the history
* removes unused error parameter in catch blocks
* disables material-icon-imports in eslint config
* refactors some tests
* removes MultiGuard (now implemented in vue-router itself)
* use empty return to avoid no-empty-function warning in boardRestApi and cardRestApi
* implements errorMessages in computed in BoardAnyTitleInput
* removes unused vars

---------

Co-authored-by: wolfganggreschus <[email protected]>
  • Loading branch information
odalys-dataport and wolfganggreschus authored Mar 6, 2025
1 parent c59a056 commit d953d10
Show file tree
Hide file tree
Showing 57 changed files with 205 additions and 499 deletions.
2 changes: 1 addition & 1 deletion __mocks__/maska.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* This is a mock for the vMaska directive exported by maska package.
*/
import { Jest as jest } from "@jest/environment";

// eslint-disable-next-line no-undef
const vMaska = jest.fn();

export { vMaska };
6 changes: 6 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,10 @@ module.exports = [
},
},
},
{
files: ["src/components/icons/material/index.ts"],
rules: {
"schulcloud/material-icon-imports": "off",
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from "@/serverApi/v3";
import { SchoolExternalTool } from "@/store/external-tool";
import SchoolExternalToolsModule from "@/store/school-external-tools";
import { DataTableHeader } from "@/types/vuetify";
import {
schoolExternalToolFactory,
schoolExternalToolResponseFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ const pasteFromClipboard = async () => {
await nextTick();
updateSearchInput(text);
} catch (err) {
} catch {
notifierModule.show({
text: t("pages.tool.select.clipboard.error"),
status: "error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function useExternalToolUrlInsertion() {
try {
new URL(text);
return true;
} catch (err) {
} catch {
return false;
}
};
Expand Down
1 change: 0 additions & 1 deletion src/components/icons/material/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable schulcloud/material-icon-imports */
import {
mdiAccountBoxOutline,
mdiAccountEditOutline,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default defineComponent({
// Clears the previous collection elements before rendering the new ones
contentModule.clearElements();
await contentModule.getElements(this.query);
} catch (error) {
} catch {
notifierModule.show({
text: this.$t("pages.content.notification.lernstoreNotAvailable"),
status: "error",
Expand Down
7 changes: 3 additions & 4 deletions src/components/lern-store/LernstoreDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
<div ref="sidebar" class="sidebar elevation-6">
<div class="content-container">
<div class="actions" />
<!--eslint-disable-next-line vuetify/no-deprecated-classes -->
<div class="title">
<span>
{{ resource.title || resource.name }}
Expand Down Expand Up @@ -175,8 +174,8 @@
</template>

<script>
import UserHasRole from "@/components/helpers/UserHasRole";
import AddContentButton from "@/components/lern-store/AddContentButton";
import UserHasRole from "@/components/helpers/UserHasRole.vue";
import AddContentButton from "@/components/lern-store/AddContentButton.vue";
import LernStorePlayer from "@/components/lern-store/LernStorePlayer";
import contentMeta from "@/mixins/contentMeta";
import { printDateFromTimestamp } from "@/plugins/datetime";
Expand All @@ -194,7 +193,7 @@ import {
import { buildPageTitle } from "@/utils/pageTitle";
import { RenderHTML } from "@feature-render-html";
import { mdiCalendar, mdiClose, mdiOpenInNew, mdiPound } from "@icons/material";
import BaseLink from "../base/BaseLink";
import BaseLink from "@/components/base/BaseLink.vue";
import { $axios } from "@/utils/api";
const DEFAULT_AUTHOR = "admin";
Expand Down
2 changes: 1 addition & 1 deletion src/components/share/ImportFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async function startImport(name: string) {
} else {
openModal("result");
}
} catch (error: unknown) {
} catch {
showFailureBackend(newName.value);
}
}
Expand Down
75 changes: 25 additions & 50 deletions src/components/templates/TasksDashboardMain.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ describe("@/components/templates/TasksDashboardMain", () => {
const validRoles = ["student", "teacher"];
const invalidRoles = ["janitor", "principal"];

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const { validator } = TasksDashboardMain.props.role;

validRoles.forEach((role) => {
Expand Down Expand Up @@ -127,15 +125,6 @@ describe("@/components/templates/TasksDashboardMain", () => {
});
});

it("should set isStudent true", () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.isStudent).toBe(true);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.isTeacher).toBe(false);
});

it("should render student's tasks dashboard", () => {
const studentDashboard = wrapper.findComponent(TasksDashboardStudent);
expect(studentDashboard.exists()).toBe(true);
Expand All @@ -149,15 +138,15 @@ describe("@/components/templates/TasksDashboardMain", () => {
});

it("should open tab from store state", async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.tab).toStrictEqual("open");
const studentDashboard = wrapper.findComponent(TasksDashboardStudent);
expect(studentDashboard.props("tabRoutes")).toContain("open");
});

it("should hide substituteFilter", async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.showSubstituteFilter).toBe(false);
const substituteFilterPlaceholder = wrapper.find(
".substitute-filter-placeholder"
);
expect(substituteFilterPlaceholder.exists()).toBe(true);
});

describe("with hasTasks === true", () => {
Expand Down Expand Up @@ -234,15 +223,6 @@ describe("@/components/templates/TasksDashboardMain", () => {
});
});

it("should set isTeacher true", () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.isTeacher).toBe(true);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.isStudent).toBe(false);
});

it("should render teacher's tasks dashboard", () => {
const teacherDashboard = wrapper.findComponent(TasksDashboardTeacher);
expect(teacherDashboard.exists()).toBe(true);
Expand All @@ -255,17 +235,16 @@ describe("@/components/templates/TasksDashboardMain", () => {
expect(fabComponent.exists()).toEqual(true);
});

it("'add task' button should have correct path", async () => {
const fabComponent = await wrapper.findComponent(SpeedDialMenu);
it("'add task' button should have correct path", () => {
const fabComponent = wrapper.findComponent(SpeedDialMenu);
expect(fabComponent.props("href")).toStrictEqual(
"/homework/new?returnUrl=tasks"
);
});

it("should open tab from store state", async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.tab).toStrictEqual("current");
const teacherDashboard = wrapper.findComponent(TasksDashboardTeacher);
expect(teacherDashboard.props("tabRoutes")).toContain("current");
});

it("should show substituteFilter on 1st tab", async () => {
Expand All @@ -279,10 +258,7 @@ describe("@/components/templates/TasksDashboardMain", () => {
role: "teacher",
},
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.showSubstituteFilter).toBe(true);
expect(wrapper.findComponent({ name: "v-switch" }).exists()).toBe(true);
});

it("should show substituteFilter on 2nd tab", async () => {
Expand All @@ -296,10 +272,7 @@ describe("@/components/templates/TasksDashboardMain", () => {
role: "teacher",
},
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.showSubstituteFilter).toBe(true);
expect(wrapper.findComponent({ name: "v-switch" }).exists()).toBe(true);
});

it("should hide substituteFilter on 3rd tab", async () => {
Expand All @@ -314,9 +287,10 @@ describe("@/components/templates/TasksDashboardMain", () => {
},
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.showSubstituteFilter).toBe(false);
const substituteFilterPlaceholder = wrapper.find(
".substitute-filter-placeholder"
);
expect(substituteFilterPlaceholder.exists()).toBe(true);
});

it("Should update state when tab changes", async () => {
Expand Down Expand Up @@ -366,7 +340,7 @@ describe("@/components/templates/TasksDashboardMain", () => {
});
});

it("should disable filter when active tab contains empty list and no course is selected", () => {
it("should not display filter when active tab contains empty list and no course is selected", () => {
tasksModuleMock = createModuleMocks(TasksModule, {
getStatus: "completed",
getOpenTasksForStudent: {
Expand Down Expand Up @@ -394,9 +368,9 @@ describe("@/components/templates/TasksDashboardMain", () => {
},
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.isCourseFilterDisabled).toBe(true);
const autoComplete = wrapper.findComponent({ name: "v-autocomplete" });

expect(autoComplete.exists()).toBe(false);
});

it("should enable filter when active tab is not empty and no course is selected", () => {
Expand All @@ -411,7 +385,7 @@ describe("@/components/templates/TasksDashboardMain", () => {
submitted: [],
graded: [],
},
hasTasks: false,
hasTasks: true,
getActiveTab: "completed",

// make tab 2 report as not empty
Expand All @@ -427,9 +401,10 @@ describe("@/components/templates/TasksDashboardMain", () => {
},
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(wrapper.vm.isCourseFilterDisabled).toBe(false);
const autoComplete = wrapper.findComponent({ name: "v-autocomplete" });

expect(autoComplete.exists()).toBe(true);
expect(autoComplete.classes()).not.toContain("v-input--disabled");
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/composables/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function useCopy(isLoadingDialogOpen: Ref<boolean>) {
} else {
openResultModal();
}
} catch (error) {
} catch {
markBackgroundCopyProcess(copyParams);
showTimeout();
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { createPinia } from "pinia";
import { createApp } from "vue";
import VueDOMPurifyHTML from "vue-dompurify-html";

// TODO solve without vue-mq dependency
// TODO - solve within https://ticketsystem.dbildungscloud.de/browse/BC-8013
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { Vue3Mq } from "vue3-mq";
Expand Down
8 changes: 0 additions & 8 deletions src/modules/data/board/CardRequestPool.composable.unit.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { BoardCardApiInterface } from "@/serverApi/v3";
import { useSharedCardRequestPool } from "./CardRequestPool.composable";
import * as serverApi from "@/serverApi/v3/api";
import * as axios from "axios";
import { initializeAxios } from "@/utils/api";

jest.mock("axios");

let mockReturnData: { data: { data: { id: string }[] } };
const cardsApiFactoryMock = {
cardControllerGetCards: jest.fn().mockImplementation(() => mockReturnData),
};
initializeAxios({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
request: async (path: string) => mockReturnData,
} as axios.AxiosInstance);

const setup = (...cardIds: string[]) => {
const returnedCards = cardIds.map((id) => ({ id }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const useBoardRestApi = () => {
try {
const board = await fetchBoardCall(payload.boardId);
boardStore.fetchBoardSuccess(board);
} catch (error) {
} catch {
applicationErrorModule.setError(
createApplicationError(
HttpStatusCode.NotFound,
Expand Down Expand Up @@ -280,8 +280,9 @@ export const useBoardRestApi = () => {
};

// this unused function is added to make sure that the same name is used in both socketApi and restApi
// eslint-disable-next-line @typescript-eslint/no-empty-function
const disconnectSocketRequest = (): void => {};
const disconnectSocketRequest = (): void => {
return;
};

return {
fetchBoardRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const useBoardSocketApi = () => {
payload.toColumnIndex = boardStore.getColumnIndex(payload.toColumnId);
}
emitOnSocket("move-card-request", payload);
} catch (err) {
} catch {
moveCardFailure();
}
};
Expand Down
5 changes: 3 additions & 2 deletions src/modules/data/board/cardActions/cardRestApi.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ export const useCardRestApi = () => {
};

// this unused function is added to make sure that the same name is used in both socketApi and restApi
// eslint-disable-next-line @typescript-eslint/no-empty-function
const disconnectSocketRequest = (): void => {};
const disconnectSocketRequest = (): void => {
return;
};

return {
createElementRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
UpdateCardTitleRequestPayload,
UpdateElementRequestPayload,
} from "./cardActionPayload";
import { DisconnectSocketRequestPayload } from "../boardActions/boardActionPayload";
import { useDebounceFn } from "@vueuse/core";
import { useBoardAriaNotification } from "../ariaNotification/ariaLiveNotificationHandler";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
DeleteCardFailurePayload,
DeleteCardRequestPayload,
DeleteElementFailurePayload,
DisconnectSocketRequestPayload,
FetchCardFailurePayload,
MoveElementFailurePayload,
UpdateCardHeightFailurePayload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default defineComponent({
try {
await upload(file, element.value.id, FileRecordParentType.BOARDNODES);
element.value.content.caption = " ";
} catch (error) {
} catch {
emit("delete:element", element.value.id);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const hostname: ComputedRef<string> = computed(() => {
try {
const urlObject = new URL(props.url);
return urlObject.hostname;
} catch (e) {
} catch {
return "";
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const useMetaTagExtractorApi = () => {
const metaTagResult: MetaTagResult = mapMetaTagResponse(res.data);

return metaTagResult;
} catch (e) {
} catch {
return {
url: "",
title: "",
Expand Down
Loading

0 comments on commit d953d10

Please sign in to comment.