🚨 Fix linting errors

This commit is contained in:
Rune Harlyk
2026-01-02 22:00:25 +01:00
parent 3c557b69a3
commit 21bd4fa837
32 changed files with 438 additions and 245 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import { get } from 'svelte/store'
import { Err, Ok, type Result } from './utilities'
import { apiLocation } from './stores'
import { apiLocation } from './stores/location-store'
export const api = {
get<TResponse>(endpoint: string, params?: RequestInit) {
+3 -3
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ComponentType } from 'svelte'
import type { Component } from 'svelte'
type Variant = 'success' | 'error' | 'primary' | 'info' | 'warning'
@@ -11,12 +11,12 @@
class: klass = '',
children = null
} = $props<{
icon?: ComponentType
icon?: Component
title: string
description?: string | number
variant?: Variant
class?: string
children?: () => ComponentType
children?: () => Component
}>()
const Icon = $derived(icon)
@@ -119,7 +119,6 @@
})
onDestroy(() => {
canvas.remove()
gui_panel?.destroy()
})
@@ -4,7 +4,7 @@
max?: number
step?: number
value?: number
oninput?: (value: number) => void
oninput?: (value: Event) => void
}
let {
@@ -2,13 +2,14 @@
import { Github } from '../icons'
interface Props {
github: { url: string; version: string; active?: boolean; href?: string }
github: { href: string; active?: boolean }
}
let { github }: Props = $props()
</script>
{#if github.active}
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- external URL -->
<a href={github.href} class="btn btn-ghost" target="_blank" rel="noopener noreferrer">
<Github class="h-5 w-5" />
</a>
+19 -33
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { page } from '$app/state'
import { base } from '$app/paths'
import { resolve } from '$app/paths'
import { useFeatureFlags } from '$lib/stores/featureFlags'
import GithubButton from '../menu/GithubButton.svelte'
import LogoButton from '../menu/LogoButton.svelte'
@@ -33,11 +33,11 @@
const github = { href: 'https://github.com/' + page.data.github, active: true }
import type { ComponentType } from 'svelte'
import type { Component } from 'svelte'
type menuItem = {
title: string
icon: ComponentType
icon: Component
href?: string
feature: boolean
active?: boolean
@@ -45,13 +45,15 @@
}
function withBase(path: string) {
return `${base}${path.startsWith('/') ? path : '/' + path}`
return `${resolve('/')}${path.startsWith('/') ? path.slice(1) : path}`
}
let menuItems = $state<menuItem[]>([])
const { menuClicked } = $props()
$effect(() => {
menuItems = [
const activeTitle = $derived(page.data.title)
const menuItems = $derived<menuItem[]>(
[
{
title: 'Connection',
icon: WiFi,
@@ -79,7 +81,7 @@
title: 'Camera',
icon: Camera,
href: withBase('/peripherals/camera'),
feature: $features.camera
feature: true
},
{
title: 'Servo',
@@ -91,9 +93,9 @@
title: 'IMU',
icon: Rotate3d,
href: withBase('/peripherals/imu'),
feature: $features.imu || $features.mag || $features.bmp
feature: true
}
]
].map(sub => ({ ...sub, active: sub.title === activeTitle }))
},
{
title: 'WiFi',
@@ -118,7 +120,7 @@
href: withBase('/wifi/mdns'),
feature: true
}
]
].map(sub => ({ ...sub, active: sub.title === activeTitle }))
},
{
title: 'System',
@@ -147,36 +149,20 @@
title: 'Firmware Update',
icon: Update,
href: withBase('/system/update'),
feature:
feature: !!(
$features.ota ||
$features.upload_firmware ||
$features.download_firmware
)
}
]
].map(sub => ({ ...sub, active: sub.title === activeTitle }))
}
] as menuItem[]
})
].map(item => ({ ...item, active: item.title === activeTitle }))
)
const { menuClicked } = $props()
function setActiveMenuItem(targetTitle: string) {
menuItems.forEach(item => {
item.active = item.title === targetTitle
item.submenu?.forEach(subItem => {
subItem.active = subItem.title === targetTitle
})
})
menuItems = menuItems
const updateMenu = () => {
menuClicked()
}
$effect(() => {
setActiveMenuItem(page.data.title)
})
const updateMenu = (event: CustomEvent) => {
setActiveMenuItem(event.details)
}
</script>
<div class="flex h-full w-80 flex-col p-4 bg-base-200 text-base-content">
+3 -3
View File
@@ -1,10 +1,10 @@
<script lang="ts">
import MenuList from './MenuList.svelte'
import type { ComponentType } from 'svelte'
import type { Component } from 'svelte'
type MenuItem = {
title: string
icon: ComponentType
icon: Component
href?: string
feature: boolean
active?: boolean
@@ -38,7 +38,7 @@
</div>
</details>
{:else}
<a
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve --><a
href={menuItem.href}
class="font-bold"
class:bg-base-100={menuItem.active}
@@ -14,7 +14,7 @@
{...rest}
class="select select-bordered select-sm lg:select-md max-w-xs {rest.class || ''}"
>
{#each options as option}
{#each options as option (option)}
<option value={option}>{option}</option>
{/each}
</select>
+2 -1
View File
@@ -4,7 +4,8 @@ export const isFullscreen = writable(false)
export function toggleFullscreen() {
isFullscreen.update(state => {
!state ? document.documentElement.requestFullscreen() : document.exitFullscreen()
if (!state) document.documentElement.requestFullscreen()
else document.exitFullscreen()
return !state
})
}
+1 -1
View File
@@ -29,7 +29,7 @@ export const cacheModelFiles = async () => {
for (const [path, data] of Object.entries(files) as [path: string, data: Uint8Array][]) {
const normalizedPath = path.startsWith('/') ? path : '/' + path
const resolvedUrl = resolve(normalizedPath as any)
const resolvedUrl = `${resolve('/')}${normalizedPath}`
fileService?.saveFile(resolvedUrl, data)
fileService?.saveFile(normalizedPath, data)
}
+3 -1
View File
@@ -16,7 +16,9 @@ const registerFetchIntercept = async () => {
const pathOnly = urlObj.pathname
file = await fileService?.getFile(pathOnly)
if (file?.isOk() && file.inner) return new Response(new Uint8Array(file.inner))
} catch {}
} catch {
console.error('Failed to get file for ', url)
}
}
return originalFetch(resource, config)
+2 -2
View File
@@ -166,7 +166,7 @@
class="flex items-end gap-4 backdrop-blur-sm bg-base-300/60 h-min rounded-tr-2xl pl-0 p-3 border-t border-r border-base-content/5 pointer-events-auto"
>
<div class="join shadow-lg">
{#each modes as modeValue}
{#each modes as modeValue (modeValue)}
<button
class="btn join-item btn-sm transition-all duration-200"
class:btn-primary={$mode === modes.indexOf(modeValue)}
@@ -179,7 +179,7 @@
{#if $mode === ModesEnum.Walk}
<div class="join shadow-md">
{#each Object.values(WalkGaits) as gaitValue}
{#each Object.values(WalkGaits) as gaitValue (gaitValue)}
{#if typeof gaitValue === 'number'}
<button
class="btn join-item btn-xs transition-all duration-200"
+1 -1
View File
@@ -71,7 +71,7 @@
{#if active_devices.length === 0}
<div>No I2C devices found</div>
{:else}
{#each active_devices as device}
{#each active_devices as device (device.address)}
<div>[{device.address.toString(16)}] {device.part_number} - {device.name}</div>
{/each}
{/if}
+5 -1
View File
@@ -252,7 +252,11 @@
{/if}
</button>
{#if calibrationResult}
<span class="badge" class:badge-success={calibrationResult.success} class:badge-error={!calibrationResult.success}>
<span
class="badge"
class:badge-success={calibrationResult.success}
class:badge-error={!calibrationResult.success}
>
{calibrationResult.success ? 'Calibrated' : 'Failed'}
</span>
{/if}
@@ -59,7 +59,7 @@
</tr>
</thead>
<tbody>
{#each data.servos as servo, index}
{#each data.servos as servo, index (index)}
<tr class="hover:bg-base-200">
<td class="font-medium">Servo {index}</td>
<td>
@@ -30,7 +30,7 @@
{#if expanded}
<ul class="ml-4 border-l border-gray-600 mt-1">
{#each Object.entries(files) as [itemName, content]}
{#each Object.entries(files) as [itemName, content] (itemName)}
<li class="py-1">
{#if typeof content === 'object'}
<Folder name={itemName} files={content} {selected} {onDelete} />
@@ -1,6 +1,6 @@
<script lang="ts">
import { onDestroy, onMount } from 'svelte'
import type { ComponentType } from 'svelte'
import type { Component } from 'svelte'
import { modals } from 'svelte-modals'
import ConfirmDialog from '$lib/components/ConfirmDialog.svelte'
import SettingsCard from '$lib/components/SettingsCard.svelte'
@@ -111,7 +111,7 @@
}
interface ActionButtonDef {
icon: ComponentType
icon: Component
label: string
onClick: () => void
type?: string
@@ -253,7 +253,7 @@
</div>
<div class="mt-4 flex flex-wrap justify-end gap-2">
{#each actionButtons as button}
{#each actionButtons as button (button.label)}
{#if button.condition === undefined || button.condition()}
<ActionButton
onclick={button.onClick}
@@ -108,7 +108,7 @@
</tr>
</thead>
<tbody>
{#each githubReleases as release}
{#each githubReleases as release (release.tag_name)}
<tr
class={(
compareVersions(
@@ -119,8 +119,8 @@
'bg-primary text-primary-content'
: 'bg-base-100 h-14'}
>
<td align="left" class="text-base font-semibold">
<a
<td align="left" class="text-base font-semibold"
><!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- external URL --><a
href={release.html_url}
class="link link-hover"
target="_blank"
+5 -6
View File
@@ -1,6 +1,4 @@
<script lang="ts">
import { preventDefault } from 'svelte/legacy'
import { onMount, onDestroy } from 'svelte'
import { slide } from 'svelte/transition'
import { cubicOut } from 'svelte/easing'
@@ -16,7 +14,7 @@
let apSettings: ApSettings | null = $state(null)
let apStatus: ApStatus | null = $state(null)
let formField: Record<string, unknown> = $state()
let formField: Record<string, unknown> = $state({})
async function getAPStatus() {
const result = await api.get<ApStatus>('/api/wifi/ap/status')
@@ -87,7 +85,8 @@
apSettings = result.inner
}
function handleSubmitAP() {
function handleSubmitAP(e: Event) {
e.preventDefault()
if (!apSettings) return
let valid = true
@@ -205,7 +204,7 @@
>
<form
class="grid w-full grid-cols-1 content-center gap-x-4 p-0s sm:grid-cols-2"
onsubmit={preventDefault(handleSubmitAP)}
onsubmit={handleSubmitAP}
novalidate
bind:this={formField}
>
@@ -218,7 +217,7 @@
id="apmode"
bind:value={apSettings.provision_mode}
>
{#each provisionMode as mode}
{#each provisionMode as mode (mode.id)}
<option value={mode.id}>
{mode.text}
</option>
+1 -1
View File
@@ -88,7 +88,7 @@
</tr>
</thead>
<tbody>
{#each services as service}
{#each services as service (service.ip)}
<tr>
<td><Devices class="h-6 w-6" /></td>
<td>{service.name}</td>
+1 -1
View File
@@ -87,7 +87,7 @@
</div>
{:else}
<ul class="menu">
{#each listOfNetworks as network}
{#each listOfNetworks as network (network.ssid)}
<li>
<!-- svelte-ignore a11y_click_events_have_key_events -->
<div