🎨 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
+8 -8
View File
@@ -2,20 +2,20 @@ import { get } from 'svelte/store'
import { Err, Ok, type Result } from './utilities'
import { location } from './stores'
export namespace api {
export function get<TResponse>(endpoint: string, params?: RequestInit) {
export const api = {
get<TResponse>(endpoint: string, params?: RequestInit) {
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)
}
},
export function put<TResponse>(endpoint: string, data?: unknown) {
put<TResponse>(endpoint: string, data?: unknown) {
return sendRequest<TResponse>(endpoint, 'PUT', data)
}
},
export function remove<TResponse>(endpoint: string) {
remove<TResponse>(endpoint: string) {
return sendRequest<TResponse>(endpoint, 'DELETE')
}
}
+4 -2
View File
@@ -1,4 +1,6 @@
<script lang="ts">
import type { ComponentType } from 'svelte'
type Variant = 'success' | 'error' | 'primary' | 'info' | 'warning'
const {
@@ -9,12 +11,12 @@
class: klass = '',
children = null
} = $props<{
icon?: any
icon?: ComponentType
title: string
description?: string | number
variant?: Variant
class?: string
children?: () => any
children?: () => ComponentType
}>()
const Icon = $derived(icon)
@@ -24,7 +24,6 @@
jointNames,
currentKinematic,
walkGait,
walkGaits,
walkGaitToMode
} from '$lib/stores'
import {
@@ -11,7 +11,7 @@
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)
</script>
@@ -3,8 +3,8 @@
min?: number
max?: number
step?: number
value?: any
oninput?: any
value?: number
oninput?: (value: number) => void
}
let {
@@ -2,7 +2,7 @@
import { Github } from '../icons'
interface Props {
github: any
github: { url: string; version: string }
}
let { github }: Props = $props()
+4 -2
View File
@@ -33,9 +33,11 @@
const github = { href: 'https://github.com/' + page.data.github, active: true }
import type { ComponentType } from 'svelte'
type menuItem = {
title: string
icon: ConstructorOfATypedSvelteComponent
icon: ComponentType
href?: string
feature: boolean
active?: boolean
@@ -172,7 +174,7 @@
setActiveMenuItem(page.data.title)
})
const updateMenu = (event: any) => {
const updateMenu = (event: CustomEvent) => {
setActiveMenuItem(event.details)
}
</script>
+4 -2
View File
@@ -1,8 +1,10 @@
<script lang="ts">
import MenuList from './MenuList.svelte'
import type { ComponentType } from 'svelte'
type MenuItem = {
title: string
icon: ConstructorOfATypedSvelteComponent
icon: ComponentType
href?: string
feature: boolean
active?: boolean
@@ -17,7 +19,7 @@
</script>
<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}
<li>
{#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'
@@ -6,12 +6,12 @@
import { slide } from 'svelte/transition'
let chartElement: HTMLCanvasElement
let chart: Chart
let chart: Chart<'line', number[], string>
interface Props {
label: any
label: string
data: number[]
title: any
title: string
}
let { label, data, title }: Props = $props()
@@ -3,7 +3,7 @@
options?: string[]
selectedOption?: string
change?: () => void
[key: string]: any
[key: string]: unknown
}
let { options = [], selectedOption = $bindable(''), ...rest }: Props = $props()
+8 -8
View File
@@ -58,14 +58,14 @@ export default class SceneBuilder {
public ground!: Mesh
public renderer!: WebGLRenderer
public orbit: OrbitControls
public callback: Function | undefined
public callback: (() => void) | undefined
public gridHelper!: GridHelper
public model!: URDFRobot
public liveStreamTexture!: CanvasTexture
private fog!: FogExp2
private isLoaded: boolean = false
public isDragging: boolean = false
highlightMaterial: any
highlightMaterial: MeshPhongMaterial
sky!: Sky
transformControl: TransformControls
public modelGroup!: Group
@@ -229,7 +229,7 @@ export default class SceneBuilder {
return this
}
public addRenderCb = (callback: Function) => {
public addRenderCb = (callback: () => void) => {
this.callback = callback
return this
}
@@ -275,7 +275,7 @@ export default class SceneBuilder {
isJoint = (j: URDFJoint) => j.isURDFJoint && j.jointType !== 'fixed'
highlightLinkGeometry = (m: URDFMimicJoint, revert: boolean, material: MeshPhongMaterial) => {
const traverse = (c: any) => {
const traverse = (c: Object3D) => {
if (c.type === 'Mesh') {
if (revert) {
c.material = c.__origMaterial
@@ -298,9 +298,9 @@ export default class SceneBuilder {
traverse(m)
}
public addTransformControls = (model: any) => {
public addTransformControls = (model: Object3D) => {
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.isDragging = !event.value
})
@@ -310,7 +310,7 @@ export default class SceneBuilder {
return this
}
public addModel = (model: any) => {
public addModel = (model: URDFRobot) => {
this.modelGroup = new Group()
this.modelGroup.add(model)
this.model = model
@@ -318,7 +318,7 @@ export default class SceneBuilder {
return this
}
public addDragControl = (updateAngle: any) => {
public addDragControl = (updateAngle: (angles: Record<string, number>) => void) => {
const highlightColor = '#FFFFFF'
const highlightMaterial = new MeshPhongMaterial({
shininess: 10,
+1 -1
View File
@@ -1,7 +1,7 @@
import { type Analytics } from '$lib/types/models'
import { writable } from 'svelte/store'
let analytics_data = {
const analytics_data = {
uptime: <number[]>[],
free_heap: <number[]>[],
total_heap: <number[]>[],
+1 -1
View File
@@ -8,7 +8,7 @@ import ChartWidget from '$lib/components/widget/ChartWidget.svelte'
export interface WidgetConfig {
id: string | number
component: keyof typeof WidgetComponents
props?: Record<string, any>
props?: Record<string, unknown>
}
export interface WidgetContainerConfig {
+2 -2
View File
@@ -1,7 +1,7 @@
import type { DownloadOTA } from '$lib/types/models'
import { writable } from 'svelte/store'
let telemetry_data = {
const telemetry_data = {
rssi: {
rssi: 0
},
@@ -13,7 +13,7 @@ let telemetry_data = {
}
function createTelemetry() {
const { subscribe, set, update } = writable(telemetry_data)
const { subscribe, update } = writable(telemetry_data)
return {
subscribe,
+5 -5
View File
@@ -1,12 +1,12 @@
declare module 'uzip' {
interface UZIP {
parse(data: Uint8Array | ArrayBuffer): any
compress(data: any): Uint8Array | ArrayBuffer
parse(data: Uint8Array | ArrayBuffer): Record<string, Uint8Array>
compress(data: Record<string, Uint8Array>): 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
encode(data: any): Uint8Array | ArrayBuffer
decode(data: Uint8Array | ArrayBuffer): any
encode(data: Record<string, Uint8Array>): Uint8Array | ArrayBuffer
decode(data: Uint8Array | ArrayBuffer): Record<string, Uint8Array>
}
const uzip: UZIP
+1 -1
View File
@@ -3,7 +3,7 @@ export class throttler {
constructor() {
this._throttlePause = false
}
throttle = (callback: Function, time: number) => {
throttle = (callback: () => void, time: number) => {
if (this._throttlePause) return
this._throttlePause = true
+2 -2
View File
@@ -1,12 +1,12 @@
export const toUint8 = (number: number, min: number, 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
}
export const toInt8 = (number: number, min: number, 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
}
+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 namespace Result {
export const Result = {
/**
* @returns `Ok<T>`
*/
export function ok<T = unknown>(value: T) {
ok<T = unknown>(value: T) {
return Ok.new(value)
}
},
/**
* @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)
}
}