chore: Adds initial support for eslint.

This commit is contained in:
greysoh 2024-05-10 11:46:22 -04:00
parent 8b4f3715e9
commit 7e80b298a2
Signed by: imterah
GPG key ID: 8FA7DD57BA6CEA37
34 changed files with 3441 additions and 649 deletions

10
api/eslint.config.js Normal file
View file

@ -0,0 +1,10 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
export default [
{languageOptions: { globals: globals.node }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];

1327
api/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -14,14 +14,18 @@
"author": "greysoh",
"license": "BSD-3-Clause",
"devDependencies": {
"@eslint/js": "^9.2.0",
"@types/bcrypt": "^5.0.2",
"@types/node": "^20.12.7",
"@types/ssh2": "^1.15.0",
"@types/ws": "^8.5.10",
"eslint": "^8.57.0",
"globals": "^15.2.0",
"nodemon": "^3.0.3",
"prettier": "^3.2.5",
"prisma": "^5.13.0",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"typescript-eslint": "^7.8.0"
},
"dependencies": {
"@fastify/websocket": "^10.0.1",

View file

@ -1,3 +1,5 @@
// @eslint-ignore-file
export type ParameterReturnedValue = {
success: boolean;
message?: string;

View file

@ -10,4 +10,4 @@ export const backendProviders: Record<string, typeof BackendBaseClass> = {
if (process.env.NODE_ENV != "production") {
backendProviders["dummy"] = BackendBaseClass;
}
}

View file

@ -216,7 +216,7 @@ export class PassyFireBackendProvider implements BackendBaseClass {
static checkParametersBackendInstance(data: string): ParameterReturnedValue {
try {
parseBackendProviderString(data);
// @ts-ignore
// @ts-expect-error
} catch (e: Error) {
return {
success: false,

View file

@ -69,7 +69,7 @@ export function route(instance: PassyFireBackendProvider) {
},
},
(req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
username: string;
password: string;
@ -115,7 +115,7 @@ export function route(instance: PassyFireBackendProvider) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
} = req.body;
@ -132,7 +132,7 @@ export function route(instance: PassyFireBackendProvider) {
req.hostname.indexOf(":") + 1,
);
// @ts-ignore
// @ts-expect-error
// parseInt(...) can take a number just fine, at least in Node.JS
const port = parseInt(unparsedPort == "" ? proxiedPort : unparsedPort);

View file

@ -57,7 +57,7 @@ export function requestHandler(
let state: "authentication" | "data" = "authentication";
let socket: dgram.Socket | net.Socket | undefined;
// @ts-ignore
// @ts-expect-error
let connectedClient: ConnectedClientExt = {};
ws.on("close", () => {

View file

@ -92,7 +92,7 @@ export class SSHBackendProvider implements BackendBaseClass {
this.logs.push(`Failed to start SSHBackendProvider! Error: '${e}'`);
this.state = "stopped";
// @ts-ignore
// @ts-expect-error
this.sshInstance = null;
return false;
@ -112,7 +112,7 @@ export class SSHBackendProvider implements BackendBaseClass {
this.sshInstance.dispose();
// @ts-ignore
// @ts-expect-error
this.sshInstance = null;
this.logs.push("Successfully stopped SSHBackendProvider.");
@ -255,7 +255,7 @@ export class SSHBackendProvider implements BackendBaseClass {
static checkParametersBackendInstance(data: string): ParameterReturnedValue {
try {
parseBackendProviderString(data);
// @ts-ignore
// @ts-expect-error
} catch (e: Error) {
return {
success: false,

View file

@ -27,7 +27,7 @@ export const permissionListDisabled: Record<string, boolean> = {
};
// FIXME: This solution fucking sucks.
export let permissionListEnabled: Record<string, boolean> = JSON.parse(
export const permissionListEnabled: Record<string, boolean> = JSON.parse(
JSON.stringify(permissionListDisabled),
);

View file

@ -35,7 +35,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
name: string;

View file

@ -33,7 +33,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
id?: number;

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
id: number;

View file

@ -27,7 +27,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
id: number;

View file

@ -50,7 +50,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;

View file

@ -41,7 +41,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
id: number;

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
id: number;
@ -59,7 +59,7 @@ export function route(routeOptions: RouteOptions) {
});
// Other restrictions in place make it so that it MUST be either TCP or UDP
// @ts-ignore
// @ts-expect-error
const protocol: "tcp" | "udp" = forward.protocol;
backends[forward.destProviderID].addConnection(

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
id: number;
@ -59,7 +59,7 @@ export function route(routeOptions: RouteOptions) {
});
// Other restrictions in place make it so that it MUST be either TCP or UDP
// @ts-ignore
// @ts-expect-error
const protocol: "tcp" | "udp" = forward.protocol;
backends[forward.destProviderID].removeConnection(

View file

@ -22,7 +22,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
} = req.body;

View file

@ -29,7 +29,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
name: string;
email: string;
@ -87,9 +87,9 @@ export function route(routeOptions: RouteOptions) {
}
if (options.allowUnsafeGlobalTokens) {
// @ts-ignore
// @ts-expect-error
userData.rootToken = generateRandomData();
// @ts-ignore
// @ts-expect-error
userData.isRootServiceAccount = true;
}

View file

@ -26,7 +26,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
email?: string;
username?: string;

View file

@ -31,7 +31,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
id?: number;

View file

@ -30,7 +30,7 @@ export function route(routeOptions: RouteOptions) {
},
},
async (req, res) => {
// @ts-ignore
// @ts-expect-error
const body: {
token: string;
uid: number;