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 @@
export * from "./rooms.actions";
export * from "./rooms.dispatch";
export * from "./rooms.reducer";
export * from "./rooms.selectors";
export * from "./rooms.types";
export * from './rooms.actions';
export * from './rooms.dispatch';
export * from './rooms.reducer';
export * from './rooms.selectors';
export * from './rooms.types';

View file

@ -1,10 +1,10 @@
import { Types } from "./rooms.types";
import { Types } from './rooms.types';
export const Actions = {
clearStore: () => ({
type: Types.CLEAR_STORE
}),
updateRooms: rooms => ({
type: Types.UPDATE_ROOMS,
rooms

View file

@ -1,6 +1,6 @@
import { reset } from 'redux-form';
import { Actions } from "./rooms.actions";
import { store } from "store";
import { Actions } from './rooms.actions';
import { store } from 'store';
// const history = useHistory();
@ -8,7 +8,7 @@ export const Dispatch = {
clearStore: () => {
store.dispatch(Actions.clearStore());
},
updateRooms: rooms => {
store.dispatch(Actions.updateRooms(rooms));
},
@ -26,7 +26,7 @@ export const Dispatch = {
if (message.name) {
store.dispatch(reset('sayMessage'));
}
store.dispatch(Actions.addMessage(roomId, message));
},
@ -45,4 +45,4 @@ export const Dispatch = {
sortGames: (roomId, field, order) => {
store.dispatch(Actions.sortGames(roomId, field, order));
}
}
}

View file

@ -1,4 +1,4 @@
import { GameSortField, Room, SortBy, UserSortField } from "types";
import { GameSortField, Room, SortBy, UserSortField } from 'types';
export interface RoomsState {
rooms: RoomsStateRooms;

View file

@ -1,11 +1,11 @@
import * as _ from "lodash";
import * as _ from 'lodash';
import { GameSortField, UserSortField, SortDirection } from "types";
import { GameSortField, UserSortField, SortDirection } from 'types';
import { SortUtil } from "../common";
import { SortUtil } from '../common';
import { RoomsState } from "./rooms.interfaces"
import { MAX_ROOM_MESSAGES, Types } from "./rooms.types";
import { RoomsState } from './rooms.interfaces'
import { MAX_ROOM_MESSAGES, Types } from './rooms.types';
const initialState: RoomsState = {
rooms: {},
@ -22,7 +22,7 @@ const initialState: RoomsState = {
};
export const roomsReducer = (state = initialState, action: any) => {
switch(action.type) {
switch (action.type) {
case Types.CLEAR_STORE: {
return {
...initialState
@ -37,7 +37,7 @@ export const roomsReducer = (state = initialState, action: any) => {
_.each(action.rooms, (room, order) => {
const { roomId } = room;
const existing = rooms[roomId] || {};
const update = { ...room };
delete update.gameList;
delete update.gametypeList;
@ -113,7 +113,7 @@ export const roomsReducer = (state = initialState, action: any) => {
const { roomId, message } = action;
const { messages } = state;
let roomMessages = [ ...(messages[roomId] || []) ];
let roomMessages = [...(messages[roomId] || [])];
if (roomMessages.length === MAX_ROOM_MESSAGES) {
roomMessages.shift();
@ -150,7 +150,7 @@ export const roomsReducer = (state = initialState, action: any) => {
}, {});
const gameUpdates = room.gameList
// filter out closed games and remove from update map
// filter out closed games and remove from update map
.filter(game => {
const gameUpdate = toUpdate[game.gameId];
const closedGame = gameUpdate && gameUpdate.closed;
@ -181,7 +181,7 @@ export const roomsReducer = (state = initialState, action: any) => {
_.each(toUpdate, game => gameUpdates.push(game));
}
const gameList = [ ...gameUpdates ];
const gameList = [...gameUpdates];
SortUtil.sortByField(gameList, sortGamesBy);
@ -216,7 +216,7 @@ export const roomsReducer = (state = initialState, action: any) => {
[roomId]: {
...room,
userList
}
}
}
};
}
@ -225,7 +225,7 @@ export const roomsReducer = (state = initialState, action: any) => {
const { rooms } = state;
const room = { ...rooms[roomId] };
const userList = room.userList.filter(user => user.name !== name);
const userList = room.userList.filter(user => user.name !== name);
return {
...state,
@ -234,7 +234,7 @@ export const roomsReducer = (state = initialState, action: any) => {
[roomId]: {
...room,
userList
}
}
}
};
}
@ -242,7 +242,7 @@ export const roomsReducer = (state = initialState, action: any) => {
const { field, order, roomId } = action;
const { rooms } = state;
const gameList = [ ...rooms[roomId].gameList ];
const gameList = [...rooms[roomId].gameList];
const sortGamesBy = {
field, order

View file

@ -1,5 +1,5 @@
import * as _ from "lodash";
import { RoomsState } from "./rooms.interfaces";
import * as _ from 'lodash';
import { RoomsState } from './rooms.interfaces';
interface State {
rooms: RoomsState
@ -8,7 +8,7 @@ interface State {
export const Selectors = {
getRooms: ({ rooms }: State) => rooms.rooms,
getRoom: ({ rooms }: State, id: number) =>
_.find(rooms.rooms, ({roomId}) => roomId === id),
_.find(rooms.rooms, ({ roomId }) => roomId === id),
getJoined: ({ rooms }: State) => rooms.joined,
getMessages: ({ rooms }: State) => rooms.messages,
getSortGamesBy: ({ rooms: { sortGamesBy } }: State) => sortGamesBy,

View file

@ -1,13 +1,13 @@
export const Types = {
CLEAR_STORE: "[Rooms] Clear Store",
UPDATE_ROOMS: "[Rooms] Update Rooms",
JOIN_ROOM: "[Rooms] Join Room",
LEAVE_ROOM: "[Rooms] Leave Room",
ADD_MESSAGE: "[Rooms] Add Message",
UPDATE_GAMES: "[Rooms] Update Games",
USER_JOINED: "[Rooms] User Joined",
USER_LEFT: "[Rooms] User Left",
SORT_GAMES: "[Rooms] Sort Games"
CLEAR_STORE: '[Rooms] Clear Store',
UPDATE_ROOMS: '[Rooms] Update Rooms',
JOIN_ROOM: '[Rooms] Join Room',
LEAVE_ROOM: '[Rooms] Leave Room',
ADD_MESSAGE: '[Rooms] Add Message',
UPDATE_GAMES: '[Rooms] Update Games',
USER_JOINED: '[Rooms] User Joined',
USER_LEFT: '[Rooms] User Left',
SORT_GAMES: '[Rooms] Sort Games'
};
export const MAX_ROOM_MESSAGES = 1000;