From 93b139c268a6494f37dce81de4634aea160f3682 Mon Sep 17 00:00:00 2001 From: Brandon Vandegrift Date: Mon, 27 May 2024 16:21:56 -0400 Subject: [PATCH] Update biome, fix and enforce recommended rules --- .vscode/settings.json | 9 ++- biome.json | 4 +- package.json | 5 +- pnpm-lock.yaml | 2 +- postcss.config.cjs | 4 +- src/components/CommandPalette.tsx | 4 +- src/components/DeviceSelector.tsx | 2 +- src/components/Dialog/DialogManager.tsx | 2 +- src/components/Dialog/QRDialog.tsx | 36 +++++++---- src/components/Dialog/RebootDialog.tsx | 2 +- src/components/Dialog/RemoveNodeDialog.tsx | 4 +- src/components/Dialog/ShutdownDialog.tsx | 2 +- src/components/Form/DynamicForm.tsx | 21 ++++--- src/components/Form/DynamicFormField.tsx | 15 ++++- src/components/Form/FormInput.tsx | 2 +- src/components/Form/FormSelect.tsx | 4 +- src/components/Form/FormToggle.tsx | 4 +- src/components/PageComponents/Channel.tsx | 52 +++++++++++++--- src/components/PageComponents/Config/LoRa.tsx | 2 +- src/components/PageComponents/Connect/BLE.tsx | 2 +- .../PageComponents/Connect/HTTP.tsx | 14 +++-- .../PageComponents/Connect/Serial.tsx | 31 +++++----- .../PageComponents/Messages/ChannelChat.tsx | 5 +- .../ModuleConfig/DetectionSensor.tsx | 6 +- .../PageComponents/ModuleConfig/MQTT.tsx | 32 ++++++++-- .../ModuleConfig/NeighborInfo.tsx | 2 +- .../ModuleConfig/Paxcounter.tsx | 3 +- src/components/PageLayout.tsx | 2 +- src/components/Sidebar.tsx | 14 +++-- src/components/Toaster.tsx | 10 +++- src/components/UI/Button.tsx | 2 +- src/components/UI/Toast.tsx | 2 +- src/components/generic/Table/index.tsx | 19 +++++- src/core/hooks/useToast.ts | 36 ++++++----- src/core/stores/appStore.ts | 9 ++- src/core/stores/deviceStore.ts | 4 +- src/core/subscriptions.ts | 2 +- src/core/utils/cn.ts | 2 +- src/pages/Config/DeviceConfig.tsx | 5 +- src/pages/Config/ModuleConfig.tsx | 2 +- src/pages/Map.tsx | 36 +++++------ src/pages/Nodes.tsx | 60 +++++++++++-------- src/validation/config/position.ts | 8 ++- src/validation/moduleConfig/mqtt.ts | 2 +- vite.config.ts | 4 +- 45 files changed, 314 insertions(+), 176 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a71cfe36..f9d98cd9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { - "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true -} \ No newline at end of file + "editor.defaultFormatter": "biomejs.biome", + "editor.codeActionsOnSave": { + "quickfix.biome": "explicit" + }, + "editor.formatOnSave": true +} diff --git a/biome.json b/biome.json index d7ab186b..c0f18797 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.6.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.7.3/schema.json", "organizeImports": { "enabled": true }, @@ -20,7 +20,7 @@ "linter": { "enabled": true, "rules": { - "all": true + "recommended": true } } } diff --git a/package.json b/package.json index bf87eb02..392d8cd6 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,9 @@ "license": "GPL-3.0-only", "scripts": { "dev": "vite --host", - "build": "tsc && vite build", + "build": "tsc && pnpm check && vite build ", "check": "biome check .", + "check:fix": "pnpm check --write", "preview": "vite preview", "package": "gzipper c -i html,js,css,png,ico,svg,webmanifest,txt dist dist/output && tar -cvf dist/build.tar -C ./dist/output/ $(ls ./dist/output/)" }, @@ -60,7 +61,7 @@ "zustand": "4.5.2" }, "devDependencies": { - "@biomejs/biome": "^1.6.3", + "@biomejs/biome": "^1.8.1", "@buf/meshtastic_protobufs.bufbuild_es": "1.8.0-20240325205556-b11811405eea.2", "@types/chrome": "^0.0.263", "@types/node": "^20.11.30", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index be303f7a..0ea3d560 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -122,7 +122,7 @@ dependencies: devDependencies: '@biomejs/biome': - specifier: ^1.6.3 + specifier: ^1.8.1 version: 1.8.1 '@buf/meshtastic_protobufs.bufbuild_es': specifier: 1.8.0-20240325205556-b11811405eea.2 diff --git a/postcss.config.cjs b/postcss.config.cjs index 5cbc2c7d..12a703d9 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -1,6 +1,6 @@ module.exports = { plugins: { tailwindcss: {}, - autoprefixer: {} - } + autoprefixer: {}, + }, }; diff --git a/src/components/CommandPalette.tsx b/src/components/CommandPalette.tsx index 5e37816d..07f456e1 100644 --- a/src/components/CommandPalette.tsx +++ b/src/components/CommandPalette.tsx @@ -19,7 +19,7 @@ import { LayersIcon, LayoutIcon, LinkIcon, - LucideIcon, + type LucideIcon, MapIcon, MessageSquareIcon, MoonIcon, @@ -350,7 +350,7 @@ export const CommandPalette = (): JSX.Element => { window.addEventListener("keydown", handleKeydown); return () => window.removeEventListener("keydown", handleKeydown); - }, []); + }, [setCommandPaletteOpen]); return ( { diff --git a/src/components/Dialog/DialogManager.tsx b/src/components/Dialog/DialogManager.tsx index 877eec4e..53e2509b 100644 --- a/src/components/Dialog/DialogManager.tsx +++ b/src/components/Dialog/DialogManager.tsx @@ -1,9 +1,9 @@ +import { RemoveNodeDialog } from "@app/components/Dialog/RemoveNodeDialog.js"; import { DeviceNameDialog } from "@components/Dialog/DeviceNameDialog.js"; import { ImportDialog } from "@components/Dialog/ImportDialog.js"; import { QRDialog } from "@components/Dialog/QRDialog.js"; import { RebootDialog } from "@components/Dialog/RebootDialog.js"; import { ShutdownDialog } from "@components/Dialog/ShutdownDialog.js"; -import { RemoveNodeDialog } from "@app/components/Dialog/RemoveNodeDialog.js" import { useDevice } from "@core/stores/deviceStore.js"; export const DialogManager = (): JSX.Element => { diff --git a/src/components/Dialog/QRDialog.tsx b/src/components/Dialog/QRDialog.tsx index e58455b3..27a57a1d 100644 --- a/src/components/Dialog/QRDialog.tsx +++ b/src/components/Dialog/QRDialog.tsx @@ -9,10 +9,10 @@ import { } from "@components/UI/Dialog.js"; import { Input } from "@components/UI/Input.js"; import { Label } from "@components/UI/Label.js"; -import { Protobuf, Types } from "@meshtastic/js"; +import { Protobuf, type Types } from "@meshtastic/js"; import { fromByteArray } from "base64-js"; import { ClipboardIcon } from "lucide-react"; -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { QRCode } from "react-qrcode-logo"; export interface QRDialogProps { @@ -32,7 +32,7 @@ export const QRDialog = ({ const [qrCodeUrl, setQrCodeUrl] = useState(""); const [qrCodeAdd, setQrCodeAdd] = useState(); - const allChannels = Array.from(channels.values()); + const allChannels = useMemo(() => Array.from(channels.values()), [channels]); useEffect(() => { const channelsToEncode = allChannels @@ -50,8 +50,10 @@ export const QRDialog = ({ .replace(/\+/g, "-") .replace(/\//g, "_"); - setQrCodeUrl(`https://meshtastic.org/e/#${base64}${qrCodeAdd ? "?add=true" : ""}`); - }, [channels, selectedChannels, qrCodeAdd, loraConfig]); + setQrCodeUrl( + `https://meshtastic.org/e/#${base64}${qrCodeAdd ? "?add=true" : ""}`, + ); + }, [allChannels, selectedChannels, qrCodeAdd, loraConfig]); return ( @@ -97,18 +99,26 @@ export const QRDialog = ({
diff --git a/src/components/Dialog/RebootDialog.tsx b/src/components/Dialog/RebootDialog.tsx index f4a591bf..79ff86bd 100644 --- a/src/components/Dialog/RebootDialog.tsx +++ b/src/components/Dialog/RebootDialog.tsx @@ -37,7 +37,7 @@ export const RebootDialog = ({ setTime(parseInt(e.target.value))} + onChange={(e) => setTime(Number.parseInt(e.target.value))} action={{ icon: ClockIcon, onClick() { diff --git a/src/components/Dialog/RemoveNodeDialog.tsx b/src/components/Dialog/RemoveNodeDialog.tsx index 789388db..b2db5d56 100644 --- a/src/components/Dialog/RemoveNodeDialog.tsx +++ b/src/components/Dialog/RemoveNodeDialog.tsx @@ -44,7 +44,9 @@ export const RemoveNodeDialog = ({ - +
diff --git a/src/components/Dialog/ShutdownDialog.tsx b/src/components/Dialog/ShutdownDialog.tsx index ea1ac487..cf34fee5 100644 --- a/src/components/Dialog/ShutdownDialog.tsx +++ b/src/components/Dialog/ShutdownDialog.tsx @@ -38,7 +38,7 @@ export const ShutdownDialog = ({ setTime(parseInt(e.target.value))} + onChange={(e) => setTime(Number.parseInt(e.target.value))} suffix="Minutes" />