feature: Adds eslint rules.

This commit is contained in:
greysoh 2024-05-10 17:37:04 -04:00
parent 57a82a15e9
commit abc60691c6
No known key found for this signature in database
GPG key ID: FE0F173B8FC01571
26 changed files with 123 additions and 94 deletions

View file

@ -2,9 +2,18 @@ import globals from "globals";
import pluginJs from "@eslint/js"; import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint"; import tseslint from "typescript-eslint";
export default [ export default [
{languageOptions: { globals: globals.node }},
pluginJs.configs.recommended, pluginJs.configs.recommended,
...tseslint.configs.recommended, ...tseslint.configs.recommended,
{
languageOptions: {
globals: globals.node
},
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off"
}
},
]; ];

View file

@ -55,7 +55,7 @@ function parseBackendProviderString(data: string): BackendParsedProviderString {
if (typeof jsonData.ip != "string") if (typeof jsonData.ip != "string")
throw new Error("IP field is not a string"); throw new Error("IP field is not a string");
if (typeof jsonData.port != "number") throw new Error("Port is not a number"); if (typeof jsonData.port != "number") throw new Error("Port is not a number");
if ( if (
@ -63,7 +63,7 @@ function parseBackendProviderString(data: string): BackendParsedProviderString {
typeof jsonData.publicPort != "number" typeof jsonData.publicPort != "number"
) )
throw new Error("(optional field) Proxied port is not a number"); throw new Error("(optional field) Proxied port is not a number");
if ( if (
typeof jsonData.isProxied != "undefined" && typeof jsonData.isProxied != "undefined" &&
typeof jsonData.isProxied != "boolean" typeof jsonData.isProxied != "boolean"
@ -216,7 +216,7 @@ export class PassyFireBackendProvider implements BackendBaseClass {
static checkParametersBackendInstance(data: string): ParameterReturnedValue { static checkParametersBackendInstance(data: string): ParameterReturnedValue {
try { try {
parseBackendProviderString(data); parseBackendProviderString(data);
// @ts-expect-error // @ts-expect-error: We write the function, and we know we're returning an error
} catch (e: Error) { } catch (e: Error) {
return { return {
success: false, success: false,

View file

@ -69,7 +69,7 @@ export function route(instance: PassyFireBackendProvider) {
}, },
}, },
(req, res) => { (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
username: string; username: string;
password: string; password: string;
@ -115,7 +115,7 @@ export function route(instance: PassyFireBackendProvider) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
} = req.body; } = req.body;
@ -132,8 +132,7 @@ export function route(instance: PassyFireBackendProvider) {
req.hostname.indexOf(":") + 1, req.hostname.indexOf(":") + 1,
); );
// @ts-expect-error // @ts-expect-error: parseInt(...) can take a number just fine, at least in Node.JS
// parseInt(...) can take a number just fine, at least in Node.JS
const port = parseInt(unparsedPort == "" ? proxiedPort : unparsedPort); const port = parseInt(unparsedPort == "" ? proxiedPort : unparsedPort);
// This protocol is so confusing. I'm sorry. // This protocol is so confusing. I'm sorry.

View file

@ -14,7 +14,7 @@ function authenticateSocket(
ws: WebSocket, ws: WebSocket,
message: string, message: string,
state: ConnectedClientExt, state: ConnectedClientExt,
): Boolean { ): boolean {
if (!message.startsWith("Accept: ")) { if (!message.startsWith("Accept: ")) {
ws.send("400 Bad Request"); ws.send("400 Bad Request");
return false; return false;
@ -57,8 +57,8 @@ export function requestHandler(
let state: "authentication" | "data" = "authentication"; let state: "authentication" | "data" = "authentication";
let socket: dgram.Socket | net.Socket | undefined; let socket: dgram.Socket | net.Socket | undefined;
// @ts-expect-error // @ts-expect-error: FIXME because this is a mess
let connectedClient: ConnectedClientExt = {}; const connectedClient: ConnectedClientExt = {};
ws.on("close", () => { ws.on("close", () => {
instance.clients.splice( instance.clients.splice(

View file

@ -92,7 +92,7 @@ export class SSHBackendProvider implements BackendBaseClass {
this.logs.push(`Failed to start SSHBackendProvider! Error: '${e}'`); this.logs.push(`Failed to start SSHBackendProvider! Error: '${e}'`);
this.state = "stopped"; this.state = "stopped";
// @ts-expect-error // @ts-expect-error: We know that stuff will be initialized in order, so this will be safe
this.sshInstance = null; this.sshInstance = null;
return false; return false;
@ -112,7 +112,7 @@ export class SSHBackendProvider implements BackendBaseClass {
this.sshInstance.dispose(); this.sshInstance.dispose();
// @ts-expect-error // @ts-expect-error: We know that stuff will be initialized in order, so this will be safe
this.sshInstance = null; this.sshInstance = null;
this.logs.push("Successfully stopped SSHBackendProvider."); this.logs.push("Successfully stopped SSHBackendProvider.");
@ -255,7 +255,7 @@ export class SSHBackendProvider implements BackendBaseClass {
static checkParametersBackendInstance(data: string): ParameterReturnedValue { static checkParametersBackendInstance(data: string): ParameterReturnedValue {
try { try {
parseBackendProviderString(data); parseBackendProviderString(data);
// @ts-expect-error // @ts-expect-error: We write the function, and we know we're returning an error
} catch (e: Error) { } catch (e: Error) {
return { return {
success: false, success: false,

View file

@ -35,12 +35,12 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
name: string; name: string;
description?: string; description?: string;
connectionDetails: any; connectionDetails: unknown;
backend: string; backend: string;
} = req.body; } = req.body;

View file

@ -33,7 +33,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
id?: number; id?: number;
@ -69,7 +69,7 @@ export function route(routeOptions: RouteOptions) {
success: true, success: true,
data: prismaBackends.map(i => ({ data: prismaBackends.map(i => ({
id: i.id, id: i.id,
name: i.name, name: i.name,
description: i.description, description: i.description,

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
id: number; id: number;

View file

@ -27,7 +27,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
id: number; id: number;
@ -59,8 +59,12 @@ export function route(routeOptions: RouteOptions) {
return { return {
success: true, success: true,
data: backends[forward.destProviderID].getAllConnections().filter((i) => { data: backends[forward.destProviderID].getAllConnections().filter(i => {
return i.connectionDetails.sourceIP == forward.sourceIP && i.connectionDetails.sourcePort == forward.sourcePort && i.connectionDetails.destPort == forward.destPort; return (
i.connectionDetails.sourceIP == forward.sourceIP &&
i.connectionDetails.sourcePort == forward.sourcePort &&
i.connectionDetails.destPort == forward.destPort
);
}), }),
}; };
}, },

View file

@ -50,7 +50,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;

View file

@ -41,7 +41,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
id: number; id: number;

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
id: number; id: number;
@ -58,8 +58,7 @@ export function route(routeOptions: RouteOptions) {
error: "Backend not found", error: "Backend not found",
}); });
// Other restrictions in place make it so that it MUST be either TCP or UDP // @ts-expect-error: Other restrictions in place make it so that it MUST be either TCP or UDP
// @ts-expect-error
const protocol: "tcp" | "udp" = forward.protocol; const protocol: "tcp" | "udp" = forward.protocol;
backends[forward.destProviderID].addConnection( backends[forward.destProviderID].addConnection(

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
id: number; id: number;
@ -58,8 +58,7 @@ export function route(routeOptions: RouteOptions) {
error: "Backend not found", error: "Backend not found",
}); });
// Other restrictions in place make it so that it MUST be either TCP or UDP // @ts-expect-error: Other restrictions in place make it so that it MUST be either TCP or UDP
// @ts-expect-error
const protocol: "tcp" | "udp" = forward.protocol; const protocol: "tcp" | "udp" = forward.protocol;
backends[forward.destProviderID].removeConnection( backends[forward.destProviderID].removeConnection(

View file

@ -22,7 +22,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
} = req.body; } = req.body;

View file

@ -29,7 +29,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
name: string; name: string;
email: string; email: string;
@ -87,9 +87,9 @@ export function route(routeOptions: RouteOptions) {
} }
if (options.allowUnsafeGlobalTokens) { if (options.allowUnsafeGlobalTokens) {
// @ts-expect-error // @ts-expect-error: Setting this correctly is a goddamn mess, but this is safe to an extent. It won't crash at least
userData.rootToken = generateRandomData(); userData.rootToken = generateRandomData();
// @ts-expect-error // @ts-expect-error: Read above.
userData.isRootServiceAccount = true; userData.isRootServiceAccount = true;
} }

View file

@ -20,27 +20,28 @@ export function route(routeOptions: RouteOptions) {
properties: { properties: {
email: { type: "string" }, email: { type: "string" },
username: { type: "string" }, username: { type: "string" },
password: { type: "string" } password: { type: "string" },
}, },
}, },
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
email?: string; email?: string;
username?: string; username?: string;
password: string; password: string;
} = req.body; } = req.body;
if (!body.email && !body.username) return res.status(400).send({ if (!body.email && !body.username)
error: "missing both email and username. please supply at least one." return res.status(400).send({
}); error: "missing both email and username. please supply at least one.",
});
const userSearch = await prisma.user.findFirst({ const userSearch = await prisma.user.findFirst({
where: { where: {
email: body.email, email: body.email,
username: body.username username: body.username,
}, },
}); });

View file

@ -31,7 +31,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
id?: number; id?: number;
@ -64,7 +64,7 @@ export function route(routeOptions: RouteOptions) {
name: i.name, name: i.name,
email: i.email, email: i.email,
isServiceAccount: i.isRootServiceAccount, isServiceAccount: i.isRootServiceAccount,
username: i.username username: i.username,
})), })),
}; };
}, },

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
}, },
}, },
async (req, res) => { async (req, res) => {
// @ts-expect-error // @ts-expect-error: Fastify routes schema parsing is trustworthy, so we can "assume" invalid types
const body: { const body: {
token: string; token: string;
uid: number; uid: number;

View file

@ -4,7 +4,17 @@ import tseslint from "typescript-eslint";
export default [ export default [
{languageOptions: { globals: globals.node }},
pluginJs.configs.recommended, pluginJs.configs.recommended,
...tseslint.configs.recommended, ...tseslint.configs.recommended,
{
languageOptions: {
globals: globals.node,
},
rules: {
"@typescript-eslint/no-explicit-any": "off",
"no-constant-condition": "warn"
}
},
]; ];

View file

@ -4,7 +4,7 @@ import { run as connection } from "./commands/connections.js";
import { run as backends } from "./commands/backends.js"; import { run as backends } from "./commands/backends.js";
import { run as users } from "./commands/users.js"; import { run as users } from "./commands/users.js";
export type PrintLine = (...str: any[]) => void; export type PrintLine = (...str: unknown[]) => void;
export type KeyboardRead = (disableEcho?: boolean) => Promise<string>; export type KeyboardRead = (disableEcho?: boolean) => Promise<string>;
type Command = ( type Command = (
@ -12,7 +12,7 @@ type Command = (
println: PrintLine, println: PrintLine,
axios: Axios, axios: Axios,
apiKey: string, apiKey: string,
keyboardRead: KeyboardRead keyboardRead: KeyboardRead,
) => Promise<void>; ) => Promise<void>;
type Commands = { type Commands = {
@ -30,7 +30,9 @@ export const commands: Commands = [
printf(`${command.name}: ${command.description}\n`); printf(`${command.name}: ${command.description}\n`);
}); });
printf("\nRun a command of your choosing with --help to see more options.\n"); printf(
"\nRun a command of your choosing with --help to see more options.\n",
);
}, },
}, },
{ {
@ -43,21 +45,21 @@ export const commands: Commands = [
{ {
name: "conn", name: "conn",
description: "Manages connections for NextNet", description: "Manages connections for NextNet",
run: connection run: connection,
}, },
{ {
name: "user", name: "user",
description: "Manages users for NextNet", description: "Manages users for NextNet",
run: users run: users,
}, },
{ {
name: "backend", name: "backend",
description: "Manages backends for NextNet", description: "Manages backends for NextNet",
run: backends run: backends,
}, },
{ {
name: "back", name: "back",
description: "(alias) Manages backends for NextNet", description: "(alias) Manages backends for NextNet",
run: backends run: backends,
} },
]; ];

View file

@ -119,8 +119,7 @@ export async function run(
password?: string; password?: string;
}, },
) => { ) => {
// Yes it can index for what we need it to do. // @ts-expect-error: Yes it can index for what we need it to do.
// @ts-expect-error
const isUnsupportedPlatform: boolean = !addRequiredOptions[provider]; const isUnsupportedPlatform: boolean = !addRequiredOptions[provider];
if (isUnsupportedPlatform) { if (isUnsupportedPlatform) {
@ -141,9 +140,8 @@ export async function run(
connectionDetails = options.customParameters; connectionDetails = options.customParameters;
} else if (provider == "ssh") { } else if (provider == "ssh") {
for (const argument of addRequiredOptions["ssh"]) { for (const argument of addRequiredOptions["ssh"]) {
// No. // @ts-expect-error: No.
// @ts-expect-error const hasArgument = options[argument];
const hasArgument = options[argument] as any;
if (!hasArgument) { if (!hasArgument) {
return println("ERROR: Missing argument '%s'\n", argument); return println("ERROR: Missing argument '%s'\n", argument);
@ -177,8 +175,7 @@ export async function run(
connectionDetails = JSON.stringify(unstringifiedArguments); connectionDetails = JSON.stringify(unstringifiedArguments);
} else if (provider == "passyfire") { } else if (provider == "passyfire") {
for (const argument of addRequiredOptions["passyfire"]) { for (const argument of addRequiredOptions["passyfire"]) {
// No. // @ts-expect-error: No.
// @ts-expect-error
const hasArgument = options[argument]; const hasArgument = options[argument];
if (!hasArgument) { if (!hasArgument) {
@ -218,7 +215,9 @@ export async function run(
} }
if (options.userAsk) { if (options.userAsk) {
while (true) { let shouldContinueAsking: boolean = true;
while (shouldContinueAsking) {
println("Creating a user.\nUsername: "); println("Creating a user.\nUsername: ");
const username = await readKeyboard(); const username = await readKeyboard();
@ -247,14 +246,12 @@ export async function run(
}); });
println("\nShould we continue creating users? (y/n) "); println("\nShould we continue creating users? (y/n) ");
const shouldContinueAsking = (await readKeyboard()) shouldContinueAsking = (await readKeyboard())
.toLowerCase() .toLowerCase()
.trim() .trim()
.startsWith("y"); .startsWith("y");
println("\n\n"); println("\n\n");
if (!shouldContinueAsking) break;
} }
} }
@ -420,6 +417,7 @@ export async function run(
// We don't know what we're recieving. We just try to parse it (hence the any type) // We don't know what we're recieving. We just try to parse it (hence the any type)
// {} is more accurate but TS yells at us if we do that :( // {} is more accurate but TS yells at us if we do that :(
// eslint-disable-next-line
let parsedJSONData: any | undefined; let parsedJSONData: any | undefined;
try { try {

View file

@ -382,6 +382,8 @@ export async function run(
if (options.tail) { if (options.tail) {
let previousEntries: string[] = []; let previousEntries: string[] = [];
// FIXME?
// eslint-disable-next-line no-constant-condition
while (true) { while (true) {
const response = await axios.post("/api/v1/forward/connections", { const response = await axios.post("/api/v1/forward/connections", {
token, token,
@ -407,6 +409,7 @@ export async function run(
simplifiedArray, simplifiedArray,
previousEntries, previousEntries,
); );
const removedItems: string[] = difference( const removedItems: string[] = difference(
previousEntries, previousEntries,
simplifiedArray, simplifiedArray,

View file

@ -80,8 +80,7 @@ export async function run(
password = passwordConfirmOne; password = passwordConfirmOne;
} else { } else {
// From the first check we do, we know this is safe (you MUST specify a password) // @ts-expect-error: From the first check we do, we know this is safe (you MUST specify a password)
// @ts-expect-error
password = options.password; password = options.password;
} }
@ -120,7 +119,7 @@ export async function run(
return; return;
} }
let response = await axios.post("/api/v1/users/remove", { const response = await axios.post("/api/v1/users/remove", {
token: apiKey, token: apiKey,
uid, uid,
}); });

View file

@ -31,7 +31,7 @@ const serverBaseURL: string =
const axios = baseAxios.create({ const axios = baseAxios.create({
baseURL: serverBaseURL, baseURL: serverBaseURL,
validateStatus: () => true validateStatus: () => true,
}); });
try { try {
@ -70,7 +70,9 @@ const server: ssh2.Server = new ssh2.Server({
server.on("connection", client => { server.on("connection", client => {
let token: string = ""; let token: string = "";
// eslint-disable-next-line
let username: string = ""; let username: string = "";
// eslint-disable-next-line
let password: string = ""; let password: string = "";
client.on("authentication", async auth => { client.on("authentication", async auth => {
@ -79,11 +81,11 @@ server.on("connection", client => {
username: auth.username, username: auth.username,
password: auth.password, password: auth.password,
}); });
if (response.status == 403) { if (response.status == 403) {
return auth.reject(["password", "publickey"]); return auth.reject(["password", "publickey"]);
} }
token = response.data.token; token = response.data.token;
username = auth.username; username = auth.username;
@ -133,12 +135,12 @@ server.on("connection", client => {
auth.accept(); auth.accept();
} else { } else {
return auth.reject(["password", "publickey"]); return auth.reject(["password", "publickey"]);
} }
}); });
client.on("ready", () => { client.on("ready", () => {
client.on("session", (accept, reject) => { client.on("session", accept => {
const conn = accept(); const conn = accept();
conn.on("exec", async (accept, reject, info) => { conn.on("exec", async (accept, reject, info) => {
@ -149,32 +151,32 @@ server.on("connection", client => {
} }
// Matches on ; and && // Matches on ; and &&
const commandsRecv = info.command.split(/;|&&/).map((i) => i.trim()); const commandsRecv = info.command.split(/;|&&/).map(i => i.trim());
function println(...data: any[]) { function println(...data: unknown[]) {
stream.write(format(...data).replaceAll("\n", "\r\n")); stream.write(format(...data).replaceAll("\n", "\r\n"));
}; }
for (const command of commandsRecv) { for (const command of commandsRecv) {
const argv = parseArgsStringToArgv(command); const argv = parseArgsStringToArgv(command);
if (argv[0] == "exit") { if (argv[0] == "exit") {
stream.close(); stream.close();
} else { } else {
const command = commands.find(i => i.name == argv[0]); const command = commands.find(i => i.name == argv[0]);
if (!command) { if (!command) {
stream.write( stream.write(`Unknown command ${argv[0]}.\r\n`);
`Unknown command ${argv[0]}.\r\n`,
);
continue; continue;
} }
await command.run(argv, println, axios, token, (disableEcho) => readFromKeyboard(stream, disableEcho)); await command.run(argv, println, axios, token, disableEcho =>
readFromKeyboard(stream, disableEcho),
);
} }
} }
return stream.close(); return stream.close();
}); });
@ -191,26 +193,28 @@ server.on("connection", client => {
"Welcome to NextNet LOM. Run 'help' to see commands.\r\n\r\n~$ ", "Welcome to NextNet LOM. Run 'help' to see commands.\r\n\r\n~$ ",
); );
function println(...data: any[]) { function println(...data: unknown[]) {
stream.write(format(...data).replaceAll("\n", "\r\n")); stream.write(format(...data).replaceAll("\n", "\r\n"));
}; }
// FIXME (greysoh): wtf? this isn't setting correctly.
// @eslint-disable-next-line
while (true) { while (true) {
const line = await readFromKeyboard(stream); const line = await readFromKeyboard(stream);
stream.write("\r\n"); stream.write("\r\n");
if (line == "") { if (line == "") {
stream.write(`~$ `); stream.write(`~$ `);
continue; continue;
} }
const argv = parseArgsStringToArgv(line); const argv = parseArgsStringToArgv(line);
if (argv[0] == "exit") { if (argv[0] == "exit") {
stream.close(); stream.close();
} else { } else {
const command = commands.find(i => i.name == argv[0]); const command = commands.find(i => i.name == argv[0]);
if (!command) { if (!command) {
stream.write( stream.write(
`Unknown command ${argv[0]}. Run 'help' to see commands.\r\n~$ `, `Unknown command ${argv[0]}. Run 'help' to see commands.\r\n~$ `,
@ -218,8 +222,10 @@ server.on("connection", client => {
continue; continue;
} }
await command.run(argv, println, axios, token, (disableEcho) => readFromKeyboard(stream, disableEcho)); await command.run(argv, println, axios, token, disableEcho =>
readFromKeyboard(stream, disableEcho),
);
stream.write("~$ "); stream.write("~$ ");
} }
} }

View file

@ -5,7 +5,7 @@ export class SSHCommand extends Command {
hasRecievedExitSignal: boolean; hasRecievedExitSignal: boolean;
println: PrintLine; println: PrintLine;
exitEventHandlers: ((...any: any[]) => void)[]; exitEventHandlers: ((...any: unknown[]) => void)[];
parent: SSHCommand | null; parent: SSHCommand | null;
/** /**
@ -81,11 +81,11 @@ export class SSHCommand extends Command {
action(fn: (...args: any[]) => void | Promise<void>): this { action(fn: (...args: any[]) => void | Promise<void>): this {
super.action(fn); super.action(fn);
// @ts-expect-error // @ts-expect-error: This parameter is private, but we need control over it.
// prettier-ignore // prettier-ignore
const oldActionHandler: (...args: any[]) => void | Promise<void> = this._actionHandler; const oldActionHandler: (...args: any[]) => void | Promise<void> = this._actionHandler;
// @ts-expect-error // @ts-expect-error: Overriding private parameters (but this works)
this._actionHandler = async (...args: any[]): Promise<void> => { this._actionHandler = async (...args: any[]): Promise<void> => {
if (this.hasRecievedExitSignal) return; if (this.hasRecievedExitSignal) return;
await oldActionHandler(...args); await oldActionHandler(...args);