function escapeHtml(s: string): string {
@@ -25,7 +26,7 @@ function escapeHtml(s: string): string {
export interface MapLayersOptions {
/** Leaflet API (from dynamic import). Required for creating markers and characters without static leaflet import. */
- L: typeof import('leaflet')
+ L: LeafletModule
map: L.Map
markerLayer: L.LayerGroup
layer: SmartTileLayerInstance
@@ -33,7 +34,7 @@ export interface MapLayersOptions {
getCurrentMapId: () => number
setCurrentMapId: (id: number) => void
setSelectedMapId: (id: number) => void
- getAuths: () => string[]
+ getAuths?: () => string[]
getTrackingCharacterId: () => number
setTrackingCharacterId: (id: number) => void
onMarkerContextMenu: (clientX: number, clientY: number, id: number, name: string) => void
@@ -69,7 +70,7 @@ export function createMapLayers(options: MapLayersOptions): MapLayersManager {
getCurrentMapId,
setCurrentMapId,
setSelectedMapId,
- getAuths,
+ getAuths: _getAuths,
getTrackingCharacterId,
setTrackingCharacterId,
onMarkerContextMenu,
diff --git a/frontend-nuxt/composables/useRecentLocations.ts b/frontend-nuxt/composables/useRecentLocations.ts
index 125894d..759e93f 100644
--- a/frontend-nuxt/composables/useRecentLocations.ts
+++ b/frontend-nuxt/composables/useRecentLocations.ts
@@ -26,7 +26,7 @@ function saveRecent(list: RecentLocation[]) {
if (import.meta.server) return
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(list.slice(0, MAX_RECENT)))
- } catch (_) {}
+ } catch { /* ignore */ }
}
export function useRecentLocations() {
diff --git a/frontend-nuxt/layouts/default.vue b/frontend-nuxt/layouts/default.vue
index 673f912..95bd1b8 100644
--- a/frontend-nuxt/layouts/default.vue
+++ b/frontend-nuxt/layouts/default.vue
@@ -12,7 +12,7 @@
type="checkbox"
class="drawer-toggle"
@change="onDrawerChange"
- />
+ >
@@ -87,7 +87,7 @@
class="toggle toggle-sm toggle-primary shrink-0"
:checked="dark"
@change="onThemeToggle"
- />
+ >
@@ -177,7 +177,7 @@
class="toggle toggle-sm toggle-primary shrink-0"
:checked="dark"
@change="onThemeToggle"
- />
+ >
@@ -296,7 +296,7 @@ async function loadConfig(loadToken: number) {
const config = await useMapApi().getConfig()
if (loadToken !== loadId) return
if (config?.title) title.value = config.title
- } catch (_) {}
+ } catch { /* ignore */ }
}
onMounted(() => {
diff --git a/frontend-nuxt/lib/Character.ts b/frontend-nuxt/lib/Character.ts
index 4eb10ba..8f35a3c 100644
--- a/frontend-nuxt/lib/Character.ts
+++ b/frontend-nuxt/lib/Character.ts
@@ -2,7 +2,7 @@ import type L from 'leaflet'
import { getColorForCharacterId, type CharacterColors } from '~/lib/characterColors'
import { HnHMaxZoom } from '~/lib/LeafletCustomTypes'
-export type LeafletApi = typeof import('leaflet')
+export type LeafletApi = L
function buildCharacterIconUrl(colors: CharacterColors): string {
const svg =
diff --git a/frontend-nuxt/lib/Marker.ts b/frontend-nuxt/lib/Marker.ts
index 3e04a76..d00960c 100644
--- a/frontend-nuxt/lib/Marker.ts
+++ b/frontend-nuxt/lib/Marker.ts
@@ -48,7 +48,7 @@ export interface MarkerIconOptions {
fallbackIconUrl?: string
}
-export type LeafletApi = typeof import('leaflet')
+export type LeafletApi = L
export function createMarker(
data: MarkerData,
diff --git a/frontend-nuxt/lib/UniqueList.ts b/frontend-nuxt/lib/UniqueList.ts
index 6d05940..903cf9a 100644
--- a/frontend-nuxt/lib/UniqueList.ts
+++ b/frontend-nuxt/lib/UniqueList.ts
@@ -39,7 +39,10 @@ export function uniqueListUpdate(
if (addCallback) {
elementsToAdd.forEach((it) => addCallback(it))
}
- elementsToRemove.forEach((it) => delete list.elements[String(it.id)])
+ const toRemove = new Set(elementsToRemove.map((it) => String(it.id)))
+ list.elements = Object.fromEntries(
+ Object.entries(list.elements).filter(([id]) => !toRemove.has(id))
+ ) as Record
elementsToAdd.forEach((it) => (list.elements[String(it.id)] = it))
}
diff --git a/frontend-nuxt/lib/__tests__/Character.test.ts b/frontend-nuxt/lib/__tests__/Character.test.ts
index a2085d7..130468e 100644
--- a/frontend-nuxt/lib/__tests__/Character.test.ts
+++ b/frontend-nuxt/lib/__tests__/Character.test.ts
@@ -1,5 +1,9 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
+import type L from 'leaflet'
+import type { Map, LayerGroup } from 'leaflet'
+import { createCharacter, type CharacterData, type CharacterMapViewRef } from '../Character'
+
vi.mock('leaflet', () => {
const markerMock = {
on: vi.fn().mockReturnThis(),
@@ -21,9 +25,6 @@ vi.mock('~/lib/LeafletCustomTypes', () => ({
HnHMaxZoom: 6,
}))
-import type L from 'leaflet'
-import { createCharacter, type CharacterData, type CharacterMapViewRef } from '../Character'
-
function getL(): L {
return require('leaflet').default
}
@@ -44,12 +45,12 @@ function makeMapViewRef(mapid = 1): CharacterMapViewRef {
map: {
unproject: vi.fn(() => ({ lat: 0, lng: 0 })),
removeLayer: vi.fn(),
- } as unknown as import('leaflet').Map,
+ } as unknown as Map,
mapid,
markerLayer: {
removeLayer: vi.fn(),
addLayer: vi.fn(),
- } as unknown as import('leaflet').LayerGroup,
+ } as unknown as LayerGroup,
}
}
diff --git a/frontend-nuxt/lib/__tests__/Marker.test.ts b/frontend-nuxt/lib/__tests__/Marker.test.ts
index 6029fa2..3612fcb 100644
--- a/frontend-nuxt/lib/__tests__/Marker.test.ts
+++ b/frontend-nuxt/lib/__tests__/Marker.test.ts
@@ -1,5 +1,9 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
+import L from 'leaflet'
+import type { Map, LayerGroup } from 'leaflet'
+import { createMarker, type MarkerData, type MapViewRef } from '../Marker'
+
vi.mock('leaflet', () => {
const markerMock = {
on: vi.fn().mockReturnThis(),
@@ -14,24 +18,19 @@ vi.mock('leaflet', () => {
return {
default: {
marker: vi.fn(() => markerMock),
- Icon: class {},
+ Icon: vi.fn(),
},
marker: vi.fn(() => markerMock),
- Icon: class {},
+ Icon: vi.fn(),
}
})
vi.mock('~/lib/LeafletCustomTypes', () => ({
HnHMaxZoom: 6,
TileSize: 100,
- ImageIcon: class {
- constructor(_opts: Record) {}
- },
+ ImageIcon: vi.fn(),
}))
-import L from 'leaflet'
-import { createMarker, type MarkerData, type MapViewRef } from '../Marker'
-
function makeMarkerData(overrides: Partial = {}): MarkerData {
return {
id: 1,
@@ -48,12 +47,12 @@ function makeMapViewRef(): MapViewRef {
return {
map: {
unproject: vi.fn(() => ({ lat: 0, lng: 0 })),
- } as unknown as import('leaflet').Map,
+ } as unknown as Map,
mapid: 1,
markerLayer: {
removeLayer: vi.fn(),
addLayer: vi.fn(),
- } as unknown as import('leaflet').LayerGroup,
+ } as unknown as LayerGroup,
}
}
diff --git a/frontend-nuxt/pages/admin/index.vue b/frontend-nuxt/pages/admin/index.vue
index 6d669e5..2ec8184 100644
--- a/frontend-nuxt/pages/admin/index.vue
+++ b/frontend-nuxt/pages/admin/index.vue
@@ -58,7 +58,7 @@
placeholder="Search users…"
class="input input-sm input-bordered w-full min-h-11 touch-manipulation"
aria-label="Search users"
- />
+ >
@@ -121,7 +121,7 @@
| Hidden |
Priority |
- |
+ |
@@ -159,7 +159,7 @@
v-model="settings.prefix"
type="text"
class="input input-sm w-full min-h-11 touch-manipulation"
- />
+ >
@@ -211,7 +211,7 @@