Skip to content

Commit

Permalink
feat: Use prettier-eslint to format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouncey authored and raisedadead committed Feb 19, 2019
1 parent 1ba67c4 commit b13e5fb
Show file tree
Hide file tree
Showing 82 changed files with 1,767 additions and 1,017 deletions.
8 changes: 4 additions & 4 deletions api-server/common/models/User-Identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ export default function(UserIdent) {
return identity
? Observable.of(identity.user())
: User.findOne$({ where: { email } }).flatMap(user => {
return user
? Observable.of(user)
: User.create$({ email }).toPromise();
});
return user
? Observable.of(user)
: User.create$({ email }).toPromise();
});
})
.flatMap(user => {
const createToken = observeQuery(AccessToken, 'create', {
Expand Down
9 changes: 3 additions & 6 deletions api-server/common/models/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { Observable } from 'rx';

export default function(Block) {
Block.on('dataSourceAttached', () => {
Block.findOne$ =
Observable.fromNodeCallback(Block.findOne, Block);
Block.findById$ =
Observable.fromNodeCallback(Block.findById, Block);
Block.find$ =
Observable.fromNodeCallback(Block.find, Block);
Block.findOne$ = Observable.fromNodeCallback(Block.findOne, Block);
Block.findById$ = Observable.fromNodeCallback(Block.findById, Block);
Block.find$ = Observable.fromNodeCallback(Block.find, Block);
});
}
10 changes: 4 additions & 6 deletions api-server/common/utils/flash.js
Original file line number Diff line number Diff line change
@@ -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';
35 changes: 11 additions & 24 deletions api-server/common/utils/map.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
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 ||
!superBlock ||
!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(
Expand All @@ -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]
];
}

Expand All @@ -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(
Expand Down
61 changes: 21 additions & 40 deletions api-server/common/utils/polyvinyl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)))
);
}

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

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

Expand Down Expand Up @@ -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(
Expand All @@ -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;
Expand All @@ -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)
};
Expand Down
9 changes: 4 additions & 5 deletions api-server/common/utils/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 1 addition & 3 deletions api-server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ module.exports = {
transform: {
'^.+\\.js$': 'babel-jest'
},
transformIgnorePatterns: [
'node_modules/(?!(gatsby)/)'
]
transformIgnorePatterns: ['node_modules/(?!(gatsby)/)']
};
5 changes: 2 additions & 3 deletions api-server/server/boot/certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,8 @@ function createShowCert(app) {
messages: [
{
type: 'info',
message: `We could not find a user with the username "${
username
}"`
message:
'We could not find a user with the username "' + username + '"'
}
]
});
Expand Down
2 changes: 1 addition & 1 deletion api-server/server/boot/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export default async function bootChallenge(app, done) {
) {
req.flash(
'danger',
'You haven\'t supplied the necessary URLs for us to inspect your work.'
"You haven't supplied the necessary URLs for us to inspect your work."
);
return res.sendStatus(403);
}
Expand Down
Loading

0 comments on commit b13e5fb

Please sign in to comment.