diff --git a/.eslintrc.js b/.eslintrc.js index d5511a26..1f55cfd5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,18 +4,18 @@ module.exports = { 'eslint:recommended', 'plugin:import/errors', 'plugin:import/warnings', - 'plugin:flowtype/recommended' + 'plugin:flowtype/recommended', ], plugins: ['react', 'flowtype'], env: { es6: true, 'shared-node-browser': true, - jest: true + jest: true, }, settings: { 'import/resolver': { - 'babel-module': {} - } + 'babel-module': {}, + }, }, globals: { global: true, @@ -23,11 +23,11 @@ module.exports = { page: true, browser: true, context: true, - jestPuppeteer: true + jestPuppeteer: true, }, rules: { 'no-console': 'off', - 'flowtype/generic-spacing': 'off' + 'flowtype/generic-spacing': 'off', }, overrides: [ { @@ -39,35 +39,35 @@ module.exports = { 'jest.visual.config.js', 'jest.framework-setup.js', 'web/next.config.js', - 'server/**/*.js' + 'server/**/*.js', ], env: { - node: true - } + node: true, + }, }, { files: ['**/*.test.js'], env: { - jest: true - } + jest: true, + }, }, { files: [ 'web/components/**/*.js', 'web/pages/**/*.js', - 'web/mocks/**/*.js' + 'web/mocks/**/*.js', ], rules: { 'react/jsx-uses-react': 'error', - 'react/jsx-uses-vars': 'error' - } + 'react/jsx-uses-vars': 'error', + }, }, { files: ['web/visualtest.js'], env: { browser: true, - node: true - } - } - ] + node: true, + }, + }, + ], }; diff --git a/.prettierignore b/.prettierignore index b9cceed8..f1139dfd 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ package.json flow-typed +web/cosmos-export diff --git a/.prettierrc b/.prettierrc index 544138be..289a1070 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,5 @@ { + "arrowParens": "avoid", + "endOfLine": "lf", "singleQuote": true } diff --git a/babel.config.js b/babel.config.js index e1bcb752..dd17086a 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,13 +1,13 @@ const path = require('path'); const alias = { - shared: path.join(__dirname, 'shared') + shared: path.join(__dirname, 'shared'), }; module.exports = { presets: [ ['next/babel', { 'preset-env': { modules: 'commonjs' } }], - '@babel/preset-flow' + '@babel/preset-flow', ], - plugins: [['module-resolver', { alias }]] + plugins: [['module-resolver', { alias }]], }; diff --git a/jest-puppeteer.config.js b/jest-puppeteer.config.js index 2bac8da0..9aeaa758 100644 --- a/jest-puppeteer.config.js +++ b/jest-puppeteer.config.js @@ -1,5 +1,5 @@ module.exports = { launch: { - args: ['--no-sandbox'] - } + args: ['--no-sandbox'], + }, }; diff --git a/jest.config.js b/jest.config.js index 14eaf455..8e7310cd 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,6 +2,6 @@ module.exports = { setupFilesAfterEnv: ['./jest.framework-setup.js'], setupFiles: ['/jest.setup.js'], moduleNameMapper: { - '\\.css$': 'identity-obj-proxy' - } + '\\.css$': 'identity-obj-proxy', + }, }; diff --git a/jest.visual.config.js b/jest.visual.config.js index aed2b3f3..67048d0c 100644 --- a/jest.visual.config.js +++ b/jest.visual.config.js @@ -1,5 +1,5 @@ module.exports = { preset: 'jest-puppeteer', setupFilesAfterEnv: ['./jest.framework-setup.js'], - testMatch: ['**/visualtest.js'] + testMatch: ['**/visualtest.js'], }; diff --git a/scripts/generate-game-media-queries.js b/scripts/generate-game-media-queries.js index 89324f4e..d79e18a7 100644 --- a/scripts/generate-game-media-queries.js +++ b/scripts/generate-game-media-queries.js @@ -37,7 +37,7 @@ function getLandscapeQuery({ height }) { const cond = getMediaQueryCond({ width: widthWithControls, - height + height, }); const body = getLandscapeRules({ width, height: gameHeight }); @@ -96,7 +96,7 @@ function getMediaQueryCond({ width, height }) { function getPortraitSize(i) { return { width: i * GAME_COLS, - height: i * (GAME_ROWS + CONTROL_BLOCKS) + height: i * (GAME_ROWS + CONTROL_BLOCKS), }; } diff --git a/server/api.js b/server/api.js index 8d8568e1..ddc66eed 100644 --- a/server/api.js +++ b/server/api.js @@ -9,14 +9,14 @@ import { activeGames, insertUser, insertSession, - insertGame + insertGame, } from './db'; import { rollbar } from './rollbar'; import { getStats, getDailyStats, incrementUserCount, - incrementGameCount + incrementGameCount, } from './firebase'; import type { User } from 'shared/types/state'; @@ -30,7 +30,7 @@ export function addRoutes(app: express$Application<>) { // NOTE: This is returned as an array instead of map in order to allow // sorting in the future games: activeGames.map(gameId => games[gameId]), - stats: await getStats() + stats: await getStats(), }); } catch (err) { res.sendStatus(500); @@ -42,7 +42,7 @@ export function addRoutes(app: express$Application<>) { async (req: express$Request, res: express$Response) => { try { res.json({ - days: await getDailyStats() + days: await getDailyStats(), }); } catch (err) { res.sendStatus(500); @@ -136,7 +136,7 @@ export function addRoutes(app: express$Application<>) { if (gameId && games[gameId]) { res.json({ game: games[gameId], - actions: gameActions[gameId] + actions: gameActions[gameId], }); } else { res.sendStatus(404); @@ -184,9 +184,9 @@ function extractBackfillRequest(req: mixed): BackfillRequest { return { userId, - from + from, }; - }) + }), }; } diff --git a/server/db.js b/server/db.js index cfe320c3..9971e418 100644 --- a/server/db.js +++ b/server/db.js @@ -6,7 +6,7 @@ import { getBlankGame } from 'shared/reducers/game'; import { MAX_NAME_LENGTH } from 'shared/constants/user'; import { GAME_INACTIVE_TIMEOUT, - GAME_EXPIRE_TIMEOUT + GAME_EXPIRE_TIMEOUT, } from 'shared/constants/timeouts'; import { createTimeoutBumper } from 'shared/utils/timeout-bumper'; @@ -31,11 +31,11 @@ export let activeGames: ActiveGames = []; export const { bumpTimeout } = createTimeoutBumper( { handler: handleInactiveGame, - timeout: GAME_INACTIVE_TIMEOUT + timeout: GAME_INACTIVE_TIMEOUT, }, { handler: handleExpiredGame, - timeout: GAME_EXPIRE_TIMEOUT + timeout: GAME_EXPIRE_TIMEOUT, } ); diff --git a/server/firebase.js b/server/firebase.js index 08d1f270..c74ebbab 100644 --- a/server/firebase.js +++ b/server/firebase.js @@ -14,7 +14,7 @@ export async function getStats(): Promise { actionRotate: 0, games: 0, lines: 0, - seconds: 0 + seconds: 0, }; } else { const ref = db.ref('counts'); @@ -110,7 +110,7 @@ function getDb() { if (!db) { admin.initializeApp({ credential: admin.credential.cert(cert), - databaseURL: 'https://flatris-forever.firebaseio.com' + databaseURL: 'https://flatris-forever.firebaseio.com', }); db = admin.database(); @@ -153,7 +153,7 @@ function prepareStats(rawStats) { games, lines, seconds, - turns + turns, } = rawStats; return { @@ -163,7 +163,7 @@ function prepareStats(rawStats) { actionRotate, games: games + turns, lines, - seconds + seconds, }; } diff --git a/server/rollbar.js b/server/rollbar.js index ae4976d5..45b8c567 100644 --- a/server/rollbar.js +++ b/server/rollbar.js @@ -9,6 +9,6 @@ export const rollbar = new Rollbar({ verbose: true, reportLevel: 'info', payload: { - environment: process.env.NODE_ENV - } + environment: process.env.NODE_ENV, + }, }); diff --git a/server/socket.js b/server/socket.js index 9e7b5b5f..9f606091 100644 --- a/server/socket.js +++ b/server/socket.js @@ -5,7 +5,7 @@ import { omit, difference } from 'lodash'; import { gameReducer, getPlayer } from 'shared/reducers/game'; import { ACTION_STATS_FLUSH_INTERVAL, - ACTION_STATS_FLUSH_DELAY + ACTION_STATS_FLUSH_DELAY, } from 'shared/constants/timeouts'; import { games, saveGameAction, bumpActiveGame } from './db'; import { @@ -16,7 +16,7 @@ import { incrementActionRight, incrementActionAcc, incrementActionRotate, - incrementGameTime + incrementGameTime, } from './firebase'; import { rollbar } from './rollbar'; @@ -123,7 +123,7 @@ export function attachSocket(server: net$Server) { } const gameSync: { - [id: string]: true + [id: string]: true, } = {}; let pendingLeftCount = 0; diff --git a/server/start-dev-server.js b/server/start-dev-server.js index 6fbbba96..47b1d49c 100644 --- a/server/start-dev-server.js +++ b/server/start-dev-server.js @@ -15,7 +15,7 @@ const server = http.createServer(app); attachSocket(server); // CORS -app.use(function(req: express$Request, res: express$Response, next) { +app.use(function (req: express$Request, res: express$Response, next) { res.header('Access-Control-Allow-Origin', 'http://localhost:3000'); res.header('Access-Control-Allow-Credentials', 'true'); res.header( diff --git a/shared/constants/tetromino.js b/shared/constants/tetromino.js index 222befcc..eb9b542c 100644 --- a/shared/constants/tetromino.js +++ b/shared/constants/tetromino.js @@ -5,15 +5,43 @@ export const COLORS = { J: '#3993d0', L: '#ed652f', S: '#95c43d', - Z: '#e84138' + Z: '#e84138', }; export const SHAPES = { - I: [[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]], - O: [[1, 1], [1, 1]], - T: [[0, 1, 0], [1, 1, 1], [0, 0, 0]], - J: [[1, 0, 0], [1, 1, 1], [0, 0, 0]], - L: [[0, 0, 1], [1, 1, 1], [0, 0, 0]], - S: [[0, 1, 1], [1, 1, 0], [0, 0, 0]], - Z: [[1, 1, 0], [0, 1, 1], [0, 0, 0]] + I: [ + [0, 0, 0, 0], + [1, 1, 1, 1], + [0, 0, 0, 0], + [0, 0, 0, 0], + ], + O: [ + [1, 1], + [1, 1], + ], + T: [ + [0, 1, 0], + [1, 1, 1], + [0, 0, 0], + ], + J: [ + [1, 0, 0], + [1, 1, 1], + [0, 0, 0], + ], + L: [ + [0, 0, 1], + [1, 1, 1], + [0, 0, 0], + ], + S: [ + [0, 1, 1], + [1, 1, 0], + [0, 0, 0], + ], + Z: [ + [1, 1, 0], + [0, 1, 1], + [0, 0, 0], + ], }; diff --git a/shared/reducers/game.js b/shared/reducers/game.js index f81d4126..30ba739d 100644 --- a/shared/reducers/game.js +++ b/shared/reducers/game.js @@ -6,12 +6,12 @@ import { WELL_COLS, DROP_FRAMES_DEFAULT, DROP_FRAMES_DECREMENT, - LINE_CLEAR_BONUSES + LINE_CLEAR_BONUSES, } from '../constants/grid'; import { SHAPES, COLORS } from '../constants/tetromino'; import { getNextTetromino, - getInitialPositionForTetromino + getInitialPositionForTetromino, } from '../utils/tetromino'; import { generateEmptyGrid, @@ -25,7 +25,7 @@ import { getBlocksFromGridRows, overrideBlockIds, appendBlocksToGrid, - getNextCellId + getNextCellId, } from '../utils/grid'; import type { @@ -36,7 +36,7 @@ import type { GameId, Game, FlashSuffix, - QuakeSuffix + QuakeSuffix, } from '../types/state'; import type { ActionId, GameAction } from '../types/actions'; @@ -64,7 +64,7 @@ export function gameReducer(state: void | Game, action: GameAction): Game { // Stop player1's game when player2 arrives status: 'PENDING', // Previous losses are irrelevant to 1vs1 game - losses: 0 + losses: 0, }); return bumpActionId(addUserToGame(game, user), userId, actionId); @@ -120,9 +120,9 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { ...game, players: players.map(player => ({ ...player, - ...getBlankPlayerRound({ gameId: id, round }) + ...getBlankPlayerRound({ gameId: id, round }), })), - dropFrames: DROP_FRAMES_DEFAULT + dropFrames: DROP_FRAMES_DEFAULT, }; } @@ -147,7 +147,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { activeTetrominoPosition, dropAcceleration, flashYay, - quake + quake, } = player; if (player.status === 'LOST') { @@ -172,13 +172,13 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { // Drop active Tetromino until it hits something let newPosition = { x: activeTetrominoPosition.x, - y: activeTetrominoPosition.y + rows + y: activeTetrominoPosition.y + rows, }; // New active Tetromino position is available, uneventful path if (isPositionAvailable(grid, activeTetrominoGrid, newPosition)) { return updatePlayer(state, userId, { - activeTetrominoPosition: newPosition + activeTetrominoPosition: newPosition, }); } @@ -210,9 +210,9 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { return { ...player, - ...newAttrs + ...newAttrs, }; - }) + }), }; } @@ -236,7 +236,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { // Clear acceleration after dropping Tetromino. Sometimes the key // events would misbehave and acceleration would remain on even after // releasing DOWN key - dropAcceleration: false + dropAcceleration: false, }); if (!hasLines(newGrid)) { @@ -251,7 +251,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { flashYay: altFlashClass(flashYay), quake: dropAcceleration ? altQuakeClass(quake, rowsCleared.length) - : null + : null, }); newState = rewardClearedBlocks(newState, userId); @@ -267,7 +267,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { grid, blocksPending, activeTetrominoGrid, - activeTetrominoPosition + activeTetrominoPosition, } = player; // XXX: The appended blocks might result in trimming existing blocks, by @@ -285,7 +285,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { ) { return updatePlayer(state, userId, { grid: newGrid, - blocksPending: [] + blocksPending: [], }); } @@ -304,7 +304,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { // if the game is over or not grid: newGrid, blocksPending: [], - activeTetrominoPosition: newPosition + activeTetrominoPosition: newPosition, }); } @@ -315,7 +315,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { const { grid, activeTetrominoGrid, activeTetrominoPosition } = player; const newPosition = { ...activeTetrominoPosition, - x: activeTetrominoPosition.x + direction + x: activeTetrominoPosition.x + direction, }; // Attempting to move the Tetromino outside the Well bounds or over landed @@ -325,7 +325,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { } return updatePlayer(state, userId, { - activeTetrominoPosition: newPosition + activeTetrominoPosition: newPosition, }); } @@ -350,7 +350,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { return updatePlayer(state, userId, { activeTetrominoGrid: newGrid, - activeTetrominoPosition: newPosition + activeTetrominoPosition: newPosition, }); } @@ -362,7 +362,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { } return updatePlayer(state, userId, { - dropAcceleration: true + dropAcceleration: true, }); } @@ -374,7 +374,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { } return updatePlayer(state, userId, { - dropAcceleration: false + dropAcceleration: false, }); } @@ -382,7 +382,7 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { const { time } = action.payload; return updatePlayer(state, userId, { - ping: time + ping: time, }); } @@ -394,16 +394,16 @@ export function gameJoinedReducer(state: Game, action: GameAction): Game { export function getBlankGame({ id, user, - dropFrames = DROP_FRAMES_DEFAULT + dropFrames = DROP_FRAMES_DEFAULT, }: { id: GameId, user: User, - dropFrames?: number + dropFrames?: number, }): Game { return { id, players: [getBlankPlayer(id, user)], - dropFrames + dropFrames, }; } @@ -413,18 +413,18 @@ export function getBlankPlayer(gameId: GameId, user: User): Player { lastActionId: 0, status: 'PENDING', losses: 0, - ...getBlankPlayerRound({ gameId }) + ...getBlankPlayerRound({ gameId }), }; } export function getBlankPlayerRound({ gameId, round = 0, - drops = 0 + drops = 0, }: { gameId: GameId, round?: number, - drops?: number + drops?: number, } = {}) { return { drops: 0, @@ -435,18 +435,18 @@ export function getBlankPlayerRound({ blocksPending: [], ...getNextPlayerTetromino({ gameId, round, drops }), dropAcceleration: false, - ...getBlankPlayerEffects() + ...getBlankPlayerEffects(), }; } export function getNextPlayerTetromino({ gameId, round = 0, - drops = 0 + drops = 0, }: { gameId: GameId, round?: number, - drops?: number + drops?: number, } = {}) { // Generate random Tetromino sequence per game round const roundId = (parseInt(gameId, 16) * (round + 1)).toString(16); @@ -459,7 +459,7 @@ export function getNextPlayerTetromino({ activeTetromino, WELL_COLS ), - nextTetromino: getNextTetromino(roundId, drops + 1) + nextTetromino: getNextTetromino(roundId, drops + 1), }; } @@ -469,8 +469,8 @@ export function stripGameEffects(game: Game): Game { players: game.players.map(player => ({ ...player, // Strip effects to avoid running them on page load - ...getBlankPlayerEffects() - })) + ...getBlankPlayerEffects(), + })), }; } @@ -523,7 +523,7 @@ export function addUserToGame(game: Game, user: User): Game { return { ...game, - players: [...players, getBlankPlayer(id, user)] + players: [...players, getBlankPlayer(id, user)], }; } @@ -541,8 +541,8 @@ export function updatePlayer( players: [ ...players.slice(0, playerIndex), { ...player, ...attrs }, - ...players.slice(playerIndex + 1) - ] + ...players.slice(playerIndex + 1), + ], }; } @@ -585,12 +585,12 @@ function rewardClearedBlocks(game: Game, userId: UserId): Game { return { ...updatePlayer(game, userId, { score: score + points, - lines: lines + blocksCleared.length + lines: lines + blocksCleared.length, }), // Increase speed whenever a line is cleared (fast game) dropFrames: blocksCleared.length ? dropFrames - DROP_FRAMES_DECREMENT - : dropFrames + : dropFrames, }; } @@ -618,7 +618,7 @@ function sendClearedBlocksToEnemy( return updatePlayer(game, enemy.user.id, { blocksPending: [...enemy.blocksPending, ...blocksPending], - flashNay: altFlashClass(flashNay) + flashNay: altFlashClass(flashNay), }); } @@ -646,7 +646,7 @@ function getBlankPlayerEffects() { flashYay: null, flashNay: null, quake: null, - ping: null + ping: null, }; } diff --git a/shared/types/actions.js b/shared/types/actions.js index f2430a8d..86d81fb7 100644 --- a/shared/types/actions.js +++ b/shared/types/actions.js @@ -7,158 +7,158 @@ import type { Game, BackfillId, Stats, - State + State, } from './state'; export type ActionId = number; export type JsLoadAction = { - type: 'JS_LOAD' + type: 'JS_LOAD', }; export type AuthAction = { type: 'AUTH', payload: { - user: User - } + user: User, + }, }; export type UnauthAction = { - type: 'UNAUTH' + type: 'UNAUTH', }; export type DashboardLoadAction = { type: 'LOAD_DASHBOARD', payload: { games: Array, - stats: Stats - } + stats: Stats, + }, }; export type AddGameAction = { type: 'ADD_GAME', payload: { - game: Game - } + game: Game, + }, }; export type RemoveGameAction = { type: 'REMOVE_GAME', payload: { - gameId: GameId - } + gameId: GameId, + }, }; export type OpenGameAction = { type: 'OPEN_GAME', payload: { - gameId: GameId - } + gameId: GameId, + }, }; export type CloseGameAction = { - type: 'CLOSE_GAME' + type: 'CLOSE_GAME', }; export type StripGameEffectsAction = { - type: 'STRIP_GAME_EFFECTS' + type: 'STRIP_GAME_EFFECTS', }; export type StartBackfillAction = { type: 'START_BACKFILL', payload: { gameId: GameId, - backfillId: BackfillId - } + backfillId: BackfillId, + }, }; export type EndBackfillAction = { type: 'END_BACKFILL', payload: { - backfillId: BackfillId - } + backfillId: BackfillId, + }, }; export type QueueGameAction = { type: 'QUEUE_GAME_ACTION', payload: { - action: GameAction - } + action: GameAction, + }, }; export type UpdateStatsAction = { type: 'UPDATE_STATS', payload: { - stats: Stats - } + stats: Stats, + }, }; type GameActionPayload = { actionId: ActionId, prevActionId: ActionId, gameId: GameId, - userId: UserId + userId: UserId, }; export type JoinGameAction = { type: 'JOIN_GAME', payload: GameActionPayload & { - user: User - } + user: User, + }, }; export type PlayerReadyAction = { type: 'PLAYER_READY', - payload: GameActionPayload + payload: GameActionPayload, }; export type PlayerPauseAction = { type: 'PLAYER_PAUSE', - payload: GameActionPayload + payload: GameActionPayload, }; export type MoveLeftAction = { type: 'MOVE_LEFT', - payload: GameActionPayload + payload: GameActionPayload, }; export type MoveRightAction = { type: 'MOVE_RIGHT', - payload: GameActionPayload + payload: GameActionPayload, }; export type RotateAction = { type: 'ROTATE', - payload: GameActionPayload + payload: GameActionPayload, }; export type DropAction = { type: 'DROP', payload: GameActionPayload & { - rows: number - } + rows: number, + }, }; export type EnableAccelerationAction = { type: 'ENABLE_ACCELERATION', - payload: GameActionPayload + payload: GameActionPayload, }; export type DisableAccelerationAction = { type: 'DISABLE_ACCELERATION', - payload: GameActionPayload + payload: GameActionPayload, }; export type AppendPendingBlocksAction = { type: 'APPEND_PENDING_BLOCKS', - payload: GameActionPayload + payload: GameActionPayload, }; export type PingAction = { type: 'PING', payload: GameActionPayload & { - time: number - } + time: number, + }, }; export type GameAction = diff --git a/shared/types/api.js b/shared/types/api.js index 4f2b92f9..1c4d6e75 100644 --- a/shared/types/api.js +++ b/shared/types/api.js @@ -9,11 +9,11 @@ export type BackfillRequest = { gameId: GameId, players: Array<{ userId: UserId, - from: number - }> + from: number, + }>, }; export type BackfillResponse = { gameId: GameId, - actions: Array + actions: Array, }; diff --git a/shared/types/error.js b/shared/types/error.js index 2c44a242..7a24879b 100644 --- a/shared/types/error.js +++ b/shared/types/error.js @@ -2,5 +2,5 @@ export type ComponentError = { message: string, - stack: string + stack: string, }; diff --git a/shared/types/state.js b/shared/types/state.js index c1de80cc..6854d7ad 100644 --- a/shared/types/state.js +++ b/shared/types/state.js @@ -20,7 +20,7 @@ export type UserId = string; export type User = { id: UserId, - name: string + name: string, }; export type PlayerStatus = 'PENDING' | 'READY' | 'PAUSE' | 'WON' | 'LOST'; @@ -50,7 +50,7 @@ export type Player = { flashYay: ?FlashSuffix, flashNay: ?FlashSuffix, quake: ?QuakeSuffix, - ping: ?number + ping: ?number, }; export type GameId = string; @@ -58,22 +58,22 @@ export type GameId = string; export type Game = { id: GameId, players: Array, - dropFrames: number + dropFrames: number, }; export type Games = { - [id: GameId]: Game + [id: GameId]: Game, }; export type BackfillId = number; export type Backfill = { backfillId: BackfillId, - queuedActions: Array + queuedActions: Array, }; export type Backfills = { - [gameId: GameId]: Backfill + [gameId: GameId]: Backfill, }; export type Stats = { @@ -83,11 +83,11 @@ export type Stats = { actionRotate: number, games: number, lines: number, - seconds: number + seconds: number, }; export type DailyStats = { - [day: string]: number + [day: string]: number, }; export type State = { @@ -96,5 +96,5 @@ export type State = { games: Games, curGame: ?GameId, backfills: Backfills, - stats: Stats + stats: Stats, }; diff --git a/shared/utils/grid.js b/shared/utils/grid.js index 08538101..50ed8f56 100644 --- a/shared/utils/grid.js +++ b/shared/utils/grid.js @@ -5,7 +5,7 @@ import type { WellGrid, TetrominoGrid, Position2d, - Player + Player, } from '../types/state'; export function generateEmptyGrid(rows: number, cols: number): WellGrid { @@ -41,7 +41,7 @@ export function getExactPosition({ x, y }: Position2d) { // with each frame return { x: Math.floor(x), - y: Math.floor(y) + y: Math.floor(y), }; } @@ -150,7 +150,7 @@ export function clearLines( grid: WellGrid ): { clearedGrid: WellGrid, - rowsCleared: Array + rowsCleared: Array, } { /** * Clear all rows that form a complete line, from one left to right, inside @@ -182,7 +182,7 @@ export function clearLines( return { clearedGrid, - rowsCleared + rowsCleared, }; } @@ -216,7 +216,7 @@ export function fitTetrominoPositionInWellBounds( return { x: newX, - y + y, }; } diff --git a/shared/utils/tetromino.js b/shared/utils/tetromino.js index 4c2e035a..b56ad749 100644 --- a/shared/utils/tetromino.js +++ b/shared/utils/tetromino.js @@ -27,6 +27,6 @@ export function getInitialPositionForTetromino( return { x: Math.round(gridCols / 2) - Math.round(grid[0].length / 2), - y: -2 + y: -2, }; } diff --git a/shared/utils/timeout-bumper.js b/shared/utils/timeout-bumper.js index 3b908134..ffd84536 100644 --- a/shared/utils/timeout-bumper.js +++ b/shared/utils/timeout-bumper.js @@ -2,7 +2,7 @@ type TimeoutConfig = { handler: (id: string) => mixed, - timeout: number + timeout: number, }; export function createTimeoutBumper(...configs: Array) { @@ -50,6 +50,6 @@ export function createTimeoutBumper(...configs: Array) { return { bumpTimeout, - cancelAllTimeouts + cancelAllTimeouts, }; } diff --git a/shared/utils/timeout-bumper.test.js b/shared/utils/timeout-bumper.test.js index e12a811e..0c5232f0 100644 --- a/shared/utils/timeout-bumper.test.js +++ b/shared/utils/timeout-bumper.test.js @@ -20,15 +20,15 @@ test('handlers are called sequentially', () => { const { bumpTimeout } = createTimeoutBumper( { handler: handler1, - timeout: TIMEOUT1 + timeout: TIMEOUT1, }, { handler: handler2, - timeout: TIMEOUT2 + timeout: TIMEOUT2, }, { handler: handler3, - timeout: TIMEOUT3 + timeout: TIMEOUT3, } ); @@ -71,15 +71,15 @@ test('handlers are not called while bumping', () => { const { bumpTimeout } = createTimeoutBumper( { handler: handler1, - timeout: TIMEOUT1 + timeout: TIMEOUT1, }, { handler: handler2, - timeout: TIMEOUT2 + timeout: TIMEOUT2, }, { handler: handler3, - timeout: TIMEOUT3 + timeout: TIMEOUT3, } ); @@ -130,15 +130,15 @@ test('handlers are canceled', () => { const { bumpTimeout, cancelAllTimeouts } = createTimeoutBumper( { handler: handler1, - timeout: TIMEOUT1 + timeout: TIMEOUT1, }, { handler: handler2, - timeout: TIMEOUT2 + timeout: TIMEOUT2, }, { handler: handler3, - timeout: TIMEOUT3 + timeout: TIMEOUT3, } ); diff --git a/web/actions/game.js b/web/actions/game.js index 92bd9435..df8ec7b1 100644 --- a/web/actions/game.js +++ b/web/actions/game.js @@ -11,7 +11,7 @@ import type { Action, ThunkAction, Dispatch, - GetState + GetState, } from 'shared/types/actions'; export function joinGame(gameId: GameId, user: User): JoinGameAction { @@ -22,8 +22,8 @@ export function joinGame(gameId: GameId, user: User): JoinGameAction { prevActionId: 0, userId: user.id, gameId, - user - } + user, + }, }; } @@ -34,8 +34,8 @@ export function playerReady(): ThunkAction { actionId, prevActionId, userId, - gameId - } + gameId, + }, })); } @@ -46,8 +46,8 @@ export function playerPause(): ThunkAction { actionId, prevActionId, userId, - gameId - } + gameId, + }, })); } @@ -59,8 +59,8 @@ export function drop(rows: number): ThunkAction { prevActionId, userId, gameId, - rows - } + rows, + }, })); } @@ -71,8 +71,8 @@ export function moveLeft(): ThunkAction { actionId, prevActionId, userId, - gameId - } + gameId, + }, })); } @@ -83,8 +83,8 @@ export function moveRight(): ThunkAction { actionId, prevActionId, userId, - gameId - } + gameId, + }, })); } @@ -95,8 +95,8 @@ export function rotate(): ThunkAction { actionId, prevActionId, userId, - gameId - } + gameId, + }, })); } @@ -107,8 +107,8 @@ export function enableAcceleration(): ThunkAction { actionId, prevActionId, userId, - gameId - } + gameId, + }, })); } @@ -119,8 +119,8 @@ export function disableAcceleration(): ThunkAction { actionId, prevActionId, userId, - gameId - } + gameId, + }, })); } @@ -131,8 +131,8 @@ export function appendPendingBlocks(): ThunkAction { actionId, prevActionId, userId, - gameId - } + gameId, + }, })); } @@ -144,8 +144,8 @@ export function ping(): ThunkAction { prevActionId, userId, gameId, - time: Date.now() - } + time: Date.now(), + }, })); } @@ -153,7 +153,7 @@ type GameActionDecorator = ({ actionId: ActionId, prevActionId: ActionId, gameId: GameId, - userId: UserId + userId: UserId, }) => Action; function decorateGameAction(fn: GameActionDecorator): ThunkAction { diff --git a/web/actions/global.js b/web/actions/global.js index e151b0d4..6be94d89 100644 --- a/web/actions/global.js +++ b/web/actions/global.js @@ -14,35 +14,35 @@ import type { EndBackfillAction, QueueGameAction, UpdateStatsAction, - GameAction + GameAction, } from 'shared/types/actions'; export function auth(user: User): AuthAction { return { type: 'AUTH', - payload: { user } + payload: { user }, }; } export function unauth(): UnauthAction { return { - type: 'UNAUTH' + type: 'UNAUTH', }; } export function loadDashboard({ games, - stats + stats, }: { games: Array, - stats: Stats + stats: Stats, }): DashboardLoadAction { return { type: 'LOAD_DASHBOARD', payload: { games, - stats - } + stats, + }, }; } @@ -50,8 +50,8 @@ export function addGame(game: Game): AddGameAction { return { type: 'ADD_GAME', payload: { - game - } + game, + }, }; } @@ -59,8 +59,8 @@ export function removeGame(gameId: GameId): RemoveGameAction { return { type: 'REMOVE_GAME', payload: { - gameId - } + gameId, + }, }; } @@ -68,20 +68,20 @@ export function openGame(gameId: GameId): OpenGameAction { return { type: 'OPEN_GAME', payload: { - gameId - } + gameId, + }, }; } export function closeGame(): CloseGameAction { return { - type: 'CLOSE_GAME' + type: 'CLOSE_GAME', }; } export function stripGameEffects(): StripGameEffectsAction { return { - type: 'STRIP_GAME_EFFECTS' + type: 'STRIP_GAME_EFFECTS', }; } @@ -93,8 +93,8 @@ export function startBackfill( type: 'START_BACKFILL', payload: { gameId, - backfillId - } + backfillId, + }, }; } @@ -102,21 +102,21 @@ export function endBackfill(backfillId: BackfillId): EndBackfillAction { return { type: 'END_BACKFILL', payload: { - backfillId - } + backfillId, + }, }; } export function queueGameAction(action: GameAction): QueueGameAction { return { type: 'QUEUE_GAME_ACTION', - payload: { action } + payload: { action }, }; } export function updateStats(stats: Stats): UpdateStatsAction { return { type: 'UPDATE_STATS', - payload: { stats } + payload: { stats }, }; } diff --git a/web/components/CurGameOfElse.js b/web/components/CurGameOfElse.js index 8e6d96cd..ee022a73 100644 --- a/web/components/CurGameOfElse.js +++ b/web/components/CurGameOfElse.js @@ -10,11 +10,11 @@ type Props = { children: Node, games: Games, curGame: ?GameId, - else: () => mixed + else: () => mixed, }; type LocalState = { - elseTriggered: boolean + elseTriggered: boolean, }; // The purpose of this component is to ensure the child component is only @@ -26,7 +26,7 @@ type LocalState = { // however, we can safely redirect to / when this happens. class CurGameOfElse extends Component { state = { - elseTriggered: false + elseTriggered: false, }; componentDidMount() { @@ -54,7 +54,7 @@ function hasCurGame({ games, curGame }: Props) { const mapStateToProps = ({ games, curGame }: State): $Shape => ({ games, - curGame + curGame, }); export default connect(mapStateToProps)(CurGameOfElse); diff --git a/web/components/FlatrisGame/FlatrisGame.fixture.js b/web/components/FlatrisGame/FlatrisGame.fixture.js index bb29bcaf..e91c92d8 100644 --- a/web/components/FlatrisGame/FlatrisGame.fixture.js +++ b/web/components/FlatrisGame/FlatrisGame.fixture.js @@ -14,9 +14,9 @@ const state = { jsReady: true, curUser: user, games: { - [game.id]: game + [game.id]: game, }, - curGame: game.id + curGame: game.id, }; export default ( diff --git a/web/components/FlatrisGame/FlatrisGame.js b/web/components/FlatrisGame/FlatrisGame.js index 915126e6..ed42fe42 100644 --- a/web/components/FlatrisGame/FlatrisGame.js +++ b/web/components/FlatrisGame/FlatrisGame.js @@ -10,7 +10,7 @@ import { getCurPlayer, getOtherPlayer, getPlayer, - isPlayer + isPlayer, } from 'shared/reducers/game'; import { appendPendingBlocks, @@ -23,7 +23,7 @@ import { ping, playerPause, playerReady, - rotate + rotate, } from '../../actions/game'; import { cancelGameFrame, runGameFrame } from '../../actions/game-frame'; import { DOWN, KEY_DELAY, LEFT, RIGHT, SPACE, UP } from '../../constants/keys'; @@ -67,19 +67,19 @@ type Props = { enableAcceleration: typeof enableAcceleration, disableAcceleration: typeof disableAcceleration, appendPendingBlocks: typeof appendPendingBlocks, - ping: typeof ping + ping: typeof ping, }; type LocalState = { isWatching: boolean, - isMobile: boolean + isMobile: boolean, }; // NOTE: This component will crash if state.curGame isn't populated! class FlatrisGame extends Component { state = { isWatching: false, - isMobile: false + isMobile: false, }; keepAliveTimeout: ?TimeoutID; @@ -97,7 +97,7 @@ class FlatrisGame extends Component { if (isMobileDevice()) { this.setState({ - isMobile: true + isMobile: true, }); } @@ -190,13 +190,13 @@ class FlatrisGame extends Component { handleWatch = () => { this.setState({ - isWatching: true + isWatching: true, }); }; handleMenu = () => { this.setState({ - isWatching: false + isWatching: false, }); }; @@ -464,12 +464,12 @@ const mapStateToProps = (state: State): $Shape => { jsReady: jsReady, curUser: curUser, game: getCurGame(state), - backfills + backfills, }; }; const mapDispatchToProps = { - runGameFrame + runGameFrame, }; const syncActions = { @@ -483,7 +483,7 @@ const syncActions = { enableAcceleration, disableAcceleration, appendPendingBlocks, - ping + ping, }; export default connect( diff --git a/web/components/FlatrisGame/controls/Drop.js b/web/components/FlatrisGame/controls/Drop.js index 3bc70160..62aec16b 100644 --- a/web/components/FlatrisGame/controls/Drop.js +++ b/web/components/FlatrisGame/controls/Drop.js @@ -4,7 +4,7 @@ import React from 'react'; import PointerButton from './PointerButton'; type Props = { - onPress: Function + onPress: Function, }; export default function Drop({ onPress, ...rest }: Props) { diff --git a/web/components/FlatrisGame/controls/LandscapeControls.js b/web/components/FlatrisGame/controls/LandscapeControls.js index 6cb95667..6157b37b 100644 --- a/web/components/FlatrisGame/controls/LandscapeControls.js +++ b/web/components/FlatrisGame/controls/LandscapeControls.js @@ -7,7 +7,7 @@ import { moveRight, rotate, enableAcceleration, - disableAcceleration + disableAcceleration, } from '../../../actions/game'; import { withSocket } from '../../socket/SocketConnect'; import { isPlayer, allPlayersReady } from 'shared/reducers/game'; @@ -28,7 +28,7 @@ type Props = { moveRight: typeof moveRight, rotate: typeof rotate, enableAcceleration: typeof enableAcceleration, - disableAcceleration: typeof disableAcceleration + disableAcceleration: typeof disableAcceleration, }; class LandscapeControls extends Component { @@ -115,7 +115,7 @@ const mapStateToProps = (state: State): $Shape => { return { curUser, game: getCurGame(state), - backfills + backfills, }; }; @@ -124,7 +124,7 @@ const syncActions = { moveRight, rotate, enableAcceleration, - disableAcceleration + disableAcceleration, }; export default connect(mapStateToProps)( diff --git a/web/components/FlatrisGame/controls/Left.js b/web/components/FlatrisGame/controls/Left.js index 35631c87..9984c496 100644 --- a/web/components/FlatrisGame/controls/Left.js +++ b/web/components/FlatrisGame/controls/Left.js @@ -4,7 +4,7 @@ import React from 'react'; import PointerButton from './PointerButton'; type Props = { - onPress: Function + onPress: Function, }; export default function Left({ onPress, ...rest }: Props) { diff --git a/web/components/FlatrisGame/controls/PointerButton.js b/web/components/FlatrisGame/controls/PointerButton.js index 93348b21..b64382d9 100644 --- a/web/components/FlatrisGame/controls/PointerButton.js +++ b/web/components/FlatrisGame/controls/PointerButton.js @@ -11,7 +11,7 @@ type Props = { children: Node, disabled?: boolean, onPress: Function, - onRelease?: Function + onRelease?: Function, }; export default function PointerButton({ diff --git a/web/components/FlatrisGame/controls/PortraitControls.js b/web/components/FlatrisGame/controls/PortraitControls.js index 1d2b7bac..bfda5461 100644 --- a/web/components/FlatrisGame/controls/PortraitControls.js +++ b/web/components/FlatrisGame/controls/PortraitControls.js @@ -7,7 +7,7 @@ import { moveRight, rotate, enableAcceleration, - disableAcceleration + disableAcceleration, } from '../../../actions/game'; import { withSocket } from '../../socket/SocketConnect'; import { isPlayer, allPlayersReady } from 'shared/reducers/game'; @@ -28,7 +28,7 @@ type Props = { moveRight: typeof moveRight, rotate: typeof rotate, enableAcceleration: typeof enableAcceleration, - disableAcceleration: typeof disableAcceleration + disableAcceleration: typeof disableAcceleration, }; class PortraitControls extends Component { @@ -118,7 +118,7 @@ const mapStateToProps = (state: State): $Shape => { return { curUser, game: getCurGame(state), - backfills + backfills, }; }; @@ -127,7 +127,7 @@ const syncActions = { moveRight, rotate, enableAcceleration, - disableAcceleration + disableAcceleration, }; export default connect(mapStateToProps)( diff --git a/web/components/FlatrisGame/controls/Right.js b/web/components/FlatrisGame/controls/Right.js index b9c45bbf..e8cbd1af 100644 --- a/web/components/FlatrisGame/controls/Right.js +++ b/web/components/FlatrisGame/controls/Right.js @@ -4,7 +4,7 @@ import React from 'react'; import PointerButton from './PointerButton'; type Props = { - onPress: Function + onPress: Function, }; export default function Right({ onPress, ...rest }: Props) { diff --git a/web/components/FlatrisGame/controls/Rotate.js b/web/components/FlatrisGame/controls/Rotate.js index 91d95572..c11bda0f 100644 --- a/web/components/FlatrisGame/controls/Rotate.js +++ b/web/components/FlatrisGame/controls/Rotate.js @@ -4,7 +4,7 @@ import React from 'react'; import PointerButton from './PointerButton'; type Props = { - onPress: Function + onPress: Function, }; export default function Rotate({ onPress, ...rest }: Props) { diff --git a/web/components/FlatrisGame/controls/index.fixture.js b/web/components/FlatrisGame/controls/index.fixture.js index d9e6c513..c94c9e21 100644 --- a/web/components/FlatrisGame/controls/index.fixture.js +++ b/web/components/FlatrisGame/controls/index.fixture.js @@ -10,5 +10,5 @@ export default { left: console.log('onPres')} />, right: console.log('onPres')} />, rotate: console.log('onPres')} />, - drop: console.log('onPres')} /> + drop: console.log('onPres')} />, }; diff --git a/web/components/GameContainer.js b/web/components/GameContainer.js index 7377388a..395af48f 100644 --- a/web/components/GameContainer.js +++ b/web/components/GameContainer.js @@ -6,7 +6,7 @@ import type { Node } from 'react'; type Props = { children: Node, - outer?: Node + outer?: Node, }; const GameContainer = ({ children, outer }: Props) => { diff --git a/web/components/Layout.js b/web/components/Layout.js index c82c4832..2a34e7aa 100644 --- a/web/components/Layout.js +++ b/web/components/Layout.js @@ -15,16 +15,16 @@ import type { ComponentError } from 'shared/types/error'; type Props = { jsReady: boolean, children: Node, - jsLoad: () => Action + jsLoad: () => Action, }; type LocalState = { - error: ?ComponentError + error: ?ComponentError, }; class Layout extends Component { state = { - error: null + error: null, }; componentDidMount() { @@ -41,8 +41,8 @@ class Layout extends Component { this.setState({ error: { message: error.toString(), - stack: componentStack - } + stack: componentStack, + }, }); } @@ -51,7 +51,7 @@ class Layout extends Component { const { error } = this.state; const layoutClasses = classNames('layout', { - 'layout-static': !jsReady + 'layout-static': !jsReady, }); return ( @@ -150,11 +150,8 @@ function mapStateToProps({ jsReady }: State): $Shape { function mapDispatchToProps(dispatch: Dispatch): $Shape { return { - jsLoad: () => dispatch({ type: 'JS_LOAD' }) + jsLoad: () => dispatch({ type: 'JS_LOAD' }), }; } -export default connect( - mapStateToProps, - mapDispatchToProps -)(Layout); +export default connect(mapStateToProps, mapDispatchToProps)(Layout); diff --git a/web/components/Loading/index.js b/web/components/Loading/index.js index 4affe894..1958d431 100644 --- a/web/components/Loading/index.js +++ b/web/components/Loading/index.js @@ -3,13 +3,41 @@ import React, { Component } from 'react'; const SHAPES = { - I: [[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]], - O: [[1, 1], [1, 1]], - T: [[0, 1, 0], [1, 1, 1], [0, 0, 0]], - J: [[1, 0, 0], [1, 1, 1], [0, 0, 0]], - L: [[0, 0, 1], [1, 1, 1], [0, 0, 0]], - S: [[0, 1, 1], [1, 1, 0], [0, 0, 0]], - Z: [[1, 1, 0], [0, 1, 1], [0, 0, 0]] + I: [ + [0, 0, 0, 0], + [1, 1, 1, 1], + [0, 0, 0, 0], + [0, 0, 0, 0], + ], + O: [ + [1, 1], + [1, 1], + ], + T: [ + [0, 1, 0], + [1, 1, 1], + [0, 0, 0], + ], + J: [ + [1, 0, 0], + [1, 1, 1], + [0, 0, 0], + ], + L: [ + [0, 0, 1], + [1, 1, 1], + [0, 0, 0], + ], + S: [ + [0, 1, 1], + [1, 1, 0], + [0, 0, 0], + ], + Z: [ + [1, 1, 0], + [0, 1, 1], + [0, 0, 0], + ], }; const { round, random } = Math; @@ -19,12 +47,12 @@ const range = [...Array(4).keys()]; type Shape = $Keys; type State = { - currShape: Shape + currShape: Shape, }; export default class Loading extends Component<{}, State> { state = { - currShape: 'S' + currShape: 'S', }; timeoutId: ?TimeoutID; @@ -45,7 +73,7 @@ export default class Loading extends Component<{}, State> { const currShape = otherShapes[round(random() * (otherShapes.length - 1))]; this.setState({ - currShape + currShape, }); this.scheduleShapeChange(); diff --git a/web/components/Title.js b/web/components/Title.js index bac490f2..b30d40cf 100644 --- a/web/components/Title.js +++ b/web/components/Title.js @@ -4,7 +4,7 @@ import React, { Component } from 'react'; import Head from 'next/head'; type Props = { - children: string + children: string, }; export default class Title extends Component { diff --git a/web/components/pages/Dashboard/Dashboard.js b/web/components/pages/Dashboard/Dashboard.js index 60d9e824..5804e205 100644 --- a/web/components/pages/Dashboard/Dashboard.js +++ b/web/components/pages/Dashboard/Dashboard.js @@ -24,7 +24,7 @@ import type { Games, State, Stats as StatsType, - User + User, } from 'shared/types/state'; const TRANSITION_TIMEOUT = 550; // CSS transition takes 500ms (added 50ms buffer) @@ -38,12 +38,12 @@ type Props = { onGameKeepAlive: (handler: (gameId: GameId) => void) => mixed, offGameKeepAlive: (handler: (gameId: GameId) => void) => mixed, closeGame: () => mixed, - removeGame: (gameId: GameId) => mixed + removeGame: (gameId: GameId) => mixed, }; type LocalState = { gamesCopy: Games, - added: Array + added: Array, }; class Dashboard extends Component { @@ -57,14 +57,14 @@ class Dashboard extends Component { this.state = { gamesCopy: props.games, - added: [] + added: [], }; // We're tracking game activity here because this is also the (only) // component that subscribes to `global` (all game rooms) const { bumpTimeout, cancelAllTimeouts } = createTimeoutBumper({ handler: this.handleInactiveGame, - timeout: GAME_INACTIVE_TIMEOUT + timeout: GAME_INACTIVE_TIMEOUT, }); this.bumpInactiveTimeout = bumpTimeout; @@ -77,7 +77,7 @@ class Dashboard extends Component { curGame, subscribe, onGameKeepAlive, - closeGame + closeGame, } = this.props; subscribe('global'); @@ -106,7 +106,7 @@ class Dashboard extends Component { const newState = { // Keep current games as well as just-removed games in state gamesCopy: { ...gamesCopy, ...games }, - added: [...added, ...justAdded] + added: [...added, ...justAdded], }; this.setState(newState, () => { @@ -138,13 +138,13 @@ class Dashboard extends Component { scheduleClearAdded = this.createTransClearScheduler((gameId: GameId) => { this.setState({ - added: without(this.state.added, gameId) + added: without(this.state.added, gameId), }); }); scheduleClearRemoved = this.createTransClearScheduler((gameId: GameId) => { this.setState({ - gamesCopy: omit(this.state.gamesCopy, gameId) + gamesCopy: omit(this.state.gamesCopy, gameId), }); }); @@ -347,7 +347,7 @@ class Dashboard extends Component { const { id } = game; const classes = classNames('game-preview', { 'game-added': added.indexOf(id) !== -1, - 'game-removed': !this.props.games[id] + 'game-removed': !this.props.games[id], }); return ( @@ -415,13 +415,13 @@ function mapStateToProps({ curUser, games, curGame, - stats + stats, }: State): $Shape { return { curUser, games, curGame, - stats + stats, }; } diff --git a/web/components/pages/Dashboard/Logo/index.fixture.js b/web/components/pages/Dashboard/Logo/index.fixture.js index f9421081..d15f59de 100644 --- a/web/components/pages/Dashboard/Logo/index.fixture.js +++ b/web/components/pages/Dashboard/Logo/index.fixture.js @@ -14,5 +14,5 @@ export default { - ) + ), }; diff --git a/web/components/pages/Dashboard/Logo/index.js b/web/components/pages/Dashboard/Logo/index.js index 74becf63..1f69979b 100644 --- a/web/components/pages/Dashboard/Logo/index.js +++ b/web/components/pages/Dashboard/Logo/index.js @@ -5,7 +5,7 @@ import { SHAPES } from 'shared/constants/tetromino'; import Tetromino from '../../../shared/Tetromino'; type Props = { - color?: string + color?: string, }; export default function Logo({ color = '#34495f' }: Props) { diff --git a/web/components/pages/Dashboard/Stats/index.fixture.js b/web/components/pages/Dashboard/Stats/index.fixture.js index 681357dc..86c06fe3 100644 --- a/web/components/pages/Dashboard/Stats/index.fixture.js +++ b/web/components/pages/Dashboard/Stats/index.fixture.js @@ -11,7 +11,7 @@ const statsDiff = { actionRotate: [123, Date.now() + 1004], games: [3, Date.now() + 1005], lines: [51, Date.now() + 1006], - seconds: [35, Date.now() + 1007] + seconds: [35, Date.now() + 1007], }; export default { @@ -24,7 +24,7 @@ export default { actionRotate: 79418, games: 1906, lines: 14599, - seconds: 150275 + seconds: 150275, }} /> ), @@ -39,9 +39,9 @@ export default { actionRotate: 79418, games: 1906, lines: 14599, - seconds: 150275 + seconds: 150275, }} /> - ) + ), }; diff --git a/web/components/pages/Dashboard/Stats/index.js b/web/components/pages/Dashboard/Stats/index.js index 46a86682..46384605 100644 --- a/web/components/pages/Dashboard/Stats/index.js +++ b/web/components/pages/Dashboard/Stats/index.js @@ -5,18 +5,18 @@ import React, { Component } from 'react'; import type { Stats as StatsType } from 'shared/types/state'; type Props = { - stats: StatsType + stats: StatsType, }; type LocalState = { statsDiff: { - [stat: $Keys]: [number, number] // [diff, updatedAt] - } + [stat: $Keys]: [number, number], // [diff, updatedAt] + }, }; class Stats extends Component { state = { - statsDiff: {} + statsDiff: {}, }; componentDidUpdate({ stats: prevStats }: Props) { @@ -31,13 +31,13 @@ class Stats extends Component { if (diff > 0) { statsDiff = { ...statsDiff, - [stat]: [diff, Date.now()] + [stat]: [diff, Date.now()], }; } }); this.setState({ - statsDiff + statsDiff, }); } } diff --git a/web/components/pages/Dashboard/__fixtures__/own-game.js b/web/components/pages/Dashboard/__fixtures__/own-game.js index 9647ce55..c4bb80e9 100644 --- a/web/components/pages/Dashboard/__fixtures__/own-game.js +++ b/web/components/pages/Dashboard/__fixtures__/own-game.js @@ -15,7 +15,7 @@ export default ( initialState={{ jsReady: true, curUser: user, - games: { [game.id]: game } + games: { [game.id]: game }, }} > diff --git a/web/components/pages/Error/__fixtures__/component-error.js b/web/components/pages/Error/__fixtures__/component-error.js index 54f47bff..975fa9c7 100644 --- a/web/components/pages/Error/__fixtures__/component-error.js +++ b/web/components/pages/Error/__fixtures__/component-error.js @@ -21,7 +21,7 @@ export default ( in WrappedCmp (created by Container) in AppContainer (created by Container) in Container (created by App) - in App` + in App`, }} /> ); diff --git a/web/components/pages/Error/index.js b/web/components/pages/Error/index.js index 6a6da838..2c48383b 100644 --- a/web/components/pages/Error/index.js +++ b/web/components/pages/Error/index.js @@ -12,7 +12,7 @@ import type { ComponentError } from 'shared/types/error'; type Props = { statusCode?: number, - error?: ComponentError + error?: ComponentError, }; export default class Error extends Component { @@ -44,7 +44,7 @@ export default class Error extends Component { actions={[ - + , ]} /> ); @@ -102,7 +102,7 @@ export default class Error extends Component { actions={[ - + , ]} /> ); diff --git a/web/components/pages/GameFrame.js b/web/components/pages/GameFrame.js index cd9be6e9..f1c6edf9 100644 --- a/web/components/pages/GameFrame.js +++ b/web/components/pages/GameFrame.js @@ -7,7 +7,7 @@ import GameContainer from '../GameContainer'; import type { Node } from 'react'; type Props = { - children: Node + children: Node, }; export default class GameFrame extends Component { diff --git a/web/components/pages/NewGame.fixture.js b/web/components/pages/NewGame.fixture.js index d1927215..a57c8339 100644 --- a/web/components/pages/NewGame.fixture.js +++ b/web/components/pages/NewGame.fixture.js @@ -22,5 +22,5 @@ export default { - ) + ), }; diff --git a/web/components/pages/NewGame.js b/web/components/pages/NewGame.js index 7c758c86..aa005535 100644 --- a/web/components/pages/NewGame.js +++ b/web/components/pages/NewGame.js @@ -14,12 +14,12 @@ import type { UnauthAction } from 'shared/types/actions'; type Props = { curUser: ?User, - unauth: () => UnauthAction + unauth: () => UnauthAction, }; type LocalState = { requireAuth: boolean, - pendingCreate: boolean + pendingCreate: boolean, }; class NewGame extends Component { @@ -28,7 +28,7 @@ class NewGame extends Component { this.state = { requireAuth: !props.curUser, - pendingCreate: false + pendingCreate: false, }; } @@ -46,7 +46,7 @@ class NewGame extends Component { // server deploy (which flushes all user sessions) this.setState({ requireAuth: true, - pendingCreate: false + pendingCreate: false, }); } } @@ -89,14 +89,11 @@ async function createAndOpenGame() { } const mapStateToProps = ({ curUser }: State): $Shape => ({ - curUser + curUser, }); const mapDispatchToProps = { - unauth + unauth, }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(NewGame); +export default connect(mapStateToProps, mapDispatchToProps)(NewGame); diff --git a/web/components/screens/Auth/index.fixture.js b/web/components/screens/Auth/index.fixture.js index 40a4aba6..a40677ec 100644 --- a/web/components/screens/Auth/index.fixture.js +++ b/web/components/screens/Auth/index.fixture.js @@ -15,5 +15,5 @@ export default { console.log('Auth started...')} /> - ) + ), }; diff --git a/web/components/screens/Auth/index.js b/web/components/screens/Auth/index.js index 105638bc..e055232e 100644 --- a/web/components/screens/Auth/index.js +++ b/web/components/screens/Auth/index.js @@ -16,7 +16,7 @@ import type { State, User } from 'shared/types/state'; type Props = { jsReady: boolean, - auth: typeof auth + auth: typeof auth, }; type OnboardingStep = 'intro' | '1vs1' | '0sum' | 'howto'; @@ -26,14 +26,14 @@ type LocalState = { pendingAuth: boolean, user: ?User, onboardingStep: OnboardingStep, - hasSubmitted: boolean + hasSubmitted: boolean, }; const ONBOARDING_SCREENS = { intro: FlatrisIntro, '1vs1': Multiplayer, '0sum': ZeroSum, - howto: HowToPlay + howto: HowToPlay, }; const ONBOARDING_STEPS = Object.keys(ONBOARDING_SCREENS); @@ -46,7 +46,7 @@ class Auth extends Component { pendingAuth: false, user: null, onboardingStep: 'intro', - hasSubmitted: false + hasSubmitted: false, }; componentDidUpdate(prevProps) { @@ -68,7 +68,7 @@ class Auth extends Component { handleNameChange = e => { this.setState({ - name: e.target.value + name: e.target.value, }); }; @@ -78,7 +78,7 @@ class Auth extends Component { const { name } = this.state; if (name) { this.setState({ - pendingAuth: true + pendingAuth: true, }); const user = await createUserSession(name); @@ -87,7 +87,7 @@ class Auth extends Component { // user seems the onboarding screen this.setState({ pendingAuth: false, - user + user, }); } }; @@ -105,11 +105,11 @@ class Auth extends Component { if (nextStep) { this.setState({ - onboardingStep: nextStep + onboardingStep: nextStep, }); } else { this.setState({ - hasSubmitted: true + hasSubmitted: true, }); auth(user); @@ -123,7 +123,7 @@ class Auth extends Component { pendingAuth, user, onboardingStep, - hasSubmitted + hasSubmitted, } = this.state; // Greet user with onboarding after they authenticate @@ -164,7 +164,7 @@ class Auth extends Component { actions={[ + , ]} />