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:
@@ -20,16 +20,8 @@ class FakeSocket extends Duplex {
|
||||
|
||||
_read() {}
|
||||
|
||||
_write(
|
||||
chunk: Buffer,
|
||||
_encoding: BufferEncoding,
|
||||
callback: (error?: Error | null) => void,
|
||||
) {
|
||||
this.lastWritten = new Uint8Array(
|
||||
chunk.buffer,
|
||||
chunk.byteOffset,
|
||||
chunk.byteLength,
|
||||
);
|
||||
_write(chunk: Buffer, _encoding: BufferEncoding, callback: (error?: Error | null) => void) {
|
||||
this.lastWritten = new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
||||
callback();
|
||||
}
|
||||
|
||||
@@ -69,16 +61,10 @@ function stubCoreTransforms() {
|
||||
});
|
||||
|
||||
const transform = Utils.toDeviceStream;
|
||||
vi.spyOn(Utils, "toDeviceStream", "get").mockReturnValue(
|
||||
toDevice as unknown as typeof transform,
|
||||
);
|
||||
vi.spyOn(Utils, "toDeviceStream", "get").mockReturnValue(toDevice as unknown as typeof transform);
|
||||
|
||||
vi.spyOn(Utils, "fromDeviceStream").mockImplementation(
|
||||
() =>
|
||||
fromDeviceFactory() as unknown as TransformStream<
|
||||
Uint8Array,
|
||||
Types.DeviceOutput
|
||||
>,
|
||||
() => fromDeviceFactory() as unknown as TransformStream<Uint8Array, Types.DeviceOutput>,
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -107,26 +93,22 @@ describe("TransportNode (contract)", () => {
|
||||
const fakeSocket = new FakeSocket();
|
||||
const transport = new TransportNode(fakeSocket as unknown as Socket);
|
||||
await Promise.resolve();
|
||||
(globalThis as unknown as { __nodeSock: FakeSocket }).__nodeSock =
|
||||
fakeSocket;
|
||||
(globalThis as unknown as { __nodeSock: FakeSocket }).__nodeSock = fakeSocket;
|
||||
return transport;
|
||||
},
|
||||
pushIncoming: async (bytes) => {
|
||||
(
|
||||
globalThis as unknown as { __nodeSock: FakeSocket }
|
||||
).__nodeSock.pushIncoming(bytes);
|
||||
(globalThis as unknown as { __nodeSock: FakeSocket }).__nodeSock.pushIncoming(bytes);
|
||||
await Promise.resolve();
|
||||
},
|
||||
assertLastWritten: (bytes) => {
|
||||
const sock = (globalThis as unknown as { __nodeSock: FakeSocket })
|
||||
.__nodeSock;
|
||||
const sock = (globalThis as unknown as { __nodeSock: FakeSocket }).__nodeSock;
|
||||
expect(sock.lastWritten).toBeDefined();
|
||||
expect(sock.lastWritten).toEqual(bytes);
|
||||
},
|
||||
triggerDisconnect: async () => {
|
||||
(
|
||||
globalThis as unknown as { __nodeSock: FakeSocket }
|
||||
).__nodeSock.emitErrorOnce("test-disconnect");
|
||||
(globalThis as unknown as { __nodeSock: FakeSocket }).__nodeSock.emitErrorOnce(
|
||||
"test-disconnect",
|
||||
);
|
||||
await Promise.resolve();
|
||||
},
|
||||
});
|
||||
@@ -153,17 +135,13 @@ describe("TransportNode (extras)", () => {
|
||||
const first = await reader.read();
|
||||
expect(isStatusEvent(first.value)).toBe(true);
|
||||
if (isStatusEvent(first.value)) {
|
||||
expect(first.value.data.status).toBe(
|
||||
Types.DeviceStatusEnum.DeviceConnecting,
|
||||
);
|
||||
expect(first.value.data.status).toBe(Types.DeviceStatusEnum.DeviceConnecting);
|
||||
}
|
||||
|
||||
const second = await reader.read();
|
||||
expect(isStatusEvent(second.value)).toBe(true);
|
||||
if (isStatusEvent(second.value)) {
|
||||
expect(second.value.data.status).toBe(
|
||||
Types.DeviceStatusEnum.DeviceConnected,
|
||||
);
|
||||
expect(second.value.data.status).toBe(Types.DeviceStatusEnum.DeviceConnected);
|
||||
}
|
||||
|
||||
fakeSocket.emitClose();
|
||||
|
||||
@@ -16,8 +16,7 @@ export class TransportNode implements Types.Transport {
|
||||
private socket: Socket | undefined;
|
||||
private pipePromise?: Promise<void>;
|
||||
private abortController: AbortController;
|
||||
private lastStatus: Types.DeviceStatusEnum =
|
||||
Types.DeviceStatusEnum.DeviceDisconnected;
|
||||
private lastStatus: Types.DeviceStatusEnum = Types.DeviceStatusEnum.DeviceDisconnected;
|
||||
|
||||
private closingByUser = false;
|
||||
private errored = false;
|
||||
@@ -29,11 +28,7 @@ export class TransportNode implements Types.Transport {
|
||||
* @param timeout - TCP socket timeout in milliseconds (defaults to 60000).
|
||||
* @returns A promise that resolves with a connected TransportNode instance.
|
||||
*/
|
||||
public static create(
|
||||
hostname: string,
|
||||
port = 4403,
|
||||
timeout = 60000,
|
||||
): Promise<TransportNode> {
|
||||
public static create(hostname: string, port = 4403, timeout = 60000): Promise<TransportNode> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const socket = new Socket();
|
||||
|
||||
@@ -65,10 +60,7 @@ export class TransportNode implements Types.Transport {
|
||||
this.socket?.removeAllListeners();
|
||||
this.socket?.destroy();
|
||||
if (!this.closingByUser) {
|
||||
this.emitStatus(
|
||||
Types.DeviceStatusEnum.DeviceDisconnected,
|
||||
"socket-error",
|
||||
);
|
||||
this.emitStatus(Types.DeviceStatusEnum.DeviceDisconnected, "socket-error");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -82,10 +74,7 @@ export class TransportNode implements Types.Transport {
|
||||
});
|
||||
|
||||
this.socket.on("timeout", () => {
|
||||
this.emitStatus(
|
||||
Types.DeviceStatusEnum.DeviceDisconnected,
|
||||
"socket-timeout",
|
||||
);
|
||||
this.emitStatus(Types.DeviceStatusEnum.DeviceDisconnected, "socket-timeout");
|
||||
this.socket?.removeAllListeners();
|
||||
this.socket?.destroy();
|
||||
});
|
||||
@@ -94,18 +83,13 @@ export class TransportNode implements Types.Transport {
|
||||
if (this.closingByUser) {
|
||||
return; // suppress close-derived disconnect in user flow
|
||||
}
|
||||
this.emitStatus(
|
||||
Types.DeviceStatusEnum.DeviceDisconnected,
|
||||
"socket-closed",
|
||||
);
|
||||
this.emitStatus(Types.DeviceStatusEnum.DeviceDisconnected, "socket-closed");
|
||||
});
|
||||
|
||||
this.abortController = new AbortController();
|
||||
const abortController = this.abortController;
|
||||
|
||||
const fromDeviceSource = Readable.toWeb(
|
||||
connection,
|
||||
) as ReadableStream<Uint8Array>;
|
||||
const fromDeviceSource = Readable.toWeb(connection) as ReadableStream<Uint8Array>;
|
||||
const transformed = fromDeviceSource.pipeThrough(Utils.fromDeviceStream());
|
||||
|
||||
this._fromDevice = new ReadableStream<Types.DeviceOutput>({
|
||||
@@ -129,14 +113,9 @@ export class TransportNode implements Types.Transport {
|
||||
if (this.closingByUser || this.errored) {
|
||||
ctrl.close();
|
||||
} else {
|
||||
this.emitStatus(
|
||||
Types.DeviceStatusEnum.DeviceDisconnected,
|
||||
"read-error",
|
||||
);
|
||||
this.emitStatus(Types.DeviceStatusEnum.DeviceDisconnected, "read-error");
|
||||
|
||||
ctrl.error(
|
||||
error instanceof Error ? error : new Error(String(error)),
|
||||
);
|
||||
ctrl.error(error instanceof Error ? error : new Error(String(error)));
|
||||
}
|
||||
try {
|
||||
await transformed.cancel();
|
||||
|
||||
Reference in New Issue
Block a user