Skip to content

Commit

Permalink
Merge pull request meshtastic#381 from KomelT/fix/biome
Browse files Browse the repository at this point in the history
Fix Biome
  • Loading branch information
Hunter275 authored Jan 24, 2025
2 parents cf79f3b + 47150c6 commit 5d0f2e4
Show file tree
Hide file tree
Showing 23 changed files with 194 additions and 185 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Meshtastic web client",
"license": "GPL-3.0-only",
"scripts": {
"build": "rsbuild build",
"build": "pnpm check && rsbuild build",
"check": "biome check .",
"check:fix": "pnpm check --write",
"dev": "rsbuild dev --open",
Expand Down
2 changes: 1 addition & 1 deletion rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execSync } from "node:child_process";
import { defineConfig } from "@rsbuild/core";
import { pluginReact } from "@rsbuild/plugin-react";
import { execSync } from "node:child_process";

let hash = "";

Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { CommandPalette } from "@components/CommandPalette.tsx";
import { DeviceSelector } from "@components/DeviceSelector.tsx";
import { DialogManager } from "@components/Dialog/DialogManager";
import { NewDeviceDialog } from "@components/Dialog/NewDeviceDialog.tsx";
import { KeyBackupReminder } from "@components/KeyBackupReminder";
import { Toaster } from "@components/Toaster.tsx";
import Footer from "@components/UI/Footer.tsx";
import { ThemeController } from "@components/generic/ThemeController.tsx";
import { useAppStore } from "@core/stores/appStore.ts";
import { useDeviceStore } from "@core/stores/deviceStore.ts";
import { Dashboard } from "@pages/Dashboard/index.tsx";
import { MapProvider } from "react-map-gl";
import { KeyBackupReminder } from "@components/KeyBackupReminder";

export const App = (): JSX.Element => {
const { getDevice } = useDeviceStore();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/DialogManager.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RemoveNodeDialog } from "@app/components/Dialog/RemoveNodeDialog.tsx";
import { DeviceNameDialog } from "@components/Dialog/DeviceNameDialog.tsx";
import { ImportDialog } from "@components/Dialog/ImportDialog.tsx";
import { PkiBackupDialog } from "@components/Dialog/PKIBackupDialog";
import { QRDialog } from "@components/Dialog/QRDialog.tsx";
import { RebootDialog } from "@components/Dialog/RebootDialog.tsx";
import { ShutdownDialog } from "@components/Dialog/ShutdownDialog.tsx";
import { useDevice } from "@core/stores/deviceStore.ts";
import { PkiBackupDialog } from "@components/Dialog/PKIBackupDialog";

