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 FakeSerialPort 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() {
|
||||
|
||||
// Utils.toDeviceStream is a getter
|
||||
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 {
|
||||
@@ -105,30 +91,24 @@ describe("TransportNodeSerial (contract)", () => {
|
||||
},
|
||||
create: async () => {
|
||||
const fakePort = new FakeSerialPort();
|
||||
const transport = new TransportNodeSerial(
|
||||
fakePort as unknown as SerialPort,
|
||||
);
|
||||
const transport = new TransportNodeSerial(fakePort as unknown as SerialPort);
|
||||
await Promise.resolve();
|
||||
(globalThis as unknown as { __fakePort: FakeSerialPort }).__fakePort =
|
||||
fakePort;
|
||||
(globalThis as unknown as { __fakePort: FakeSerialPort }).__fakePort = fakePort;
|
||||
return transport;
|
||||
},
|
||||
pushIncoming: async (bytes) => {
|
||||
(
|
||||
globalThis as unknown as { __fakePort: FakeSerialPort }
|
||||
).__fakePort.pushIncoming(bytes);
|
||||
(globalThis as unknown as { __fakePort: FakeSerialPort }).__fakePort.pushIncoming(bytes);
|
||||
await Promise.resolve();
|
||||
},
|
||||
assertLastWritten: (bytes) => {
|
||||
const port = (globalThis as unknown as { __fakePort: FakeSerialPort })
|
||||
.__fakePort;
|
||||
const port = (globalThis as unknown as { __fakePort: FakeSerialPort }).__fakePort;
|
||||
expect(port.lastWritten).toBeDefined();
|
||||
expect(port.lastWritten).toEqual(bytes);
|
||||
},
|
||||
triggerDisconnect: async () => {
|
||||
(
|
||||
globalThis as unknown as { __fakePort: FakeSerialPort }
|
||||
).__fakePort.emitErrorOnce("test-disconnect");
|
||||
(globalThis as unknown as { __fakePort: FakeSerialPort }).__fakePort.emitErrorOnce(
|
||||
"test-disconnect",
|
||||
);
|
||||
await Promise.resolve();
|
||||
},
|
||||
});
|
||||
@@ -147,9 +127,7 @@ describe("TransportNodeSerial (extras)", () => {
|
||||
|
||||
it("emits DeviceDisconnected with reason 'port-closed' on close event", async () => {
|
||||
const fakePort = new FakeSerialPort();
|
||||
const transport = new TransportNodeSerial(
|
||||
fakePort as unknown as SerialPort,
|
||||
);
|
||||
const transport = new TransportNodeSerial(fakePort as unknown as SerialPort);
|
||||
const reader = transport.fromDevice.getReader();
|
||||
|
||||
await Promise.resolve();
|
||||
@@ -157,17 +135,13 @@ describe("TransportNodeSerial (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);
|
||||
}
|
||||
|
||||
fakePort.emitClose();
|
||||
|
||||
@@ -16,8 +16,7 @@ export class TransportNodeSerial implements Types.Transport {
|
||||
private port: SerialPort | 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;
|
||||
|
||||
/**
|
||||
@@ -26,10 +25,7 @@ export class TransportNodeSerial implements Types.Transport {
|
||||
* @param baudRate - Baud rate for the serial connection (default is 115200).
|
||||
* @returns A promise that resolves with a connected TransportNode instance.
|
||||
*/
|
||||
public static create(
|
||||
path: string,
|
||||
baudRate = 115200,
|
||||
): Promise<TransportNodeSerial> {
|
||||
public static create(path: string, baudRate = 115200): Promise<TransportNodeSerial> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const port = new SerialPort({
|
||||
path,
|
||||
@@ -94,13 +90,8 @@ export class TransportNodeSerial implements Types.Transport {
|
||||
if (this.closingByUser) {
|
||||
ctrl.close(); // graceful EOF on user
|
||||
} else {
|
||||
this.emitStatus(
|
||||
Types.DeviceStatusEnum.DeviceDisconnected,
|
||||
"read-error",
|
||||
);
|
||||
ctrl.error(
|
||||
error instanceof Error ? error : new Error(String(error)),
|
||||
);
|
||||
this.emitStatus(Types.DeviceStatusEnum.DeviceDisconnected, "read-error");
|
||||
ctrl.error(error instanceof Error ? error : new Error(String(error)));
|
||||
}
|
||||
try {
|
||||
await transformed.cancel();
|
||||
@@ -124,10 +115,7 @@ export class TransportNodeSerial implements Types.Transport {
|
||||
return;
|
||||
}
|
||||
console.error("Error piping data to serial port:", error);
|
||||
this.emitStatus(
|
||||
Types.DeviceStatusEnum.DeviceDisconnected,
|
||||
"write-error",
|
||||
);
|
||||
this.emitStatus(Types.DeviceStatusEnum.DeviceDisconnected, "write-error");
|
||||
try {
|
||||
this.port?.close();
|
||||
} catch {}
|
||||
|
||||
Reference in New Issue
Block a user