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
+1 -1
View File
@@ -114,7 +114,7 @@ function superBlockInfoFromPath(filePath) {
}
function superBlockInfoFromFullPath(fullFilePath) {
const [,, maybeSuper] = fullFilePath.split(path.sep).reverse();
const [, , maybeSuper] = fullFilePath.split(path.sep).reverse();
return superBlockInfo(maybeSuper);
}
+2 -6
View File
@@ -1,13 +1,9 @@
const fs = require('fs-extra');
const gulp = require('gulp');
const {
locale
} = require('../config/env.json');
const { locale } = require('../config/env.json');
const {
getChallengesForLang
} = require('./getChallenges');
const { getChallengesForLang } = require('./getChallenges');
function generateCurriculum(done) {
return getChallengesForLang(locale)
+66 -63
View File
@@ -8,9 +8,7 @@ const _ = require('lodash');
const createDebugger = require('debug');
const utils = require('../server/utils');
const getChallenges = require('./getChallenges');
const { validateChallenge } = require(
'./schema/challengeSchema'
);
const { validateChallenge } = require('./schema/challengeSchema');
const app = require('../server/server');
const log = createDebugger('fcc:seed');
@@ -23,10 +21,14 @@ const nameify = utils.nameify;
const Observable = Rx.Observable;
const Challenge = app.models.Challenge;
const destroyChallenges =
Observable.fromNodeCallback(Challenge.destroyAll, Challenge);
const createChallenges =
Observable.fromNodeCallback(Challenge.create, Challenge);
const destroyChallenges = Observable.fromNodeCallback(
Challenge.destroyAll,
Challenge
);
const createChallenges = Observable.fromNodeCallback(
Challenge.create,
Challenge
);
const Block = app.models.Block;
const destroyBlocks = Observable.fromNodeCallback(Block.destroyAll, Block);
@@ -34,12 +36,11 @@ const createBlocks = Observable.fromNodeCallback(Block.create, Block);
const arrToString = arr =>
Array.isArray(arr) ? arr.join('\n') : _.toString(arr);
Observable.combineLatest(
destroyChallenges(),
destroyBlocks()
)
Observable.combineLatest(destroyChallenges(), destroyBlocks())
.last()
.flatMap(function() { return Observable.from(getChallenges()); })
.flatMap(function() {
return Observable.from(getChallenges());
})
.flatMap(function(challengeSpec) {
const order = challengeSpec.order;
const blockName = challengeSpec.name;
@@ -80,23 +81,24 @@ Observable.combineLatest(
.map(block => {
log('successfully created %s block', block.name);
return challengeSpec.challenges
.map(function(challenge, index) {
challenge.name = nameify(challenge.title);
return challengeSpec.challenges.map(function(challenge, index) {
challenge.name = nameify(challenge.title);
challenge.dashedName = dasherize(challenge.name);
challenge.dashedName = dasherize(challenge.name);
challenge.checksum = adler32.sum(
Buffer(
challenge.title +
challenge.checksum = adler32.sum(
Buffer(
challenge.title +
JSON.stringify(challenge.description) +
JSON.stringify(challenge.challengeSeed) +
JSON.stringify(challenge.tests)
)
);
)
);
if (challenge.files) {
challenge.files = _.reduce(challenge.files, (map, file) => {
if (challenge.files) {
challenge.files = _.reduce(
challenge.files,
(map, file) => {
map[file.key] = {
...file,
head: arrToString(file.head),
@@ -104,46 +106,45 @@ Observable.combineLatest(
tail: arrToString(file.tail)
};
return map;
}, {});
}
challenge.fileName = fileName;
challenge.helpRoom = helpRoom;
challenge.order = order;
challenge.suborder = index + 1;
challenge.block = dasherize(blockName);
challenge.blockId = '' + block.id;
challenge.isBeta = challenge.isBeta || isBeta;
challenge.isComingSoon = challenge.isComingSoon || isComingSoon;
challenge.isLocked = challenge.isLocked || isLocked;
challenge.isPrivate = challenge.isPrivate || isPrivate;
challenge.time = challengeSpec.time;
challenge.superOrder = superOrder;
challenge.superBlock = superBlock
.split('-')
.map(function(word) {
return _.capitalize(word);
})
.join(' ');
challenge.required = (challenge.required || []).concat(required);
challenge.template = challenge.template || template;
return _.omit(
challenge,
[
'betaSolutions',
'betaTests',
'hints',
'MDNlinks',
'null',
'rawSolutions',
'react',
'reactRedux',
'redux',
'releasedOn',
'translations',
'type'
]
},
{}
);
});
}
challenge.fileName = fileName;
challenge.helpRoom = helpRoom;
challenge.order = order;
challenge.suborder = index + 1;
challenge.block = dasherize(blockName);
challenge.blockId = '' + block.id;
challenge.isBeta = challenge.isBeta || isBeta;
challenge.isComingSoon = challenge.isComingSoon || isComingSoon;
challenge.isLocked = challenge.isLocked || isLocked;
challenge.isPrivate = challenge.isPrivate || isPrivate;
challenge.time = challengeSpec.time;
challenge.superOrder = superOrder;
challenge.superBlock = superBlock
.split('-')
.map(function(word) {
return _.capitalize(word);
})
.join(' ');
challenge.required = (challenge.required || []).concat(required);
challenge.template = challenge.template || template;
return _.omit(challenge, [
'betaSolutions',
'betaTests',
'hints',
'MDNlinks',
'null',
'rawSolutions',
'react',
'reactRedux',
'redux',
'releasedOn',
'translations',
'type'
]);
});
})
.flatMap(challenges => {
challenges.forEach(challenge => {
@@ -160,7 +161,9 @@ Observable.combineLatest(
function(challenges) {
log('%s successfully saved', challenges[0].block);
},
function(err) { throw err; },
function(err) {
throw err;
},
function() {
log('challenge seed completed');
process.exit(0);
+1 -5
View File
@@ -55,11 +55,7 @@ async function translateChallenge(file) {
];
return Promise.all(translatePromises).then(
([title, description, instructions, ...tests]) => {
const {
files = {},
solutions = [],
...challengeMeta
} = challenge;
const { files = {}, solutions = [], ...challengeMeta } = challenge;
const md = `---
${YAML.dump(
Object.assign(challengeMeta, {
+1 -1
View File
@@ -20,7 +20,7 @@ class ChallengeTitles {
The title ${title} is already assigned
`);
}
this.knownTitles = [ ...this.knownTitles, titleToCheck ];
this.knownTitles = [...this.knownTitles, titleToCheck];
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ class MongoIds {
The id for ${title} is already assigned
`);
}
this.knownIds = [ ...this.knownIds, id ];
this.knownIds = [...this.knownIds, id];
}
}