chore: fixes from deno linting/formatting

This commit is contained in:
Dan Ditomaso
2025-03-02 14:46:02 -05:00
parent db08542b39
commit 50eb2a827f
136 changed files with 1018 additions and 1082 deletions
+2 -2
View File
@@ -14,8 +14,8 @@ export function useBrowserFeatureDetection(): BrowserSupport {
["Web Serial", !!navigator?.serial],
[
"Secure Context",
window.location.protocol === "https:" ||
window.location.hostname === "localhost",
globalThis.location.protocol === "https:" ||
globalThis.location.hostname === "localhost",
],
];
+6 -7
View File
@@ -1,8 +1,8 @@
import { Button } from "@app/components/UI/Button";
import { Button } from "../../components/UI/Button.tsx";
import type { CookieAttributes } from "js-cookie";
import { useCallback, useEffect, useRef } from "react";
import useCookie from "./useCookie";
import { useToast } from "./useToast";
import useCookie from "./useCookie.ts";
import { useToast } from "./useToast.ts";
interface UseBackupReminderOptions {
reminderInDays?: number;
@@ -26,8 +26,8 @@ const ON_ACCEPT_REMINDER_DAYS = 365;
function isReminderExpired(lastShown: string): boolean {
const lastShownDate = new Date(lastShown);
const now = new Date();
const daysSinceLastShown =
(now.getTime() - lastShownDate.getTime()) / (1000 * 60 * 60 * 24);
const daysSinceLastShown = (now.getTime() - lastShownDate.getTime()) /
(1000 * 60 * 60 * 24);
return daysSinceLastShown >= 7;
}
@@ -63,8 +63,7 @@ export function useBackupReminder({
useEffect(() => {
if (!enabled || toastShownRef.current) return;
const shouldShowReminder =
!reminderCookie?.suppressed ||
const shouldShowReminder = !reminderCookie?.suppressed ||
isReminderExpired(reminderCookie.lastShown);
if (!shouldShowReminder) return;
+3 -3
View File
@@ -4,7 +4,7 @@ type Theme = "light" | "dark" | "system";
export function useTheme() {
const getSystemTheme = () =>
window.matchMedia("(prefers-color-scheme: dark)").matches
globalThis.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
@@ -14,7 +14,7 @@ export function useTheme() {
);
const [preference, setPreference] = useState<Theme>(() =>
typeof window !== "undefined" ? getStoredPreference() : "light",
typeof window !== "undefined" ? getStoredPreference() : "light"
);
const theme = preference === "system" ? getSystemTheme() : preference;
@@ -26,7 +26,7 @@ export function useTheme() {
useEffect(() => {
if (preference !== "system") return;
const media = window.matchMedia("(prefers-color-scheme: dark)");
const media = globalThis.matchMedia("(prefers-color-scheme: dark)");
const updateTheme = () => setPreference(getStoredPreference());
media.addEventListener("change", updateTheme);
+17 -17
View File
@@ -31,21 +31,21 @@ type ActionType = typeof actionTypes;
type Action =
| {
type: ActionType["ADD_TOAST"];
toast: ToasterToast;
}
type: ActionType["ADD_TOAST"];
toast: ToasterToast;
}
| {
type: ActionType["UPDATE_TOAST"];
toast: Partial<ToasterToast>;
}
type: ActionType["UPDATE_TOAST"];
toast: Partial<ToasterToast>;
}
| {
type: ActionType["DISMISS_TOAST"];
toastId?: ToasterToast["id"];
}
type: ActionType["DISMISS_TOAST"];
toastId?: ToasterToast["id"];
}
| {
type: ActionType["REMOVE_TOAST"];
toastId?: ToasterToast["id"];
};
type: ActionType["REMOVE_TOAST"];
toastId?: ToasterToast["id"];
};
interface State {
toasts: ToasterToast[];
@@ -81,7 +81,7 @@ export const reducer = (state: State, action: Action): State => {
return {
...state,
toasts: state.toasts.map((t) =>
t.id === action.toast.id ? { ...t, ...action.toast } : t,
t.id === action.toast.id ? { ...t, ...action.toast } : t
),
};
@@ -103,10 +103,10 @@ export const reducer = (state: State, action: Action): State => {
toasts: state.toasts.map((t) =>
t.id === toastId || toastId === undefined
? {
...t,
open: false,
}
: t,
...t,
open: false,
}
: t
),
};
}
+2 -2
View File
@@ -112,7 +112,7 @@ export const useAppStore = create<AppState>()((set, get) => ({
);
},
setNodeNumToBeRemoved: (nodeNum) =>
set((state) => ({
set(() => ({
nodeNumToBeRemoved: nodeNum,
})),
setConnectDialogOpen: (open: boolean) => {
@@ -124,7 +124,7 @@ export const useAppStore = create<AppState>()((set, get) => ({
},
setNodeNumDetails: (nodeNum) =>
set((state) => ({
set(() => ({
nodeNumDetails: nodeNum,
})),
setActiveChat: (chat) =>
+13 -19
View File
@@ -299,11 +299,11 @@ export const useDeviceStore = createStore<DeviceState>((set, get) => ({
if (!device) {
return;
}
const workingModuleConfigIndex =
device?.workingModuleConfig.findIndex(
const workingModuleConfigIndex = device?.workingModuleConfig
.findIndex(
(wmc) =>
wmc.payloadVariant.case ===
moduleConfig.payloadVariant.case,
moduleConfig.payloadVariant.case,
);
if (workingModuleConfigIndex !== -1) {
device.workingModuleConfig[workingModuleConfigIndex] =
@@ -445,8 +445,7 @@ export const useDeviceStore = createStore<DeviceState>((set, get) => ({
if (!device) {
return;
}
const currentNode =
device.nodes.get(user.from) ??
const currentNode = device.nodes.get(user.from) ??
create(Protobuf.Mesh.NodeInfoSchema);
currentNode.user = user.data;
device.nodes.set(user.from, currentNode);
@@ -460,8 +459,7 @@ export const useDeviceStore = createStore<DeviceState>((set, get) => ({
if (!device) {
return;
}
const currentNode =
device.nodes.get(position.from) ??
const currentNode = device.nodes.get(position.from) ??
create(Protobuf.Mesh.NodeInfoSchema);
currentNode.position = position.data;
device.nodes.set(position.from, currentNode);
@@ -486,12 +484,11 @@ export const useDeviceStore = createStore<DeviceState>((set, get) => ({
return;
}
const messageGroup = device.messages[message.type];
const messageIndex =
message.type === "direct"
? message.from === device.hardware.myNodeNum
? message.to
: message.from
: message.channel;
const messageIndex = message.type === "direct"
? message.from === device.hardware.myNodeNum
? message.to
: message.from
: message.channel;
const messages = messageGroup.get(messageIndex);
if (messages) {
@@ -564,12 +561,9 @@ export const useDeviceStore = createStore<DeviceState>((set, get) => ({
}
const messageGroup = device.messages[type];
const messageIndex =
type === "direct"
? from === device.hardware.myNodeNum
? to
: from
: channelIndex;
const messageIndex = type === "direct"
? from === device.hardware.myNodeNum ? to : from
: channelIndex;
const messages = messageGroup.get(messageIndex);
if (!messages) {
+2 -2
View File
@@ -36,7 +36,7 @@ export const subscribeAll = (
}
});
connection.events.onTelemetryPacket.subscribe((telemetryPacket) => {
connection.events.onTelemetryPacket.subscribe(() => {
// device.setMetrics(telemetryPacket);
});
@@ -45,7 +45,7 @@ export const subscribeAll = (
});
connection.events.onWaypointPacket.subscribe((waypoint) => {
const { data, ...rest } = waypoint;
const { data } = waypoint;
device.addWaypoint(data);
});
+1 -1
View File
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { debounce } from "./debounce";
import { debounce } from "./debounce.ts";
describe("debounce", () => {
beforeEach(() => {
+1 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { convertIntToIpAddress, convertIpAddressToInt } from "./ip";
import { convertIntToIpAddress, convertIpAddressToInt } from "./ip.ts";
describe("IP Address Conversion Functions", () => {
describe("convertIntToIpAddress", () => {
+3 -1
View File
@@ -1,5 +1,7 @@
export function convertIntToIpAddress(int: number): string {
return `${int & 0xff}.${(int >> 8) & 0xff}.${(int >> 16) & 0xff}.${(int >> 24) & 0xff}`;
return `${int & 0xff}.${(int >> 8) & 0xff}.${(int >> 16) & 0xff}.${
(int >> 24) & 0xff
}`;
}
export function convertIpAddressToInt(ip: string): number | null {
+1 -1
View File
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { randId } from "./randId";
import { randId } from "./randId.ts";
describe("randId", () => {
beforeEach(() => {