From 749062bed65a0f740988399ae591d259c71fdc3b Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Mon, 27 Jan 2025 17:47:42 +0100 Subject: frontend/lint: Fix miscellaneous lint issues --- frontend/src/lib/Filter.ts | 4 +--- frontend/src/lib/Navigation.ts | 2 +- frontend/src/lib/Shortcuts.ts | 2 +- frontend/src/lib/Update.ts | 4 +--- frontend/svelte.config.js | 1 - frontend/tests/Selection.test.ts | 10 +++++----- 6 files changed, 9 insertions(+), 14 deletions(-) diff --git a/frontend/src/lib/Filter.ts b/frontend/src/lib/Filter.ts index 8e419f3..1340eaf 100644 --- a/frontend/src/lib/Filter.ts +++ b/frontend/src/lib/Filter.ts @@ -25,9 +25,7 @@ type FilterMode = 'any' | 'all' | 'exact'; type Key = string | number | symbol; -type Filter = { - [Property in K]?: T | null; -}; +type Filter = Partial>; type AssocFilter = Filter< { diff --git a/frontend/src/lib/Navigation.ts b/frontend/src/lib/Navigation.ts index e6b17cd..5ed3ec5 100644 --- a/frontend/src/lib/Navigation.ts +++ b/frontend/src/lib/Navigation.ts @@ -41,7 +41,7 @@ export function parseFilter(params: URLSearchParams): T { try { return JsonURL.parse(param, { AQF: true, impliedObject: {} }) as T; - } catch (e) { + } catch { return {} as T; } } diff --git a/frontend/src/lib/Shortcuts.ts b/frontend/src/lib/Shortcuts.ts index 063bd40..300ddcb 100644 --- a/frontend/src/lib/Shortcuts.ts +++ b/frontend/src/lib/Shortcuts.ts @@ -37,7 +37,7 @@ type ModeSwitch = (typeof modeSwitches)[number]; function isModeSwitch(s: string): s is ModeSwitch { // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument - return modeSwitches.indexOf(s as any) !== -1; + return modeSwitches.includes(s as any); } type Key = Letter | Special; diff --git a/frontend/src/lib/Update.ts b/frontend/src/lib/Update.ts index 507dd52..13aec61 100644 --- a/frontend/src/lib/Update.ts +++ b/frontend/src/lib/Update.ts @@ -12,9 +12,7 @@ interface AssociationUpdate { options?: UpdateOptions | null; } -type Input = { - [Property in K]?: T | null; -}; +type Input = Partial>; abstract class Entry { key: K; diff --git a/frontend/svelte.config.js b/frontend/svelte.config.js index dbfdf53..6b76a53 100644 --- a/frontend/svelte.config.js +++ b/frontend/svelte.config.js @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ import adapter from '@sveltejs/adapter-static'; import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; import { readFileSync } from 'fs'; diff --git a/frontend/tests/Selection.test.ts b/frontend/tests/Selection.test.ts index 67e8c4c..c7847cd 100644 --- a/frontend/tests/Selection.test.ts +++ b/frontend/tests/Selection.test.ts @@ -86,7 +86,7 @@ test('deselects all', () => { selection = selection.none(); - expect(selection.ids).empty; + expect(selection.ids).toHaveLength(0); }); test('deselects a single item', () => { @@ -104,7 +104,7 @@ test('deselects multiple items', () => { selection = selection.update(2, true); selection = selection.update(2, true); - expect(selection.ids).empty; + expect(selection.ids).toHaveLength(0); }); test('retains selection', () => { @@ -130,7 +130,7 @@ test('is inactive after clearing', () => { selection.active = true; selection = selection.clear(); - expect(selection.active).false; + expect(selection.active).toBeFalsy(); }); test('can be toggled', () => { @@ -142,7 +142,7 @@ test('can be toggled', () => { selection = selection.all(); selection = selection.toggle(); expect(selection.active).toBe(false); - expect(selection.ids).empty; + expect(selection.ids).toHaveLength(0); }); test('can be cleared', () => { @@ -151,7 +151,7 @@ test('can be cleared', () => { selection = selection.all(); selection = selection.clear(); - expect(selection.ids).empty; + expect(selection.ids).toHaveLength(0); }); test('reports selected items', () => { -- cgit v1.2.3-2-gb3c3