fix: address lint warnings in new files
- wsTransport.ts: Use addEventListener instead of on-function assignments - wsServer.ts: Replace filter(Boolean).pop() with direct array access - wsServer.test.ts: Use addEventListener for WebSocket events Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
871fe5e8b8
commit
bb4f4d57e8
3 files changed
+15
-15
No files matched your search
@@ -93,23 +93,23 @@ export class WsTransport {
|
||||
|
||||
const ws = new WebSocket(this.url);
|
||||
|
||||
ws.onopen = () => {
|
||||
ws.addEventListener("open", () => {
|
||||
this.ws = ws;
|
||||
this.reconnectAttempt = 0;
|
||||
};
|
||||
});
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
ws.addEventListener("message", (event) => {
|
||||
this.handleMessage(event.data);
|
||||
};
|
||||
});
|
||||
|
||||
ws.onclose = () => {
|
||||
ws.addEventListener("close", () => {
|
||||
this.ws = null;
|
||||
this.scheduleReconnect();
|
||||
};
|
||||
});
|
||||
|
||||
ws.onerror = () => {
|
||||
// onclose will fire after onerror
|
||||
};
|
||||
ws.addEventListener("error", () => {
|
||||
// close event will fire after error
|
||||
});
|
||||
}
|
||||
|
||||
private handleMessage(raw: unknown) {
|
||||
|
||||
@@ -6,8 +6,10 @@ import { WS_CHANNELS, WS_METHODS, type WsPush, type WsResponse } from "@acme/con
|
||||
function connectWs(port: number): Promise<WebSocket> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const ws = new WebSocket(`ws://localhost:${port}`);
|
||||
ws.onopen = () => resolve(ws);
|
||||
ws.onerror = () => reject(new Error("WebSocket connection failed"));
|
||||
ws.addEventListener("open", () => resolve(ws));
|
||||
ws.addEventListener("error", () =>
|
||||
reject(new Error("WebSocket connection failed")),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -121,10 +121,8 @@ export function createServer(options: ServerOptions) {
|
||||
clients.add(ws);
|
||||
|
||||
// Send welcome message with project info
|
||||
const projectName =
|
||||
cwd.split("/").filter(Boolean).pop() ??
|
||||
cwd.split("\\").filter(Boolean).pop() ??
|
||||
"project";
|
||||
const segments = cwd.split(/[/\\]/).filter(Boolean);
|
||||
const projectName = segments[segments.length - 1] ?? "project";
|
||||
|
||||
const welcome: WsPush = {
|
||||
type: "push",
|
||||
|
||||
Reference in new issue
Block a user