feat: Use prettier-eslint to format code

This commit is contained in:
Bouncey
2019-02-18 19:32:49 +00:00
committed by mrugesh mohapatra
parent 1ba67c4e2b
commit b13e5fb41a
82 changed files with 1767 additions and 1017 deletions

View File

@ -1,10 +1,8 @@
import _ from 'lodash';
export const alertTypes = _.keyBy([
'success',
'info',
'warning',
'danger'
], _.identity);
export const alertTypes = _.keyBy(
['success', 'info', 'warning', 'danger'],
_.identity
);
export const normalizeAlertType = alertType => alertTypes[alertType] || 'info';

View File

@ -1,15 +1,9 @@
import emptyProtector from './empty-protector';
export function checkMapData(
{
entities: {
challenge,
block,
superBlock
},
result: { superBlocks }
}
) {
export function checkMapData({
entities: { challenge, block, superBlock },
result: { superBlocks }
}) {
if (
!challenge ||
!block ||
@ -17,9 +11,7 @@ export function checkMapData(
!superBlocks ||
!superBlocks.length
) {
throw new Error(
'entities not found, db may not be properly seeded'
);
throw new Error('entities not found, db may not be properly seeded');
}
}
// getFirstChallenge(
@ -33,11 +25,8 @@ export function getFirstChallenge({
result: { superBlocks }
}) {
return challenge[
emptyProtector(block[
emptyProtector(superBlock[
superBlocks[0]
]).blocks[0]
]).challenges[0]
emptyProtector(block[emptyProtector(superBlock[superBlocks[0]]).blocks[0]])
.challenges[0]
];
}
@ -52,12 +41,10 @@ export function getFirstChallenge({
// };
export function createNameIdMap({ challenge }) {
return {
challengeIdToName: Object.keys(challenge)
.reduce((map, challengeName) => {
map[challenge[challengeName].id] =
challenge[challengeName].dashedName;
return map;
}, {})
challengeIdToName: Object.keys(challenge).reduce((map, challengeName) => {
map[challenge[challengeName].id] = challenge[challengeName].dashedName;
return map;
}, {})
};
}
// addNameIdMap(

View File

@ -3,14 +3,11 @@ import invariant from 'invariant';
import { Observable } from 'rx';
import castToObservable from '../../server/utils/cast-to-observable';
// createFileStream(
// files: [...PolyVinyl]
// ) => Observable[...Observable[...PolyVinyl]]
export function createFileStream(files = []) {
return Observable.of(
Observable.from(files)
);
return Observable.of(Observable.from(files));
}
// Observable::pipe(
@ -20,8 +17,8 @@ export function createFileStream(files = []) {
// ) => Observable[...Observable[...PolyVinyl]]
export function pipe(project) {
const source = this;
return source.map(
files => files.flatMap(file => castToObservable(project(file)))
return source.map(files =>
files.flatMap(file => castToObservable(project(file)))
);
}
@ -44,24 +41,10 @@ export function pipe(project) {
// contents: String,
// history?: [...String],
// }) => PolyVinyl, throws
export function createPoly({
name,
ext,
contents,
history,
...rest
} = {}) {
invariant(
typeof name === 'string',
'name must be a string but got %s',
name
);
export function createPoly({ name, ext, contents, history, ...rest } = {}) {
invariant(typeof name === 'string', 'name must be a string but got %s', name);
invariant(
typeof ext === 'string',
'ext must be a string, but was %s',
ext
);
invariant(typeof ext === 'string', 'ext must be a string, but was %s', ext);
invariant(
typeof contents === 'string',
@ -71,7 +54,7 @@ export function createPoly({
return {
...rest,
history: Array.isArray(history) ? history : [ name + ext ],
history: Array.isArray(history) ? history : [name + ext],
name,
ext,
path: name + '.' + ext,
@ -83,11 +66,13 @@ export function createPoly({
// isPoly(poly: Any) => Boolean
export function isPoly(poly) {
return poly &&
return (
poly &&
typeof poly.contents === 'string' &&
typeof poly.name === 'string' &&
typeof poly.ext === 'string' &&
Array.isArray(poly.history);
Array.isArray(poly.history)
);
}
// checkPoly(poly: Any) => Void, throws
@ -125,7 +110,7 @@ export function setExt(ext, poly) {
path: poly.name + '.' + ext,
key: poly.name + ext
};
newPoly.history = [ ...poly.history, newPoly.path ];
newPoly.history = [...poly.history, newPoly.path];
return newPoly;
}
@ -138,7 +123,7 @@ export function setName(name, poly) {
path: name + '.' + poly.ext,
key: name + poly.ext
};
newPoly.history = [ ...poly.history, newPoly.path ];
newPoly.history = [...poly.history, newPoly.path];
return newPoly;
}
@ -177,10 +162,12 @@ export function appendToTail(tail, poly) {
// compileHeadTail(padding: String, poly: PolyVinyl) => PolyVinyl
export function compileHeadTail(padding = '', poly) {
return clearHeadTail(transformContents(
() => [ poly.head, poly.contents, poly.tail ].join(padding),
poly
));
return clearHeadTail(
transformContents(
() => [poly.head, poly.contents, poly.tail].join(padding),
poly
)
);
}
// transformContents(
@ -192,10 +179,7 @@ export function compileHeadTail(padding = '', poly) {
// already contains a source, this version will continue as
// the source property
export function transformContents(wrap, poly) {
const newPoly = setContent(
wrap(poly.contents),
poly
);
const newPoly = setContent(wrap(poly.contents), poly);
// if no source exist, set the original contents as source
newPoly.source = poly.source || poly.contents;
return newPoly;
@ -207,10 +191,7 @@ export function transformContents(wrap, poly) {
// ) => PolyVinyl
export function transformHeadTailAndContents(wrap, poly) {
return {
...transformContents(
wrap,
poly
),
...transformContents(wrap, poly),
head: wrap(poly.head),
tail: wrap(poly.tail)
};

View File

@ -3,8 +3,7 @@ export const themes = {
default: 'default'
};
export const invertTheme = currentTheme => (
!currentTheme || currentTheme === themes.default ?
themes.night :
themes.default
);
export const invertTheme = currentTheme =>
!currentTheme || currentTheme === themes.default
? themes.night
: themes.default;