From 8fd148f091a2c7bb0a71996bcc7ff29e2f047339 Mon Sep 17 00:00:00 2001 From: Wojciech Kwolek Date: Sat, 8 Jun 2024 06:33:23 +0200 Subject: ray lint --fix --- package.json | 1 - src/index.tsx | 67 ++++++++++++++++++++++++++++++++++------------------------- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 3fd552b..b0e1c9a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ ] } ], - "tools": null, "dependencies": { "@raycast/api": "^1.76.0", "@raycast/utils": "^1.15.0" diff --git a/src/index.tsx b/src/index.tsx index b300f20..aa7f16b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,7 +3,7 @@ import { connect, Socket } from "net"; import { showFailureToast } from "@raycast/utils"; import { useState, useEffect, useRef } from "react"; -export default function Command({ arguments: { host, port } }: { arguments: { host: string, port: string } }) { +export default function Command({ arguments: { host, port } }: { arguments: { host: string; port: string } }) { const [elements, setElements] = useState(); const socket = useRef(); @@ -13,50 +13,61 @@ export default function Command({ arguments: { host, port } }: { arguments: { ho setElements([]); }; - const s = connect({ host, port: parseInt(port) }) - socket.current = s - s.on('error', showErr); + const s = connect({ host, port: parseInt(port) }); + socket.current = s; + s.on("error", showErr); - let buf: string = ''; + let buf: string = ""; - s.on('data', data => { + s.on("data", (data) => { buf += data; - const firstLineEnding = buf.indexOf('\n'); + const firstLineEnding = buf.indexOf("\n"); if (firstLineEnding == -1) return; const amount = parseInt(buf.slice(0, firstLineEnding)); - const lines = buf.slice(firstLineEnding + 1).trim().split("\n"); + const lines = buf + .slice(firstLineEnding + 1) + .trim() + .split("\n"); if (lines.length != amount) return; - setElements(lines.map(s => s.trim()).filter(s => s.length != 0)); - }) + setElements(lines.map((s) => s.trim()).filter((s) => s.length != 0)); + }); - s.on('close', () => closeMainWindow()); + s.on("close", () => closeMainWindow()); return () => { if (socket.current != null) socket.current.end(); - } - }, [host, port]) - + }; + }, [host, port]); return ( - {elements?.map((item, idx) => - { - const s = socket.current; - if (s == null) { - showFailureToast('Socket disconnected') - closeMainWindow(); - return; - } - s.write(item + '\n') - s.end() - }} /> - - } />)} + {elements?.map((item, idx) => ( + + { + const s = socket.current; + if (s == null) { + showFailureToast("Socket disconnected"); + closeMainWindow(); + return; + } + s.write(item + "\n"); + s.end(); + }} + /> + + } + /> + ))} ); } -- cgit v1.2.3