Add ESLint & Run it against the system (#4470)

This commit is contained in:
Zach H 2021-11-13 14:49:06 -05:00 committed by ZeldaZach
parent 43eee6b32e
commit f789e02096
106 changed files with 1235 additions and 20242 deletions

View file

@ -1,5 +1,5 @@
import { KeepAliveService } from './KeepAliveService';
import { WebSocketService } from "./WebSocketService";
import { WebSocketService } from './WebSocketService';
import webClient from '../WebClient';

View file

@ -1,6 +1,6 @@
import { Subject } from "rxjs";
import { Subject } from 'rxjs';
import { WebSocketService } from "./WebSocketService";
import { WebSocketService } from './WebSocketService';
export class KeepAliveService {
private socket: WebSocketService;

View file

@ -1,7 +1,7 @@
import protobuf from "protobufjs";
import protobuf from 'protobufjs';
import ProtoFiles from "../ProtoFiles";
import { WebClient } from "../WebClient";
import ProtoFiles from '../ProtoFiles';
import { WebClient } from '../WebClient';
import { RoomEvents, SessionEvents } from '../events';
@ -31,8 +31,8 @@ export class ProtobufService {
public sendRoomCommand(roomId: number, roomCmd: number, callback?: Function) {
const cmd = this.controller.CommandContainer.create({
"roomId" : roomId,
"roomCommand" : [ roomCmd ]
'roomId': roomId,
'roomCommand': [roomCmd]
});
this.sendCommand(cmd, raw => callback && callback(raw));
@ -40,7 +40,7 @@ export class ProtobufService {
public sendSessionCommand(sesCmd: number, callback?: Function) {
const cmd = this.controller.CommandContainer.create({
"sessionCommand" : [ sesCmd ]
'sessionCommand': [sesCmd]
});
this.sendCommand(cmd, (raw) => callback && callback(raw));
@ -48,7 +48,7 @@ export class ProtobufService {
public sendModeratorCommand(modCmd: number, callback?: Function) {
const cmd = this.controller.CommandContainer.create({
"moderatorCommand" : [ modCmd ]
'moderatorCommand': [modCmd]
});
this.sendCommand(cmd, (raw) => callback && callback(raw));
@ -57,7 +57,7 @@ export class ProtobufService {
public sendCommand(cmd: number, callback: Function) {
this.cmdId++;
cmd["cmdId"] = this.cmdId;
cmd['cmdId'] = this.cmdId;
this.pendingCommands[this.cmdId] = callback;
if (this.webClient.socket.checkReadyState(WebSocket.OPEN)) {
@ -67,7 +67,7 @@ export class ProtobufService {
public sendKeepAliveCommand(pingReceived: Function) {
const command = this.controller.SessionCommand.create({
".Command_Ping.ext" : this.controller.Command_Ping.create()
'.Command_Ping.ext': this.controller.Command_Ping.create()
});
this.sendSessionCommand(command, pingReceived);
@ -90,12 +90,12 @@ export class ProtobufService {
this.processSessionEvent(msg.sessionEvent, msg);
break;
case this.controller.ServerMessage.MessageType.GAME_EVENT_CONTAINER:
// @TODO
// @TODO
break;
}
}
} catch (err) {
console.error("Processing failed:", err);
console.error('Processing failed:', err);
}
}

View file

@ -1,8 +1,8 @@
import { Subject } from 'rxjs';
import { ServerStatus, StatusEnum } from "types";
import { ServerStatus, StatusEnum } from 'types';
import { KeepAliveService } from "./KeepAliveService";
import { KeepAliveService } from './KeepAliveService';
import { WebClient } from '../WebClient';
export interface WebSocketOptions {
@ -42,7 +42,7 @@ export class WebSocketService {
this.keepAliveService = new KeepAliveService(this);
this.keepAliveService.disconnected$.subscribe(() => {
this.disconnect();
this.updateStatus(StatusEnum.DISCONNECTED, "Connection timeout");
this.updateStatus(StatusEnum.DISCONNECTED, 'Connection timeout');
});
}
@ -73,15 +73,15 @@ export class WebSocketService {
public updateStatus(status: StatusEnum, description: string): void {
this.status = status;
this.statusChange$.next({status, description});
this.statusChange$.next({ status, description });
}
private createWebSocket(url: string): WebSocket {
const socket = new WebSocket(url);
socket.binaryType = "arraybuffer"; // We are talking binary
socket.binaryType = 'arraybuffer';
socket.onopen = () => {
this.updateStatus(StatusEnum.CONNECTED, "Connected");
this.updateStatus(StatusEnum.CONNECTED, 'Connected');
this.keepAliveService.startPingLoop(this.keepalive, (pingReceived: Function) => {
this.webClient.keepAlive(pingReceived);
@ -91,14 +91,14 @@ export class WebSocketService {
socket.onclose = () => {
// dont overwrite failure messages
if (this.status !== StatusEnum.DISCONNECTED) {
this.updateStatus(StatusEnum.DISCONNECTED, "Connection Closed");
this.updateStatus(StatusEnum.DISCONNECTED, 'Connection Closed');
}
this.keepAliveService.endPingLoop();
};
socket.onerror = () => {
this.updateStatus(StatusEnum.DISCONNECTED, "Connection Failed");
this.updateStatus(StatusEnum.DISCONNECTED, 'Connection Failed');
};
socket.onmessage = (event: MessageEvent) => {