Address new linting rules (#851)
Co-authored-by: philon- <philon-@users.noreply.github.com>
This commit is contained in:
co-authored by
philon-
parent
37ad0ac9eb
commit
aaf85943a8
+3
-3
@@ -3,9 +3,9 @@
|
|||||||
"includes": [
|
"includes": [
|
||||||
"**/*.ts",
|
"**/*.ts",
|
||||||
"**/*.tsx",
|
"**/*.tsx",
|
||||||
"!npm_modules/**",
|
"!npm_modules",
|
||||||
"!dist/**",
|
"!dist",
|
||||||
"!npm/**",
|
"!npm",
|
||||||
"**/*.json",
|
"**/*.json",
|
||||||
"!**/locales/*-*/*.json"
|
"!**/locales/*-*/*.json"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const fromDeviceStream: () => TransformStream<Uint8Array, DeviceOutput> =
|
|||||||
byteBuffer = new Uint8Array([...byteBuffer, ...chunk]);
|
byteBuffer = new Uint8Array([...byteBuffer, ...chunk]);
|
||||||
let processingExhausted = false;
|
let processingExhausted = false;
|
||||||
while (byteBuffer.length !== 0 && !processingExhausted) {
|
while (byteBuffer.length !== 0 && !processingExhausted) {
|
||||||
const framingIndex = byteBuffer.findIndex((byte) => byte === 0x94);
|
const framingIndex = byteBuffer.indexOf(0x94);
|
||||||
const framingByte2 = byteBuffer[framingIndex + 1];
|
const framingByte2 = byteBuffer[framingIndex + 1];
|
||||||
if (framingByte2 === 0xc3) {
|
if (framingByte2 === 0xc3) {
|
||||||
if (byteBuffer.subarray(0, framingIndex).length) {
|
if (byteBuffer.subarray(0, framingIndex).length) {
|
||||||
@@ -35,9 +35,7 @@ export const fromDeviceStream: () => TransformStream<Uint8Array, DeviceOutput> =
|
|||||||
) {
|
) {
|
||||||
const packet = byteBuffer.subarray(4, 4 + (msb << 8) + lsb);
|
const packet = byteBuffer.subarray(4, 4 + (msb << 8) + lsb);
|
||||||
|
|
||||||
const malformedDetectorIndex = packet.findIndex(
|
const malformedDetectorIndex = packet.indexOf(0x94);
|
||||||
(byte) => byte === 0x94,
|
|
||||||
);
|
|
||||||
if (
|
if (
|
||||||
malformedDetectorIndex !== -1 &&
|
malformedDetectorIndex !== -1 &&
|
||||||
packet[malformedDetectorIndex + 1] === 0xc3
|
packet[malformedDetectorIndex + 1] === 0xc3
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ class MiniEmitter {
|
|||||||
this.listeners.get(type)?.delete(listener);
|
this.listeners.get(type)?.delete(listener);
|
||||||
}
|
}
|
||||||
dispatchEvent(event: Event) {
|
dispatchEvent(event: Event) {
|
||||||
this.listeners.get(event.type)?.forEach((l) => l(event));
|
this.listeners.get(event.type)?.forEach((l) => {
|
||||||
|
l(event);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export const ImportDialog = ({ open, onOpenChange }: ImportDialogProps) => {
|
|||||||
}, [importDialogInput, t]);
|
}, [importDialogInput, t]);
|
||||||
|
|
||||||
const apply = () => {
|
const apply = () => {
|
||||||
channelSet?.settings.map(
|
channelSet?.settings.forEach(
|
||||||
(ch: Protobuf.Channel.ChannelSettings, index: number) => {
|
(ch: Protobuf.Channel.ChannelSettings, index: number) => {
|
||||||
if (importIndex[index] === -1) {
|
if (importIndex[index] === -1) {
|
||||||
return;
|
return;
|
||||||
@@ -140,7 +140,7 @@ export const ImportDialog = ({ open, onOpenChange }: ImportDialogProps) => {
|
|||||||
|
|
||||||
const onSelectChange = (value: string, index: number) => {
|
const onSelectChange = (value: string, index: number) => {
|
||||||
const newImportIndex = [...importIndex];
|
const newImportIndex = [...importIndex];
|
||||||
newImportIndex[index] = Number.parseInt(value);
|
newImportIndex[index] = Number.parseInt(value, 10);
|
||||||
setImportIndex(newImportIndex);
|
setImportIndex(newImportIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ export const ManagedModeDialog = ({
|
|||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="managedMode"
|
|
||||||
checked={confirmState}
|
checked={confirmState}
|
||||||
onChange={() => setConfirmState(!confirmState)}
|
onChange={() => setConfirmState(!confirmState)}
|
||||||
name="confirmUnderstanding"
|
name="confirmUnderstanding"
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export const ShutdownDialog = ({ open, onOpenChange }: ShutdownDialogProps) => {
|
|||||||
<Input
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
value={time}
|
value={time}
|
||||||
onChange={(e) => setTime(Number.parseInt(e.target.value))}
|
onChange={(e) => setTime(Number.parseInt(e.target.value, 10))}
|
||||||
suffix={t("unit.minute.plural")}
|
suffix={t("unit.minute.plural")}
|
||||||
/>
|
/>
|
||||||
<Button className="w-24" onClick={handleScheduledShutdown}>
|
<Button className="w-24" onClick={handleScheduledShutdown}>
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ export const UnsafeRolesDialog = ({
|
|||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="routerRole"
|
|
||||||
checked={confirmState}
|
checked={confirmState}
|
||||||
onChange={() => setConfirmState(!confirmState)}
|
onChange={() => setConfirmState(!confirmState)}
|
||||||
name="confirmUnderstanding"
|
name="confirmUnderstanding"
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export function SelectInput<T extends FieldValues>({
|
|||||||
if (field.selectChange) {
|
if (field.selectChange) {
|
||||||
field.selectChange(newValue, selectedKey);
|
field.selectChange(newValue, selectedKey);
|
||||||
}
|
}
|
||||||
onChange(Number.parseInt(newValue));
|
onChange(Number.parseInt(newValue, 10));
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ export const Channel = ({ onFormInit, channel }: SettingsPanelProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const selectChangeEvent = (e: string) => {
|
const selectChangeEvent = (e: string) => {
|
||||||
const count = Number.parseInt(e);
|
const count = Number.parseInt(e, 10);
|
||||||
if (!Number.isNaN(count)) {
|
if (!Number.isNaN(count)) {
|
||||||
setBytes(count);
|
setBytes(count);
|
||||||
trigger("settings.psk");
|
trigger("settings.psk");
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ export default function ThemeSwitcher({
|
|||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={toggleTheme}
|
onClick={toggleTheme}
|
||||||
id="theme-switcher"
|
|
||||||
aria-label={t("theme.changeTheme")}
|
aria-label={t("theme.changeTheme")}
|
||||||
className={cn(
|
className={cn(
|
||||||
"group relative flex justify-start",
|
"group relative flex justify-start",
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ describe("Checkbox", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("uses provided id", () => {
|
it("uses provided id", () => {
|
||||||
|
// biome-ignore lint/correctness/useUniqueElementIds: <test>
|
||||||
render(<Checkbox id="custom-id" />);
|
render(<Checkbox id="custom-id" />);
|
||||||
expect(screen.getByRole("checkbox").id).toBe("custom-id");
|
expect(screen.getByRole("checkbox").id).toBe("custom-id");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -72,10 +72,7 @@ export function ErrorPage({ error }: { error: Error }) {
|
|||||||
<label htmlFor="message">
|
<label htmlFor="message">
|
||||||
{t("errorPage.errorMessageLabel")}
|
{t("errorPage.errorMessageLabel")}
|
||||||
</label>
|
</label>
|
||||||
<p
|
<p className="text-slate-400 break-words overflow-wrap">
|
||||||
id="message"
|
|
||||||
className="text-slate-400 break-words overflow-wrap"
|
|
||||||
>
|
|
||||||
{error.message}
|
{error.message}
|
||||||
</p>
|
</p>
|
||||||
</> // TODO: Use Trans for the label and message together?
|
</> // TODO: Use Trans for the label and message together?
|
||||||
@@ -83,10 +80,7 @@ export function ErrorPage({ error }: { error: Error }) {
|
|||||||
{error?.stack && (
|
{error?.stack && (
|
||||||
<>
|
<>
|
||||||
<label htmlFor="stack">{t("errorPage.stackTraceLabel")}</label>
|
<label htmlFor="stack">{t("errorPage.stackTraceLabel")}</label>
|
||||||
<p
|
<p className="text-slate-400 break-words overflow-wrap">
|
||||||
id="stack"
|
|
||||||
className="text-slate-400 break-words overflow-wrap"
|
|
||||||
>
|
|
||||||
{error.stack}
|
{error.stack}
|
||||||
</p>
|
</p>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -244,7 +244,6 @@ export function FilterControl({
|
|||||||
</label>
|
</label>
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
id="nodeName"
|
|
||||||
value={filterState.nodeName}
|
value={filterState.nodeName}
|
||||||
onChange={handleTextChange("nodeName")}
|
onChange={handleTextChange("nodeName")}
|
||||||
showClearButton
|
showClearButton
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export function convertIpAddressToInt(ip: string): number | undefined {
|
|||||||
.split(".")
|
.split(".")
|
||||||
.reverse()
|
.reverse()
|
||||||
.reduce((ipnum, octet) => {
|
.reduce((ipnum, octet) => {
|
||||||
return (ipnum << 8) + Number.parseInt(octet);
|
return (ipnum << 8) + Number.parseInt(octet, 10);
|
||||||
}, 0) >>> 0
|
}, 0) >>> 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,11 +122,15 @@ const ConfigPage = () => {
|
|||||||
await connection?.commitEditSettings();
|
await connection?.commitEditSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
workingChannelConfig.forEach((newChannel) => addChannel(newChannel));
|
workingChannelConfig.forEach((newChannel) => {
|
||||||
workingConfig.forEach((newConfig) => setConfig(newConfig));
|
addChannel(newChannel);
|
||||||
workingModuleConfig.forEach((newModuleConfig) =>
|
});
|
||||||
setModuleConfig(newModuleConfig),
|
workingConfig.forEach((newConfig) => {
|
||||||
);
|
setConfig(newConfig);
|
||||||
|
});
|
||||||
|
workingModuleConfig.forEach((newModuleConfig) => {
|
||||||
|
setModuleConfig(newModuleConfig);
|
||||||
|
});
|
||||||
|
|
||||||
removeWorkingChannelConfig();
|
removeWorkingChannelConfig();
|
||||||
removeWorkingConfig();
|
removeWorkingConfig();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const Dashboard = () => {
|
|||||||
{devices.map((device) => {
|
{devices.map((device) => {
|
||||||
const nodeDB = getNodeDB(device.id);
|
const nodeDB = getNodeDB(device.id);
|
||||||
if (!nodeDB) {
|
if (!nodeDB) {
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user