🎨 Lint project

This commit is contained in:
Rune Harlyk
2025-10-11 10:54:07 +02:00
parent 91a7b170fe
commit a77eb0b1e0
36 changed files with 77 additions and 72 deletions
-1
View File
@@ -7,7 +7,6 @@
"experimentalTernaries": true, "experimentalTernaries": true,
"printWidth": 100, "printWidth": 100,
"semi": false, "semi": false,
"svelteBracketNewLine": false,
"plugins": ["prettier-plugin-svelte"], "plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
} }
+8 -8
View File
@@ -2,20 +2,20 @@ import { get } from 'svelte/store'
import { Err, Ok, type Result } from './utilities' import { Err, Ok, type Result } from './utilities'
import { location } from './stores' import { location } from './stores'
export namespace api { export const api = {
export function get<TResponse>(endpoint: string, params?: RequestInit) { get<TResponse>(endpoint: string, params?: RequestInit) {
return sendRequest<TResponse>(endpoint, 'GET', null, params) return sendRequest<TResponse>(endpoint, 'GET', null, params)
} },
export function post<TResponse>(endpoint: string, data?: unknown) { post<TResponse>(endpoint: string, data?: unknown) {
return sendRequest<TResponse>(endpoint, 'POST', data) return sendRequest<TResponse>(endpoint, 'POST', data)
} },
export function put<TResponse>(endpoint: string, data?: unknown) { put<TResponse>(endpoint: string, data?: unknown) {
return sendRequest<TResponse>(endpoint, 'PUT', data) return sendRequest<TResponse>(endpoint, 'PUT', data)
} },
export function remove<TResponse>(endpoint: string) { remove<TResponse>(endpoint: string) {
return sendRequest<TResponse>(endpoint, 'DELETE') return sendRequest<TResponse>(endpoint, 'DELETE')
} }
} }
+4 -2
View File
@@ -1,4 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { ComponentType } from 'svelte'
type Variant = 'success' | 'error' | 'primary' | 'info' | 'warning' type Variant = 'success' | 'error' | 'primary' | 'info' | 'warning'
const { const {
@@ -9,12 +11,12 @@
class: klass = '', class: klass = '',
children = null children = null
} = $props<{ } = $props<{
icon?: any icon?: ComponentType
title: string title: string
description?: string | number description?: string | number
variant?: Variant variant?: Variant
class?: string class?: string
children?: () => any children?: () => ComponentType
}>() }>()
const Icon = $derived(icon) const Icon = $derived(icon)
@@ -24,7 +24,6 @@
jointNames, jointNames,
currentKinematic, currentKinematic,
walkGait, walkGait,
walkGaits,
walkGaitToMode walkGaitToMode
} from '$lib/stores' } from '$lib/stores'
import { import {
@@ -11,7 +11,7 @@
let type = $derived(show ? 'text' : 'password') let type = $derived(show ? 'text' : 'password')
const handleInput = (e: any) => (value = e.target.value) const handleInput = (e: Event) => (value = (e.target as HTMLInputElement).value)
const togglePassword = () => (show = !show) const togglePassword = () => (show = !show)
</script> </script>
@@ -3,8 +3,8 @@
min?: number min?: number
max?: number max?: number
step?: number step?: number
value?: any value?: number
oninput?: any oninput?: (value: number) => void
} }
let { let {
@@ -2,7 +2,7 @@
import { Github } from '../icons' import { Github } from '../icons'
interface Props { interface Props {
github: any github: { url: string; version: string }
} }
let { github }: Props = $props() let { github }: Props = $props()
+4 -2
View File
@@ -33,9 +33,11 @@
const github = { href: 'https://github.com/' + page.data.github, active: true } const github = { href: 'https://github.com/' + page.data.github, active: true }
import type { ComponentType } from 'svelte'
type menuItem = { type menuItem = {
title: string title: string
icon: ConstructorOfATypedSvelteComponent icon: ComponentType
href?: string href?: string
feature: boolean feature: boolean
active?: boolean active?: boolean
@@ -172,7 +174,7 @@
setActiveMenuItem(page.data.title) setActiveMenuItem(page.data.title)
}) })
const updateMenu = (event: any) => { const updateMenu = (event: CustomEvent) => {
setActiveMenuItem(event.details) setActiveMenuItem(event.details)
} }
</script> </script>
+4 -2
View File
@@ -1,8 +1,10 @@
<script lang="ts"> <script lang="ts">
import MenuList from './MenuList.svelte' import MenuList from './MenuList.svelte'
import type { ComponentType } from 'svelte'
type MenuItem = { type MenuItem = {
title: string title: string
icon: ConstructorOfATypedSvelteComponent icon: ComponentType
href?: string href?: string
feature: boolean feature: boolean
active?: boolean active?: boolean
@@ -17,7 +19,7 @@
</script> </script>
<ul class={klass + ' menu w-full'}> <ul class={klass + ' menu w-full'}>
{#each menuItems as MenuItem[] as menuItem, i (menuItem.title)} {#each menuItems as MenuItem[] as menuItem (menuItem.title)}
{#if menuItem.feature} {#if menuItem.feature}
<li> <li>
{#if menuItem.submenu} {#if menuItem.submenu}
@@ -1,4 +1,4 @@
import { writable, derived, type Writable } from 'svelte/store' import { writable } from 'svelte/store'
type StateType = 'info' | 'success' | 'warning' | 'error' type StateType = 'info' | 'success' | 'warning' | 'error'
@@ -6,12 +6,12 @@
import { slide } from 'svelte/transition' import { slide } from 'svelte/transition'
let chartElement: HTMLCanvasElement let chartElement: HTMLCanvasElement
let chart: Chart let chart: Chart<'line', number[], string>
interface Props { interface Props {
label: any label: string
data: number[] data: number[]
title: any title: string
} }
let { label, data, title }: Props = $props() let { label, data, title }: Props = $props()
@@ -3,7 +3,7 @@
options?: string[] options?: string[]
selectedOption?: string selectedOption?: string
change?: () => void change?: () => void
[key: string]: any [key: string]: unknown
} }
let { options = [], selectedOption = $bindable(''), ...rest }: Props = $props() let { options = [], selectedOption = $bindable(''), ...rest }: Props = $props()
+8 -8
View File
@@ -58,14 +58,14 @@ export default class SceneBuilder {
public ground!: Mesh public ground!: Mesh
public renderer!: WebGLRenderer public renderer!: WebGLRenderer
public orbit: OrbitControls public orbit: OrbitControls
public callback: Function | undefined public callback: (() => void) | undefined
public gridHelper!: GridHelper public gridHelper!: GridHelper
public model!: URDFRobot public model!: URDFRobot
public liveStreamTexture!: CanvasTexture public liveStreamTexture!: CanvasTexture
private fog!: FogExp2 private fog!: FogExp2
private isLoaded: boolean = false private isLoaded: boolean = false
public isDragging: boolean = false public isDragging: boolean = false
highlightMaterial: any highlightMaterial: MeshPhongMaterial
sky!: Sky sky!: Sky
transformControl: TransformControls transformControl: TransformControls
public modelGroup!: Group public modelGroup!: Group
@@ -229,7 +229,7 @@ export default class SceneBuilder {
return this return this
} }
public addRenderCb = (callback: Function) => { public addRenderCb = (callback: () => void) => {
this.callback = callback this.callback = callback
return this return this
} }
@@ -275,7 +275,7 @@ export default class SceneBuilder {
isJoint = (j: URDFJoint) => j.isURDFJoint && j.jointType !== 'fixed' isJoint = (j: URDFJoint) => j.isURDFJoint && j.jointType !== 'fixed'
highlightLinkGeometry = (m: URDFMimicJoint, revert: boolean, material: MeshPhongMaterial) => { highlightLinkGeometry = (m: URDFMimicJoint, revert: boolean, material: MeshPhongMaterial) => {
const traverse = (c: any) => { const traverse = (c: Object3D) => {
if (c.type === 'Mesh') { if (c.type === 'Mesh') {
if (revert) { if (revert) {
c.material = c.__origMaterial c.material = c.__origMaterial
@@ -298,9 +298,9 @@ export default class SceneBuilder {
traverse(m) traverse(m)
} }
public addTransformControls = (model: any) => { public addTransformControls = (model: Object3D) => {
this.transformControl = new TransformControls(this.camera, this.renderer.domElement) this.transformControl = new TransformControls(this.camera, this.renderer.domElement)
this.transformControl.addEventListener('dragging-changed', (event: any) => { this.transformControl.addEventListener('dragging-changed', (event: { value: boolean }) => {
this.orbit.enabled = !event.value this.orbit.enabled = !event.value
this.isDragging = !event.value this.isDragging = !event.value
}) })
@@ -310,7 +310,7 @@ export default class SceneBuilder {
return this return this
} }
public addModel = (model: any) => { public addModel = (model: URDFRobot) => {
this.modelGroup = new Group() this.modelGroup = new Group()
this.modelGroup.add(model) this.modelGroup.add(model)
this.model = model this.model = model
@@ -318,7 +318,7 @@ export default class SceneBuilder {
return this return this
} }
public addDragControl = (updateAngle: any) => { public addDragControl = (updateAngle: (angles: Record<string, number>) => void) => {
const highlightColor = '#FFFFFF' const highlightColor = '#FFFFFF'
const highlightMaterial = new MeshPhongMaterial({ const highlightMaterial = new MeshPhongMaterial({
shininess: 10, shininess: 10,
+1 -1
View File
@@ -1,7 +1,7 @@
import { type Analytics } from '$lib/types/models' import { type Analytics } from '$lib/types/models'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
let analytics_data = { const analytics_data = {
uptime: <number[]>[], uptime: <number[]>[],
free_heap: <number[]>[], free_heap: <number[]>[],
total_heap: <number[]>[], total_heap: <number[]>[],
+1 -1
View File
@@ -8,7 +8,7 @@ import ChartWidget from '$lib/components/widget/ChartWidget.svelte'
export interface WidgetConfig { export interface WidgetConfig {
id: string | number id: string | number
component: keyof typeof WidgetComponents component: keyof typeof WidgetComponents
props?: Record<string, any> props?: Record<string, unknown>
} }
export interface WidgetContainerConfig { export interface WidgetContainerConfig {
+2 -2
View File
@@ -1,7 +1,7 @@
import type { DownloadOTA } from '$lib/types/models' import type { DownloadOTA } from '$lib/types/models'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
let telemetry_data = { const telemetry_data = {
rssi: { rssi: {
rssi: 0 rssi: 0
}, },
@@ -13,7 +13,7 @@ let telemetry_data = {
} }
function createTelemetry() { function createTelemetry() {
const { subscribe, set, update } = writable(telemetry_data) const { subscribe, update } = writable(telemetry_data)
return { return {
subscribe, subscribe,
+5 -5
View File
@@ -1,12 +1,12 @@
declare module 'uzip' { declare module 'uzip' {
interface UZIP { interface UZIP {
parse(data: Uint8Array | ArrayBuffer): any parse(data: Uint8Array | ArrayBuffer): Record<string, Uint8Array>
compress(data: any): Uint8Array | ArrayBuffer compress(data: Record<string, Uint8Array>): Uint8Array | ArrayBuffer
compressRaw(data: Uint8Array | ArrayBuffer): Uint8Array | ArrayBuffer compressRaw(data: Uint8Array | ArrayBuffer): Uint8Array | ArrayBuffer
decompress(data: Uint8Array | ArrayBuffer): any decompress(data: Uint8Array | ArrayBuffer): Record<string, Uint8Array>
decompressRaw(data: Uint8Array | ArrayBuffer): Uint8Array | ArrayBuffer decompressRaw(data: Uint8Array | ArrayBuffer): Uint8Array | ArrayBuffer
encode(data: any): Uint8Array | ArrayBuffer encode(data: Record<string, Uint8Array>): Uint8Array | ArrayBuffer
decode(data: Uint8Array | ArrayBuffer): any decode(data: Uint8Array | ArrayBuffer): Record<string, Uint8Array>
} }
const uzip: UZIP const uzip: UZIP
+1 -1
View File
@@ -3,7 +3,7 @@ export class throttler {
constructor() { constructor() {
this._throttlePause = false this._throttlePause = false
} }
throttle = (callback: Function, time: number) => { throttle = (callback: () => void, time: number) => {
if (this._throttlePause) return if (this._throttlePause) return
this._throttlePause = true this._throttlePause = true
+2 -2
View File
@@ -1,12 +1,12 @@
export const toUint8 = (number: number, min: number, max: number) => { export const toUint8 = (number: number, min: number, max: number) => {
number = Math.max(min, Math.min(max, number)) number = Math.max(min, Math.min(max, number))
let scaled = ((number - min) / (max - min)) * 255 const scaled = ((number - min) / (max - min)) * 255
return Math.round(scaled) & 0xff return Math.round(scaled) & 0xff
} }
export const toInt8 = (number: number, min: number, max: number) => { export const toInt8 = (number: number, min: number, max: number) => {
number = Math.max(min, Math.min(max, number)) number = Math.max(min, Math.min(max, number))
let scaled = ((number - min) / (max - min)) * 255 - 128 const scaled = ((number - min) / (max - min)) * 255 - 128
return Math.max(-128, Math.min(127, Math.round(scaled))) | 0 return Math.max(-128, Math.min(127, Math.round(scaled))) | 0
} }
+4 -4
View File
@@ -3,18 +3,18 @@ import { Ok } from './ok'
export type Result<T = unknown, E = unknown, F = unknown> = Ok<T> | Err<E, F> export type Result<T = unknown, E = unknown, F = unknown> = Ok<T> | Err<E, F>
export namespace Result { export const Result = {
/** /**
* @returns `Ok<T>` * @returns `Ok<T>`
*/ */
export function ok<T = unknown>(value: T) { ok<T = unknown>(value: T) {
return Ok.new(value) return Ok.new(value)
} },
/** /**
* @returns `Err<E, F>` * @returns `Err<E, F>`
*/ */
export function err<E = unknown, F = unknown>(error: E, exception?: F) { err<E = unknown, F = unknown>(error: E, exception?: F) {
return Err.new(error, exception) return Err.new(error, exception)
} }
} }
+4 -3
View File
@@ -83,7 +83,7 @@
telemetry.setRSSI(0) telemetry.setRSSI(0)
} }
const handleError = (data: any) => console.error(data) const handleError = (data: unknown) => console.error(data)
const handleAnalytics = (data: Analytics) => analytics.addData(data) const handleAnalytics = (data: Analytics) => analytics.addData(data)
@@ -115,13 +115,14 @@
</div> </div>
<Modals> <Modals>
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
{#snippet backdrop()} {#snippet backdrop()}
<div <div
class="fixed inset-0 z-40 max-h-full max-w-full bg-black/20 backdrop-blur-sm" class="fixed inset-0 z-40 max-h-full max-w-full bg-black/20 backdrop-blur-sm"
transition:fade transition:fade
onclick={modals.closeAll} onclick={modals.closeAll}
onkeydown={e => e.key === 'Escape' && modals.closeAll()}
role="button"
tabindex="0"
></div> ></div>
{/snippet} {/snippet}
</Modals> </Modals>
+2 -3
View File
@@ -9,7 +9,6 @@
modes, modes,
type Modes, type Modes,
ModesEnum, ModesEnum,
walkGaits,
WalkGaits, WalkGaits,
walkGait, walkGait,
walkGaitLabels walkGaitLabels
@@ -61,9 +60,9 @@
}) })
left.on('move', (_, data) => handleJoyMove('left', data.vector)) left.on('move', (_, data) => handleJoyMove('left', data.vector))
left.on('end', (_, __) => handleJoyMove('left', { x: 0, y: 0 })) left.on('end', () => handleJoyMove('left', { x: 0, y: 0 }))
right.on('move', (_, data) => handleJoyMove('right', data.vector)) right.on('move', (_, data) => handleJoyMove('right', data.vector))
right.on('end', (_, __) => handleJoyMove('right', { x: 0, y: 0 })) right.on('end', () => handleJoyMove('right', { x: 0, y: 0 }))
}) })
const handleJoyMove = (key: 'left' | 'right', data: vector) => { const handleJoyMove = (key: 'left' | 'right', data: vector) => {
@@ -25,7 +25,7 @@
{#await getCameraSettings()} {#await getCameraSettings()}
<Spinner /> <Spinner />
{:then _} {:then}
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
<button class="btn btn-primary" type="button" onclick={updateCameraSettings} <button class="btn btn-primary" type="button" onclick={updateCameraSettings}
>Update camera settings</button >Update camera settings</button
+1 -1
View File
@@ -30,7 +30,7 @@
return () => socket.off(MessageTopic.i2cScan, handleScan) return () => socket.off(MessageTopic.i2cScan, handleScan)
}) })
const handleScan = (data: any) => { const handleScan = (data: { addresses: number[] }) => {
active_devices = data.addresses.map( active_devices = data.addresses.map(
(address: number) => (address: number) =>
i2cDevices.find(device => device.address === address) || { i2cDevices.find(device => device.address === address) || {
@@ -15,7 +15,7 @@
return () => socket.off(MessageTopic.peripheralSettings, handleSettings) return () => socket.off(MessageTopic.peripheralSettings, handleSettings)
}) })
const handleSettings = (data: any) => { const handleSettings = (data: Record<string, unknown>) => {
settings = data settings = data
} }
+1 -1
View File
@@ -173,7 +173,7 @@
}) })
} }
const updateChartData = (chart: Chart, data: number[], label: string) => { const updateChartData = (chart: Chart, data: number[]) => {
chart.data.labels = data chart.data.labels = data
chart.data.datasets[0].data = data chart.data.datasets[0].data = data
chart.options.scales!.y!.min = Math.min(...data) - 1 chart.options.scales!.y!.min = Math.min(...data) - 1
@@ -3,7 +3,7 @@
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { RotateCw, RotateCcw } from '$lib/components/icons' import { RotateCw, RotateCcw } from '$lib/components/icons'
interface Props { interface Props {
data?: any data?: Record<string, unknown>
servoId?: number servoId?: number
pwm?: number pwm?: number
} }
@@ -1,5 +1,4 @@
<script lang="ts"> <script lang="ts">
import SettingsCard from '$lib/components/SettingsCard.svelte'
import Spinner from '$lib/components/Spinner.svelte' import Spinner from '$lib/components/Spinner.svelte'
import Folder from './Folder.svelte' import Folder from './Folder.svelte'
import { api } from '$lib/api' import { api } from '$lib/api'
@@ -164,7 +163,7 @@
{#await getContent(filename)} {#await getContent(filename)}
<Spinner /> <Spinner />
{:then _} {:then}
{#if isEditing} {#if isEditing}
<textarea <textarea
class="w-full h-[300px] sm:h-[500px] font-mono p-2 bg-gray-800 text-white" class="w-full h-[300px] sm:h-[500px] font-mono p-2 bg-gray-800 text-white"
@@ -6,7 +6,7 @@
interface Props { interface Props {
expanded?: boolean expanded?: boolean
name: string name: string
files: any files: unknown[]
selected: (name: string) => void selected: (name: string) => void
onDelete: (name: string) => void onDelete: (name: string) => void
} }
@@ -1,6 +1,5 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { page } from '$app/stores'
import SettingsCard from '$lib/components/SettingsCard.svelte' import SettingsCard from '$lib/components/SettingsCard.svelte'
import { slide } from 'svelte/transition' import { slide } from 'svelte/transition'
import { cubicOut } from 'svelte/easing' import { cubicOut } from 'svelte/easing'
@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import { onDestroy, onMount } from 'svelte' import { onDestroy, onMount } from 'svelte'
import type { ComponentType } from 'svelte'
import { modals } from 'svelte-modals' import { modals } from 'svelte-modals'
import ConfirmDialog from '$lib/components/ConfirmDialog.svelte' import ConfirmDialog from '$lib/components/ConfirmDialog.svelte'
import SettingsCard from '$lib/components/SettingsCard.svelte' import SettingsCard from '$lib/components/SettingsCard.svelte'
@@ -110,7 +111,7 @@
} }
interface ActionButtonDef { interface ActionButtonDef {
icon: any icon: ComponentType
label: string label: string
onClick: () => void onClick: () => void
type?: string type?: string
@@ -28,7 +28,10 @@
console.error('Error:', result.inner) console.error('Error:', result.inner)
return return
} }
return result.inner as any return result.inner as {
tag_name: string
assets: Array<{ name: string; browser_download_url: string }>
}
} }
async function postGithubDownload(url: string) { async function postGithubDownload(url: string) {
@@ -39,7 +42,7 @@
} }
} }
function confirmGithubUpdate(assets: any) { function confirmGithubUpdate(assets: Array<{ name: string; browser_download_url: string }>) {
let url = '' let url = ''
// iterate over assets and find the correct one // iterate over assets and find the correct one
for (let i = 0; i < assets.length; i++) { for (let i = 0; i < assets.length; i++) {
@@ -154,7 +157,7 @@
</table> </table>
</div> </div>
</div> </div>
{:catch error} {:catch}
<div class="alert alert-error shadow-lg"> <div class="alert alert-error shadow-lg">
<Error class="h-6 w-6 shrink-0" /> <Error class="h-6 w-6 shrink-0" />
<span <span
+1 -1
View File
@@ -16,7 +16,7 @@
let apSettings: ApSettings | null = $state(null) let apSettings: ApSettings | null = $state(null)
let apStatus: ApStatus | null = $state(null) let apStatus: ApStatus | null = $state(null)
let formField: any = $state() let formField: Record<string, unknown> = $state()
async function getAPStatus() { async function getAPStatus() {
const result = await api.get<ApStatus>('/api/wifi/ap/status') const result = await api.get<ApStatus>('/api/wifi/ap/status')
-1
View File
@@ -3,7 +3,6 @@
import { api } from '$lib/api' import { api } from '$lib/api'
import SettingsCard from '$lib/components/SettingsCard.svelte' import SettingsCard from '$lib/components/SettingsCard.svelte'
import { AP, Home, MAC, Devices } from '$lib/components/icons' import { AP, Home, MAC, Devices } from '$lib/components/icons'
import Spinner from '$lib/components/Spinner.svelte'
import StatusItem from '$lib/components/StatusItem.svelte' import StatusItem from '$lib/components/StatusItem.svelte'
import { cubicOut } from 'svelte/easing' import { cubicOut } from 'svelte/easing'
import { slide } from 'svelte/transition' import { slide } from 'svelte/transition'
+1 -1
View File
@@ -87,7 +87,7 @@
</div> </div>
{:else} {:else}
<ul class="menu"> <ul class="menu">
{#each listOfNetworks as network, i} {#each listOfNetworks as network}
<li> <li>
<!-- svelte-ignore a11y_click_events_have_key_events --> <!-- svelte-ignore a11y_click_events_have_key_events -->
<div <div
+1 -1
View File
@@ -63,7 +63,7 @@
let showWifiDetails = $state(false) let showWifiDetails = $state(false)
let formField: any = $state() let formField: Record<string, unknown> = $state()
let formErrors = $state({ let formErrors = $state({
ssid: false, ssid: false,