mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 17:14:52 -07:00
Add ESLint & Run it against the system (#4470)
This commit is contained in:
parent
43eee6b32e
commit
f789e02096
106 changed files with 1235 additions and 20242 deletions
|
|
@ -61,4 +61,4 @@ describe('RoomEvents', () => {
|
|||
data
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ import { RoomPersistence } from '../persistence/RoomPersistence';
|
|||
import { ProtobufEvents } from '../services/ProtobufService';
|
||||
|
||||
export const RoomEvents: ProtobufEvents = {
|
||||
".Event_JoinRoom.ext": joinRoom,
|
||||
".Event_LeaveRoom.ext": leaveRoom,
|
||||
".Event_ListGames.ext": listGames,
|
||||
".Event_RoomSay.ext": roomSay,
|
||||
'.Event_JoinRoom.ext': joinRoom,
|
||||
'.Event_LeaveRoom.ext': leaveRoom,
|
||||
'.Event_ListGames.ext': listGames,
|
||||
'.Event_RoomSay.ext': roomSay,
|
||||
};
|
||||
|
||||
function joinRoom({ userInfo }: JoinRoomData, { roomEvent }: RoomEvent) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {StatusEnum} from "types";
|
||||
import { StatusEnum } from 'types';
|
||||
|
||||
import {
|
||||
AddToListData,
|
||||
|
|
@ -12,10 +12,10 @@ import {
|
|||
UserLeftData,
|
||||
} from './SessionEvents';
|
||||
|
||||
import {SessionCommands} from "../commands";
|
||||
import {RoomPersistence, SessionPersistence} from '../persistence';
|
||||
import { SessionCommands } from '../commands';
|
||||
import { RoomPersistence, SessionPersistence } from '../persistence';
|
||||
import webClient from '../WebClient';
|
||||
import {WebSocketConnectReason} from "../services/WebSocketService";
|
||||
import { WebSocketConnectReason } from '../services/WebSocketService';
|
||||
|
||||
describe('SessionEvents', () => {
|
||||
const roomId = 1;
|
||||
|
|
@ -340,7 +340,10 @@ describe('SessionEvents', () => {
|
|||
event(data);
|
||||
|
||||
expect(SessionCommands.disconnect).toHaveBeenCalled();
|
||||
expect(SessionCommands.updateStatus).toHaveBeenCalledWith(StatusEnum.DISCONNECTED, `Protocol version mismatch: ${data.protocolVersion}`);
|
||||
expect(SessionCommands.updateStatus).toHaveBeenCalledWith(
|
||||
StatusEnum.DISCONNECTED,
|
||||
`Protocol version mismatch: ${data.protocolVersion}`
|
||||
);
|
||||
expect(SessionCommands.login).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
@ -361,7 +364,7 @@ describe('SessionEvents', () => {
|
|||
describe('.Event_UserJoined.ext', () => {
|
||||
it('should call SessionPersistence.userJoined', () => {
|
||||
spyOn(SessionPersistence, 'userJoined');
|
||||
const data: UserJoinedData = { userInfo: {} as any };
|
||||
const data: UserJoinedData = { userInfo: {} as any };
|
||||
|
||||
SessionEvents['.Event_UserJoined.ext'](data);
|
||||
|
||||
|
|
@ -374,7 +377,7 @@ describe('SessionEvents', () => {
|
|||
describe('.Event_UserLeft.ext', () => {
|
||||
it('should call SessionPersistence.userLeft', () => {
|
||||
spyOn(SessionPersistence, 'userLeft');
|
||||
const data: UserLeftData = { name: '' };
|
||||
const data: UserLeftData = { name: '' };
|
||||
|
||||
SessionEvents['.Event_UserLeft.ext'](data);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import {Room, StatusEnum, User} from 'types';
|
||||
import { Room, StatusEnum, User } from 'types';
|
||||
|
||||
import {SessionCommands} from '../commands';
|
||||
import {RoomPersistence, SessionPersistence} from '../persistence';
|
||||
import {ProtobufEvents} from '../services/ProtobufService';
|
||||
import { SessionCommands } from '../commands';
|
||||
import { RoomPersistence, SessionPersistence } from '../persistence';
|
||||
import { ProtobufEvents } from '../services/ProtobufService';
|
||||
import webClient from '../WebClient';
|
||||
import {WebSocketConnectReason} from "../services/WebSocketService";
|
||||
import { WebSocketConnectReason } from '../services/WebSocketService';
|
||||
|
||||
export const SessionEvents: ProtobufEvents = {
|
||||
'.Event_AddToList.ext': addToList,
|
||||
|
|
@ -21,7 +21,7 @@ export const SessionEvents: ProtobufEvents = {
|
|||
'.Event_UserMessage.ext': userMessage,
|
||||
}
|
||||
|
||||
function addToList({ listName, userInfo}: AddToListData) {
|
||||
function addToList({ listName, userInfo }: AddToListData) {
|
||||
switch (listName) {
|
||||
case 'buddy': {
|
||||
SessionPersistence.addToBuddyList(userInfo);
|
||||
|
|
@ -44,7 +44,7 @@ function connectionClosed({ reason, reasonStr }: ConnectionClosedData) {
|
|||
if (reasonStr) {
|
||||
message = reasonStr;
|
||||
} else {
|
||||
switch(reason) {
|
||||
switch (reason) {
|
||||
case webClient.protobuf.controller.Event_ConnectionClosed.CloseReason.USER_LIMIT_REACHED:
|
||||
message = 'The server has reached its maximum user capacity';
|
||||
break;
|
||||
|
|
@ -147,7 +147,7 @@ function serverIdentification(info: ServerIdentificationData) {
|
|||
SessionCommands.resetPassword();
|
||||
break;
|
||||
default:
|
||||
SessionCommands.updateStatus(StatusEnum.DISCONNECTED, "Unknown Connection Reason: " + webClient.options.reason);
|
||||
SessionCommands.updateStatus(StatusEnum.DISCONNECTED, 'Unknown Connection Reason: ' + webClient.options.reason);
|
||||
SessionCommands.disconnect();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue