fix: resolve lint warnings/errors and apply formatting (#1024)
* fix: resolve lint warnings/errors and apply formatting Fix 10 oxlint issues (2 errors, 8 warnings): - Remove unused catch parameters in Security.tsx and ImportDialog.tsx - Remove stray expression in Generator.tsx - Add eslint-disable for debounced useCallback in FilterControl.tsx - Remove unnecessary deps (resolveDB, store) in bindStoreToDevice.ts - Prefix unused variant param in AppSidebar.tsx - Memoize tabs arrays in DeviceConfig, RadioConfig, ModuleConfig - Fix channels type in RadioConfig TabItem Also applies oxfmt formatting across all files. * updating lock file * update protobuf package * fix: regenerate pnpm-lock.yaml and exclude jsr protobufs from minimumReleaseAge * prevented http card from always being polled * updated pnpm config fiile * updated actions * removed biome config and lint system leftovers * updating protobuf package
This commit is contained in:
@@ -1,26 +1,14 @@
|
||||
import {
|
||||
afterEach,
|
||||
beforeEach,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
type MockInstance,
|
||||
vi,
|
||||
} from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it, type MockInstance, vi } from "vitest";
|
||||
import { runTransportContract } from "../../../tests/utils/transportContract.ts";
|
||||
import { TransportHTTP } from "./transport.ts";
|
||||
|
||||
let abortTimeoutSpy: MockInstance | undefined;
|
||||
beforeEach(() => {
|
||||
abortTimeoutSpy = vi
|
||||
.spyOn(
|
||||
globalThis.AbortSignal as unknown as { timeout(ms: number): AbortSignal },
|
||||
"timeout",
|
||||
)
|
||||
.spyOn(globalThis.AbortSignal as unknown as { timeout(ms: number): AbortSignal }, "timeout")
|
||||
.mockImplementation((ms: number) => {
|
||||
const ctrl = new AbortController();
|
||||
const abort = () =>
|
||||
ctrl.abort(new DOMException("Timeout reached", "TimeoutError"));
|
||||
const abort = () => ctrl.abort(new DOMException("Timeout reached", "TimeoutError"));
|
||||
// Uses setTimeout so vi.useFakeTimers() can fast-forward it
|
||||
setTimeout(abort, ms);
|
||||
return ctrl.signal;
|
||||
@@ -128,23 +116,21 @@ describe("TransportHTTP (contract)", () => {
|
||||
vi.unstubAllGlobals();
|
||||
},
|
||||
create: async () => {
|
||||
(
|
||||
globalThis as unknown as { __http: ReturnType<typeof stubFetch> }
|
||||
).__http = stubFetch();
|
||||
(globalThis as unknown as { __http: ReturnType<typeof stubFetch> }).__http = stubFetch();
|
||||
const transport = await TransportHTTP.create("127.0.0.1:80", false);
|
||||
await tickNextTimer();
|
||||
return transport;
|
||||
},
|
||||
pushIncoming: async (bytes) => {
|
||||
(
|
||||
globalThis as unknown as { __http: ReturnType<typeof stubFetch> }
|
||||
).__http.pushIncoming(bytes);
|
||||
(globalThis as unknown as { __http: ReturnType<typeof stubFetch> }).__http.pushIncoming(
|
||||
bytes,
|
||||
);
|
||||
await tickNextTimer();
|
||||
},
|
||||
assertLastWritten: (bytes) => {
|
||||
(
|
||||
globalThis as unknown as { __http: ReturnType<typeof stubFetch> }
|
||||
).__http.assertLastWritten(bytes);
|
||||
(globalThis as unknown as { __http: ReturnType<typeof stubFetch> }).__http.assertLastWritten(
|
||||
bytes,
|
||||
);
|
||||
},
|
||||
triggerDisconnect: async () => {
|
||||
(
|
||||
|
||||
@@ -34,8 +34,7 @@ export class TransportHTTP implements Types.Transport {
|
||||
|
||||
private inflightReadController?: AbortController;
|
||||
|
||||
private lastStatus: Types.DeviceStatusEnum =
|
||||
Types.DeviceStatusEnum.DeviceDisconnected;
|
||||
private lastStatus: Types.DeviceStatusEnum = Types.DeviceStatusEnum.DeviceDisconnected;
|
||||
private closingByUser = false;
|
||||
|
||||
/**
|
||||
@@ -44,10 +43,7 @@ export class TransportHTTP implements Types.Transport {
|
||||
* @param address Hostname or IP address (with optional port).
|
||||
* @param tls Use HTTPS if true, HTTP otherwise.
|
||||
*/
|
||||
public static async create(
|
||||
address: string,
|
||||
tls?: boolean,
|
||||
): Promise<TransportHTTP> {
|
||||
public static async create(address: string, tls?: boolean): Promise<TransportHTTP> {
|
||||
const connectionUrl = `${tls ? "https" : "http"}://${address}`;
|
||||
await fetch(`${connectionUrl}/api/v1/toradio`, {
|
||||
method: "OPTIONS",
|
||||
@@ -90,10 +86,7 @@ export class TransportHTTP implements Types.Transport {
|
||||
|
||||
// Start polling immediately
|
||||
void this.safePoll();
|
||||
this.interval = setInterval(
|
||||
() => void this.safePoll(),
|
||||
this.fetchInterval,
|
||||
);
|
||||
this.interval = setInterval(() => void this.safePoll(), this.fetchInterval);
|
||||
},
|
||||
cancel: () => {
|
||||
if (this.interval) {
|
||||
@@ -112,10 +105,7 @@ export class TransportHTTP implements Types.Transport {
|
||||
const inflight = new AbortController();
|
||||
this.inflightReadController = inflight;
|
||||
|
||||
const signal = AbortSignal.any([
|
||||
inflight.signal,
|
||||
AbortSignal.timeout(READ_TIMEOUT_MS),
|
||||
]);
|
||||
const signal = AbortSignal.any([inflight.signal, AbortSignal.timeout(READ_TIMEOUT_MS)]);
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
@@ -127,9 +117,7 @@ export class TransportHTTP implements Types.Transport {
|
||||
},
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`fromradio ${response.status} ${response.statusText}`,
|
||||
);
|
||||
throw new Error(`fromradio ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
this.emitStatus(Types.DeviceStatusEnum.DeviceConnected);
|
||||
@@ -217,10 +205,8 @@ export class TransportHTTP implements Types.Transport {
|
||||
|
||||
private isTimeoutOrAbort(err: unknown): boolean {
|
||||
return (
|
||||
(err instanceof DOMException &&
|
||||
(err.name === "AbortError" || err.name === "TimeoutError")) ||
|
||||
(err instanceof Error &&
|
||||
(err.name === "AbortError" || err.name === "TimeoutError"))
|
||||
(err instanceof DOMException && (err.name === "AbortError" || err.name === "TimeoutError")) ||
|
||||
(err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user