From 703c641aeb586e8158ad619827d432574ec28fcf Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 29 Oct 2024 10:05:53 +0100 Subject: [PATCH] fix: lint issues --- frontend/src/components/base/Expandable.vue | 1 + frontend/src/components/misc/ApiConfig.vue | 1 + frontend/src/components/sharing/UserTeam.vue | 2 -- frontend/src/composables/useBodyClass.ts | 9 ++++--- .../src/composables/useCopyToClipboard.ts | 4 ++- frontend/src/helpers/checkAndSetApiUrl.ts | 1 + frontend/src/helpers/hourToDaytime.test.ts | 2 +- frontend/src/helpers/time/parseDateProp.ts | 2 +- frontend/src/modules/parseTaskText.test.ts | 26 +++++++++---------- frontend/src/registerServiceWorker.ts | 2 -- frontend/src/stores/auth.ts | 2 +- frontend/src/sw.ts | 3 --- .../views/project/helpers/useGanttTaskList.ts | 2 +- frontend/src/views/tasks/ShowTasks.vue | 1 - 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/frontend/src/components/base/Expandable.vue b/frontend/src/components/base/Expandable.vue index 663fc4379..6bb009220 100644 --- a/frontend/src/components/base/Expandable.vue +++ b/frontend/src/components/base/Expandable.vue @@ -73,6 +73,7 @@ function getHeight(el: HTMLElement) { * https://gist.github.com/paulirish/5d52fb081b3570c81e3a */ function forceLayout(el: HTMLElement) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions el.offsetTop } diff --git a/frontend/src/components/misc/ApiConfig.vue b/frontend/src/components/misc/ApiConfig.vue index 073d6afcb..6908bd803 100644 --- a/frontend/src/components/misc/ApiConfig.vue +++ b/frontend/src/components/misc/ApiConfig.vue @@ -117,6 +117,7 @@ async function setApiUrl() { success({message: t('apiConfig.success', {domain: apiDomain.value})}) configureApi.value = false emit('foundApi', apiUrl.value) + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { // Still not found, url is still invalid errorMsg.value = t('apiConfig.error', {domain: apiDomain.value}) diff --git a/frontend/src/components/sharing/UserTeam.vue b/frontend/src/components/sharing/UserTeam.vue index c6f6d5898..0a2e978ce 100644 --- a/frontend/src/components/sharing/UserTeam.vue +++ b/frontend/src/components/sharing/UserTeam.vue @@ -250,7 +250,6 @@ const sharableName = computed(() => { if (props.shareType === 'user') { searchService = shallowReactive(new UserService()) - // eslint-disable-next-line vue/no-ref-as-operand sharable = ref(new UserModel()) searchLabel.value = 'username' @@ -262,7 +261,6 @@ if (props.shareType === 'user') { } } else if (props.shareType === 'team') { searchService = new TeamService() - // eslint-disable-next-line vue/no-ref-as-operand sharable = ref(new TeamModel()) searchLabel.value = 'name' diff --git a/frontend/src/composables/useBodyClass.ts b/frontend/src/composables/useBodyClass.ts index b5bbf9ff1..e145e7bc7 100644 --- a/frontend/src/composables/useBodyClass.ts +++ b/frontend/src/composables/useBodyClass.ts @@ -5,9 +5,12 @@ export function useBodyClass(className: string, defaultValue = false) { const isActive = ref(defaultValue) watchEffect(() => { - isActive.value - ? document.body.classList.add(className) - : document.body.classList.remove(className) + if(isActive.value) { + document.body.classList.add(className) + return + } + + document.body.classList.remove(className) }) tryOnBeforeUnmount(() => isActive.value && document.body.classList.remove(className)) diff --git a/frontend/src/composables/useCopyToClipboard.ts b/frontend/src/composables/useCopyToClipboard.ts index 69fa19140..b5a3e2c93 100644 --- a/frontend/src/composables/useCopyToClipboard.ts +++ b/frontend/src/composables/useCopyToClipboard.ts @@ -24,7 +24,8 @@ export function useCopyToClipboard() { if (!successful) { throw new Error() } - } catch (err) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + } catch (e) { error(t('misc.copyError')) } @@ -38,6 +39,7 @@ export function useCopyToClipboard() { } try { await navigator.clipboard.writeText(text) + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch(e) { error(t('misc.copyError')) } diff --git a/frontend/src/helpers/checkAndSetApiUrl.ts b/frontend/src/helpers/checkAndSetApiUrl.ts index 1144dff27..282c7281f 100644 --- a/frontend/src/helpers/checkAndSetApiUrl.ts +++ b/frontend/src/helpers/checkAndSetApiUrl.ts @@ -40,6 +40,7 @@ export const checkAndSetApiUrl = (url: string | undefined | null): Promise { const mar = new Date(2022, 2, 32) vi.setSystemTime(mar) - const result = parseTaskText(`Lorem Ipsum 31st`) + const result = parseTaskText('Lorem Ipsum 31st') const expectedDate = new Date(2022, 4, 31) expect(result.text).toBe('Lorem Ipsum') @@ -617,7 +617,7 @@ describe('Parse Task Text', () => { expect(result.labels[1]).toBe('label2') }) it('should correctly parse labels with spaces in them', () => { - const result = parseTaskText(`Lorem *'label with space' Ipsum`) + const result = parseTaskText('Lorem *\'label with space\' Ipsum') expect(result.text).toBe('Lorem Ipsum') expect(result.labels).toHaveLength(1) @@ -647,25 +647,25 @@ describe('Parse Task Text', () => { expect(result.project).toBe('project') }) it('should parse a project with a space in it', () => { - const result = parseTaskText(`Lorem Ipsum +'project with long name'`) + const result = parseTaskText('Lorem Ipsum +\'project with long name\'') expect(result.text).toBe('Lorem Ipsum') expect(result.project).toBe('project with long name') }) it('should parse a project with a space in it and "', () => { - const result = parseTaskText(`Lorem Ipsum +"project with long name"`) + const result = parseTaskText('Lorem Ipsum +"project with long name"') expect(result.text).toBe('Lorem Ipsum') expect(result.project).toBe('project with long name') }) it('should parse only the first project', () => { - const result = parseTaskText(`Lorem Ipsum +project1 +project2 +project3`) + const result = parseTaskText('Lorem Ipsum +project1 +project2 +project3') expect(result.text).toBe('Lorem Ipsum +project2 +project3') expect(result.project).toBe('project1') }) it('should parse a project that\'s called like a date as project', () => { - const result = parseTaskText(`Lorem Ipsum +today`) + const result = parseTaskText('Lorem Ipsum +today') expect(result.text).toBe('Lorem Ipsum') expect(result.project).toBe('today') @@ -681,14 +681,14 @@ describe('Parse Task Text', () => { expect(result.priority).toBe(PRIORITIES[p]) }) } - it(`should not parse an invalid priority`, () => { - const result = parseTaskText(`Lorem Ipsum !9999`) + it('should not parse an invalid priority', () => { + const result = parseTaskText('Lorem Ipsum !9999') expect(result.text).toBe('Lorem Ipsum !9999') expect(result.priority).toBe(null) }) - it(`should not parse an invalid priority but use the first valid one it finds`, () => { - const result = parseTaskText(`Lorem Ipsum !9999 !1`) + it('should not parse an invalid priority but use the first valid one it finds', () => { + const result = parseTaskText('Lorem Ipsum !9999 !1') expect(result.text).toBe('Lorem Ipsum !9999') expect(result.priority).toBe(1) @@ -724,7 +724,7 @@ describe('Parse Task Text', () => { expect(result.assignees[1]).toBe('user2') }) it('should parse an assignee with a space in it', () => { - const text = `Lorem Ipsum @'user with long name'` + const text = 'Lorem Ipsum @\'user with long name\'' const result = parseTaskText(text) expect(result.text).toBe(text) @@ -732,7 +732,7 @@ describe('Parse Task Text', () => { expect(result.assignees[0]).toBe('user with long name') }) it('should parse an assignee with a space in it and "', () => { - const text = `Lorem Ipsum @"user with long name"` + const text = 'Lorem Ipsum @"user with long name"' const result = parseTaskText(text) expect(result.text).toBe(text) @@ -740,7 +740,7 @@ describe('Parse Task Text', () => { expect(result.assignees[0]).toBe('user with long name') }) it('should parse an assignee who is called like a date as assignee', () => { - const text = `Lorem Ipsum @today` + const text = 'Lorem Ipsum @today' const result = parseTaskText(text) expect(result.text).toBe(text) diff --git a/frontend/src/registerServiceWorker.ts b/frontend/src/registerServiceWorker.ts index 8e0a30d2f..4d7b72621 100644 --- a/frontend/src/registerServiceWorker.ts +++ b/frontend/src/registerServiceWorker.ts @@ -1,5 +1,3 @@ -/* eslint-disable no-console */ - import {register} from 'register-service-worker' import {getFullBaseUrl} from './helpers/getFullBaseUrl' diff --git a/frontend/src/stores/auth.ts b/frontend/src/stores/auth.ts index f4c36bfd7..c84ee832d 100644 --- a/frontend/src/stores/auth.ts +++ b/frontend/src/stores/auth.ts @@ -247,7 +247,7 @@ export const useAuthStore = defineStore('auth', () => { isAuthenticated = info.exp >= ts // Settings should only be loaded from the api request, not via the jwt setUser(info, false) - } catch (e) { + } catch (_) { logout() } diff --git a/frontend/src/sw.ts b/frontend/src/sw.ts index 122204cdf..731466e84 100644 --- a/frontend/src/sw.ts +++ b/frontend/src/sw.ts @@ -1,6 +1,3 @@ -/* eslint-disable no-console */ -/* eslint-disable no-undef */ - import {getFullBaseUrl} from './helpers/getFullBaseUrl' declare let self: ServiceWorkerGlobalScope diff --git a/frontend/src/views/project/helpers/useGanttTaskList.ts b/frontend/src/views/project/helpers/useGanttTaskList.ts index eed634a7a..443106310 100644 --- a/frontend/src/views/project/helpers/useGanttTaskList.ts +++ b/frontend/src/views/project/helpers/useGanttTaskList.ts @@ -88,7 +88,7 @@ export function useGanttTaskList( // update the task with possible changes from server tasks.value.set(updatedTask.id, updatedTask) success('Saved') - } catch (e) { + } catch (_) { error('Something went wrong saving the task') // roll back changes tasks.value.set(task.id, oldTask) diff --git a/frontend/src/views/tasks/ShowTasks.vue b/frontend/src/views/tasks/ShowTasks.vue index c8bab0703..0efbb5faf 100644 --- a/frontend/src/views/tasks/ShowTasks.vue +++ b/frontend/src/views/tasks/ShowTasks.vue @@ -117,7 +117,6 @@ const showAll = computed(() => typeof props.dateFrom === 'undefined' || typeof p const pageTitle = computed(() => { // We need to define "key" because it is the first parameter in the array and we need the second const predefinedRange = Object.entries(DATE_RANGES) - // eslint-disable-next-line no-unused-vars .find(([, value]) => props.dateFrom === value[0] && props.dateTo === value[1]) ?.[0] if (typeof predefinedRange !== 'undefined') {