export const DialogManager = (): JSX.Element => {
const { channels, config, dialog, setDialogOpen } = useDevice();
Expand Down
38 changes: 16 additions & 22 deletions src/components/Dialog/NewDeviceDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import {
DialogHeader,
DialogTitle,
} from "@components/UI/Dialog.tsx";
import { AlertCircle, InfoIcon, } from "lucide-react";
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@components/UI/Tabs.tsx";
import { Subtle } from "@components/UI/Typography/Subtle.tsx";
import { Link } from "../UI/Typography/Link";
import { AlertCircle, InfoIcon } from "lucide-react";
import { Fragment } from "react/jsx-runtime";
import { Link } from "../UI/Typography/Link";

export interface TabElementProps {
closeDialog: () => void;
Expand Down Expand Up @@ -50,26 +50,25 @@ const links: { [key: string]: string } = {
"https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts",
};

const listFormatter = new Intl.ListFormat('en', {
style: 'long',
type: 'conjunction'
const listFormatter = new Intl.ListFormat("en", {
style: "long",
type: "conjunction",
});

const ErrorMessage = ({ missingFeatures }: FeatureErrorProps) => {
if (missingFeatures.length === 0) return null;

const browserFeatures = missingFeatures.filter(feature => feature !== "Secure Context");
const browserFeatures = missingFeatures.filter(
(feature) => feature !== "Secure Context",
);
const needsSecureContext = missingFeatures.includes("Secure Context");

const formatFeatureList = (features: string[]) => {
const parts = listFormatter.formatToParts(features);
return parts.map((part) => {
if (part.type === 'element') {
if (part.type === "element") {
return (
<Link
key={part.value}
href={links[part.value]}
>
<Link key={part.value} href={links[part.value]}>
{part.value}
</Link>
);
Expand All @@ -94,12 +93,8 @@ const ErrorMessage = ({ missingFeatures }: FeatureErrorProps) => {
<>
{browserFeatures.length > 0 && " Additionally, it"}
{browserFeatures.length === 0 && "This application"} requires a{" "}
<Link
href={links["Secure Context"]}
>
secure context
</Link>
. Please connect using HTTPS or localhost.
<Link href={links["Secure Context"]}>secure context</Link>.
Please connect using HTTPS or localhost.
</>
)}
</p>
Expand Down Expand Up @@ -146,18 +141,17 @@ export const NewDeviceDialog = ({
<Tabs defaultValue="HTTP">
<TabsList>
{tabs.map((tab) => (
<TabsTrigger
key={tab.label}
value={tab.label}
>
<TabsTrigger key={tab.label} value={tab.label}>
{tab.label}
</TabsTrigger>
))}
</TabsList>
{tabs.map((tab) => (
<TabsContent key={tab.label} value={tab.label}>
<fieldset disabled={tab.isDisabled}>
{tab.isDisabled ? <ErrorMessage missingFeatures={unsupported} /> : null}
{tab.isDisabled ? (
<ErrorMessage missingFeatures={unsupported} />
) : null}
<tab.element closeDialog={() => onOpenChange(false)} />
</fieldset>
</TabsContent>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Form/FormPasswordGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import type {
BaseFormBuilderProps,
GenericFormElementProps,
} from "@components/Form/DynamicForm.tsx";
import type { ButtonVariant } from "@components/UI/Button";
import { Generator } from "@components/UI/Generator.tsx";
import { Eye, EyeOff } from "lucide-react";
import type { ChangeEventHandler, MouseEventHandler } from "react";
import { useState } from "react";
import { Controller, type FieldValues } from "react-hook-form";
import type { ButtonVariant } from "@components/UI/Button";

export interface PasswordGeneratorProps<T> extends BaseFormBuilderProps<T> {
type: "passwordGenerator";
Expand Down Expand Up @@ -44,9 +44,9 @@ export function PasswordGenerator<T extends FieldValues>({
action={
field.hide
? {
icon: passwordShown ? EyeOff : Eye,
onClick: togglePasswordVisiblity,
}
icon: passwordShown ? EyeOff : Eye,
onClick: togglePasswordVisiblity,
}
: undefined
}
devicePSKBitCount={field.devicePSKBitCount}
Expand Down
63 changes: 36 additions & 27 deletions src/components/PageComponents/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
channel?.settings?.psk.length ?? 16,
);
const [validationText, setValidationText] = useState<string>();
const [preSharedDialogOpen, setPreSharedDialogOpen] = useState<boolean>(false);
const [preSharedDialogOpen, setPreSharedDialogOpen] =
useState<boolean>(false);

const onSubmit = (data: ChannelValidation) => {
const channel = new Protobuf.Channel.Channel({
Expand Down Expand Up @@ -99,12 +100,13 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
psk: pass,
positionEnabled:
channel?.settings?.moduleSettings?.positionPrecision !==
undefined &&
undefined &&
channel?.settings?.moduleSettings?.positionPrecision > 0,
preciseLocation:
channel?.settings?.moduleSettings?.positionPrecision === 32,
positionPrecision:
channel?.settings?.moduleSettings?.positionPrecision === undefined
channel?.settings?.moduleSettings?.positionPrecision ===
undefined
? 10
: channel?.settings?.moduleSettings?.positionPrecision,
},
Expand Down Expand Up @@ -133,12 +135,19 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
type: "passwordGenerator",
name: "settings.psk",
label: "Pre-Shared Key",
description: "Supported PSK lengths: 256-bit, 128-bit, 8-bit, Empty (0-bit)",
description:
"Supported PSK lengths: 256-bit, 128-bit, 8-bit, Empty (0-bit)",
validationText: validationText,
devicePSKBitCount: bitCount ?? 0,
inputChange: inputChangeEvent,
selectChange: selectChangeEvent,
actionButtons: [{ text: 'Generate', variant: 'success', onClick: preSharedClickEvent }],
actionButtons: [
{
text: "Generate",
variant: "success",
onClick: preSharedClickEvent,
},
],
hide: true,
properties: {
value: pass,
Expand Down Expand Up @@ -185,29 +194,29 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
enumValue:
config.display?.units === 0
? {
"Within 23 km": 10,
"Within 12 km": 11,
"Within 5.8 km": 12,
"Within 2.9 km": 13,
"Within 1.5 km": 14,
"Within 700 m": 15,
"Within 350 m": 16,
"Within 200 m": 17,
"Within 90 m": 18,
"Within 50 m": 19,
}
"Within 23 km": 10,
"Within 12 km": 11,
"Within 5.8 km": 12,
"Within 2.9 km": 13,
"Within 1.5 km": 14,
"Within 700 m": 15,
"Within 350 m": 16,
"Within 200 m": 17,
"Within 90 m": 18,
"Within 50 m": 19,
}
: {
"Within 15 miles": 10,
"Within 7.3 miles": 11,
"Within 3.6 miles": 12,
"Within 1.8 miles": 13,
"Within 0.9 miles": 14,
"Within 0.5 miles": 15,
"Within 0.2 miles": 16,
"Within 600 feet": 17,
"Within 300 feet": 18,
"Within 150 feet": 19,
},
"Within 15 miles": 10,
"Within 7.3 miles": 11,
"Within 3.6 miles": 12,
"Within 1.8 miles": 13,
"Within 0.9 miles": 14,
"Within 0.5 miles": 15,
"Within 0.2 miles": 16,
"Within 600 feet": 17,
"Within 300 feet": 18,
"Within 150 feet": 19,
},
},
},
],
Expand Down
16 changes: 6 additions & 10 deletions src/components/PageComponents/Config/Bluetooth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ import { useState } from "react";

export const Bluetooth = (): JSX.Element => {
const { config, setWorkingConfig } = useDevice();
const [bluetoothValidationText, setBluetoothValidationText] = useState<string>();
const [bluetoothValidationText, setBluetoothValidationText] =
useState<string>();

const bluetoothPinChangeEvent = (
e: React.ChangeEvent<HTMLInputElement>,
) => {
if (e.target.value[0] == "0")
{
const bluetoothPinChangeEvent = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.target.value[0] === "0") {
setBluetoothValidationText("Bluetooth Pin cannot start with 0.");
}
else
{
} else {
setBluetoothValidationText("");
}
}
};

const onSubmit = (data: BluetoothValidation) => {
setWorkingConfig(
Expand Down
10 changes: 6 additions & 4 deletions src/components/PageComponents/Config/Security.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { Eye, EyeOff } from "lucide-react";
import { useState } from "react";

export const Security = (): JSX.Element => {
const { config, nodes, hardware, setWorkingConfig, setDialogOpen } = useDevice();
const { config, nodes, hardware, setWorkingConfig, setDialogOpen } =
useDevice();

const [privateKey, setPrivateKey] = useState<string>(
fromByteArray(config.security?.privateKey ?? new Uint8Array(0)),
Expand All @@ -31,7 +32,8 @@ export const Security = (): JSX.Element => {
);
const [adminKeyValidationText, setAdminKeyValidationText] =
useState<string>();
const [privateKeyDialogOpen, setPrivateKeyDialogOpen] = useState<boolean>(false);
const [privateKeyDialogOpen, setPrivateKeyDialogOpen] =
useState<boolean>(false);

const onSubmit = (data: SecurityValidation) => {
if (privateKeyValidationText || adminKeyValidationText) return;
Expand Down Expand Up @@ -76,7 +78,7 @@ export const Security = (): JSX.Element => {

const pkiBackupClickEvent = () => {
setDialogOpen("pkiBackup", true);
}
};

const pkiRegenerate = () => {
const privateKey = getX25519PrivateKey();
Expand Down Expand Up @@ -202,7 +204,7 @@ export const Security = (): JSX.Element => {
name: "isManaged",
label: "Managed",
description:
'If true, device configuration options are only able to be changed remotely by a Remote Admin node via admin messages. Do not enable this option unless a suitable Remote Admin node has been setup, and the public key stored in the field below.',
"If true, device configuration options are only able to be changed remotely by a Remote Admin node via admin messages. Do not enable this option unless a suitable Remote Admin node has been setup, and the public key stored in the field below.",
},
{
type: "text",
Expand Down
5 changes: 3 additions & 2 deletions src/components/PageComponents/Connect/Serial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => {
await onConnect(port);
}}
>
{`# ${index} - ${usbVendorId ?? "UNK"} - ${usbProductId ?? "UNK"
}`}
{`# ${index} - ${usbVendorId ?? "UNK"} - ${
usbProductId ?? "UNK"
}`}
</Button>
);
})}
Expand Down
10 changes: 5 additions & 5 deletions src/components/PageComponents/Map/NodeDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Mono } from "@components/generic/Mono.tsx";
import { Separator } from "@app/components/UI/Seperator";
import { H5 } from "@app/components/UI/Typography/H5.tsx";
import { Subtle } from "@app/components/UI/Typography/Subtle.tsx";
import { Separator } from "@app/components/UI/Seperator";
import { Mono } from "@components/generic/Mono.tsx";
import { TimeAgo } from "@components/generic/Table/tmp/TimeAgo.tsx";
import { Hashicon } from "@emeraldpay/hashicon-react";
import { Protobuf } from "@meshtastic/js";
import type { Protobuf as ProtobufType } from "@meshtastic/js";
import { numberToHexUnpadded } from "@noble/curves/abstract/utils";
import {
BatteryChargingIcon,
BatteryFullIcon,
Expand All @@ -17,7 +18,6 @@ import {
MountainSnow,
Star,
} from "lucide-react";
import { numberToHexUnpadded } from "@noble/curves/abstract/utils";

export interface NodeDetailProps {
node: ProtobufType.Mesh.NodeInfo;
Expand Down Expand Up @@ -84,7 +84,7 @@ export const NodeDetail = ({ node }: NodeDetailProps): JSX.Element => {
<Subtle aria-label="Battery">
{node.deviceMetrics?.batteryLevel > 100
? "Charging"
: node.deviceMetrics?.batteryLevel + "%"}
: `${node.deviceMetrics?.batteryLevel}%`}
</Subtle>
</div>
)}
Expand Down Expand Up @@ -121,7 +121,7 @@ export const NodeDetail = ({ node }: NodeDetailProps): JSX.Element => {
<div className="flex mt-2 text-sm">
<div className="flex items-center flex-grow">
<div className="border-2 border-black rounded px-0.5 mr-1">
{isNaN(node.hopsAway) ? "?" : node.hopsAway}
{Number.isNaN(node.hopsAway) ? "?" : node.hopsAway}
</div>
<div>{node.hopsAway === 1 ? "Hop" : "Hops"}</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/PageComponents/Messages/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Message = ({
{sender?.user?.longName ?? "UNK"}
</span>
<span className="mt-1 font-mono text-xs text-textSecondary">
{message.rxTime.toLocaleDateString()}
{message.rxTime.toLocaleDateString()}
</span>
<span className="mt-1 font-mono text-xs text-textSecondary">
{message.rxTime.toLocaleTimeString(undefined, {
Expand Down
Loading

0 comments on commit 5d0f2e4

Please sign in to comment.