Skip to content

Commit

Permalink
Prettify (ovidiuch#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiuch authored May 28, 2020
1 parent 826cc02 commit 2209ce5
Show file tree
Hide file tree
Showing 120 changed files with 529 additions and 480 deletions.
36 changes: 18 additions & 18 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ 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,
process: true,
page: true,
browser: true,
context: true,
jestPuppeteer: true
jestPuppeteer: true,
},
rules: {
'no-console': 'off',
'flowtype/generic-spacing': 'off'
'flowtype/generic-spacing': 'off',
},
overrides: [
{
Expand All @@ -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,
},
},
],
};
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
package.json
flow-typed
web/cosmos-export
2 changes: 2 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"arrowParens": "avoid",
"endOfLine": "lf",
"singleQuote": true
}
6 changes: 3 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -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 }]],
};
4 changes: 2 additions & 2 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
launch: {
args: ['--no-sandbox']
}
args: ['--no-sandbox'],
},
};
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module.exports = {
setupFilesAfterEnv: ['./jest.framework-setup.js'],
setupFiles: ['<rootDir>/jest.setup.js'],
moduleNameMapper: {
'\\.css$': 'identity-obj-proxy'
}
'\\.css$': 'identity-obj-proxy',
},
};
2 changes: 1 addition & 1 deletion jest.visual.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
preset: 'jest-puppeteer',
setupFilesAfterEnv: ['./jest.framework-setup.js'],
testMatch: ['**/visualtest.js']
testMatch: ['**/visualtest.js'],
};
4 changes: 2 additions & 2 deletions scripts/generate-game-media-queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function getLandscapeQuery({ height }) {

const cond = getMediaQueryCond({
width: widthWithControls,
height
height,
});
const body = getLandscapeRules({ width, height: gameHeight });

Expand Down Expand Up @@ -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),
};
}

Expand Down
14 changes: 7 additions & 7 deletions server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -184,9 +184,9 @@ function extractBackfillRequest(req: mixed): BackfillRequest {

return {
userId,
from
from,
};
})
}),
};
}

Expand Down
6 changes: 3 additions & 3 deletions server/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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,
}
);

Expand Down
8 changes: 4 additions & 4 deletions server/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function getStats(): Promise<Stats> {
actionRotate: 0,
games: 0,
lines: 0,
seconds: 0
seconds: 0,
};
} else {
const ref = db.ref('counts');
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -153,7 +153,7 @@ function prepareStats(rawStats) {
games,
lines,
seconds,
turns
turns,
} = rawStats;

return {
Expand All @@ -163,7 +163,7 @@ function prepareStats(rawStats) {
actionRotate,
games: games + turns,
lines,
seconds
seconds,
};
}

Expand Down
4 changes: 2 additions & 2 deletions server/rollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export const rollbar = new Rollbar({
verbose: true,
reportLevel: 'info',
payload: {
environment: process.env.NODE_ENV
}
environment: process.env.NODE_ENV,
},
});
6 changes: 3 additions & 3 deletions server/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -16,7 +16,7 @@ import {
incrementActionRight,
incrementActionAcc,
incrementActionRotate,
incrementGameTime
incrementGameTime,
} from './firebase';
import { rollbar } from './rollbar';

Expand Down Expand Up @@ -123,7 +123,7 @@ export function attachSocket(server: net$Server) {
}

const gameSync: {
[id: string]: true
[id: string]: true,
} = {};

let pendingLeftCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion server/start-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
44 changes: 36 additions & 8 deletions shared/constants/tetromino.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
],
};
Loading

0 comments on commit 2209ce5

Please sign in to comment.