chore(deps): upgrade eslint, prettier & related packages
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
0a53a1d7f0
commit
6c91f81b0e
@ -8,8 +8,8 @@ import {
|
||||
} from '../../server/utils/auth';
|
||||
|
||||
const log = debug('fcc:models:UserCredential');
|
||||
module.exports = function(UserCredential) {
|
||||
UserCredential.link = function(
|
||||
module.exports = function (UserCredential) {
|
||||
UserCredential.link = function (
|
||||
userId,
|
||||
_provider,
|
||||
authScheme,
|
||||
|
@ -14,12 +14,12 @@ export function ensureLowerCaseEmail(profile) {
|
||||
: '';
|
||||
}
|
||||
|
||||
export default function(UserIdent) {
|
||||
export default function (UserIdent) {
|
||||
UserIdent.on('dataSourceAttached', () => {
|
||||
UserIdent.findOne$ = observeMethod(UserIdent, 'findOne');
|
||||
});
|
||||
|
||||
UserIdent.login = function(
|
||||
UserIdent.login = function (
|
||||
_provider,
|
||||
authScheme,
|
||||
profile,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Observable } from 'rx';
|
||||
|
||||
export default function(Block) {
|
||||
export default function (Block) {
|
||||
Block.on('dataSourceAttached', () => {
|
||||
Block.findOne$ = Observable.fromNodeCallback(Block.findOne, Block);
|
||||
Block.findById$ = Observable.fromNodeCallback(Block.findById, Block);
|
||||
|
@ -152,7 +152,7 @@ function populateRequiredFields(user) {
|
||||
return;
|
||||
}
|
||||
|
||||
export default function(User) {
|
||||
export default function (User) {
|
||||
// set salt factor for passwords
|
||||
User.settings.saltWorkFactor = 5;
|
||||
// set user.rand to random number
|
||||
@ -180,7 +180,7 @@ export default function(User) {
|
||||
);
|
||||
});
|
||||
|
||||
User.observe('before save', function(ctx) {
|
||||
User.observe('before save', function (ctx) {
|
||||
const beforeCreate = Observable.of(ctx)
|
||||
.filter(({ isNewInstance }) => isNewInstance)
|
||||
// User.create
|
||||
@ -229,7 +229,7 @@ export default function(User) {
|
||||
});
|
||||
|
||||
// remove lingering user identities before deleting user
|
||||
User.observe('before delete', function(ctx, next) {
|
||||
User.observe('before delete', function (ctx, next) {
|
||||
const UserIdentity = User.app.models.UserIdentity;
|
||||
const UserCredential = User.app.models.UserCredential;
|
||||
log('removing user', ctx.where);
|
||||
@ -240,21 +240,21 @@ export default function(User) {
|
||||
return Observable.combineLatest(
|
||||
destroyAll(id, UserIdentity),
|
||||
destroyAll(id, UserCredential),
|
||||
function(identData, credData) {
|
||||
function (identData, credData) {
|
||||
return {
|
||||
identData: identData,
|
||||
credData: credData
|
||||
};
|
||||
}
|
||||
).subscribe(
|
||||
function(data) {
|
||||
function (data) {
|
||||
log('deleted', data);
|
||||
},
|
||||
function(err) {
|
||||
function (err) {
|
||||
log('error deleting user %s stuff', id, err);
|
||||
next(err);
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
log('user stuff deleted for user %s', id);
|
||||
next();
|
||||
}
|
||||
@ -263,7 +263,7 @@ export default function(User) {
|
||||
|
||||
log('setting up user hooks');
|
||||
// overwrite lb confirm
|
||||
User.confirm = function(uid, token, redirectTo) {
|
||||
User.confirm = function (uid, token, redirectTo) {
|
||||
return this.findById(uid).then(user => {
|
||||
if (!user) {
|
||||
throw wrapHandledError(new Error(`User not found: ${uid}`), {
|
||||
@ -339,7 +339,7 @@ export default function(User) {
|
||||
);
|
||||
};
|
||||
|
||||
User.afterRemote('logout', function({ req, res }, result, next) {
|
||||
User.afterRemote('logout', function ({ req, res }, result, next) {
|
||||
removeCookies(req, res);
|
||||
next();
|
||||
});
|
||||
@ -802,7 +802,7 @@ export default function(User) {
|
||||
...user,
|
||||
about: showAbout ? about : '',
|
||||
calendar: showHeatMap ? calendar : {},
|
||||
completedChallenges: (function() {
|
||||
completedChallenges: (function () {
|
||||
if (showTimeLine) {
|
||||
return showCerts
|
||||
? completedChallenges
|
||||
|
@ -41,9 +41,9 @@ export default function donateBoot(app, done) {
|
||||
metadata: {
|
||||
/* eslint-disable camelcase */
|
||||
sb_service: `freeCodeCamp.org`,
|
||||
sb_tier: `${
|
||||
donationSubscriptionConfig.duration[duration]
|
||||
} $${amount / 100} Donation`
|
||||
sb_tier: `${donationSubscriptionConfig.duration[duration]} $${
|
||||
amount / 100
|
||||
} Donation`
|
||||
/* eslint-enable camelcase */
|
||||
}
|
||||
},
|
||||
@ -68,11 +68,11 @@ export default function donateBoot(app, done) {
|
||||
}
|
||||
|
||||
function connectToStripe() {
|
||||
return new Promise(function(resolve) {
|
||||
return new Promise(function (resolve) {
|
||||
// connect to stripe API
|
||||
stripe = Stripe(keys.stripe.secret);
|
||||
// parse stripe plans
|
||||
stripe.plans.list({}, function(err, stripePlans) {
|
||||
stripe.plans.list({}, function (err, stripePlans) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
@ -96,7 +96,7 @@ export default function donateBoot(app, done) {
|
||||
|
||||
function createStripePlan(plan) {
|
||||
log(`Creating subscription plan: ${plan.product.name}`);
|
||||
stripe.plans.create(plan, function(err) {
|
||||
stripe.plans.create(plan, function (err) {
|
||||
if (err) {
|
||||
log(err);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ module.exports = function mountLoopBackExplorer(app) {
|
||||
} catch (err) {
|
||||
// Print the message only when the app was started via `app.listen()`.
|
||||
// Do not print any message when the project is used as a component.
|
||||
app.once('started', function() {
|
||||
app.once('started', function () {
|
||||
log(
|
||||
'Run `npm install loopback-component-explorer` to enable ' +
|
||||
'the LoopBack explorer'
|
||||
@ -25,7 +25,7 @@ module.exports = function mountLoopBackExplorer(app) {
|
||||
const mountPath = '/explorer';
|
||||
|
||||
explorer(app, { basePath: restApiRoot, mountPath });
|
||||
app.once('started', function() {
|
||||
app.once('started', function () {
|
||||
const baseUrl = app.get('url').replace(/\/$/, '');
|
||||
|
||||
log('Browse your REST API at %s%s', baseUrl, mountPath);
|
||||
|
@ -6,7 +6,7 @@ import { getRedirectParams } from '../utils/redirection';
|
||||
const githubClient = process.env.GITHUB_ID;
|
||||
const githubSecret = process.env.GITHUB_SECRET;
|
||||
|
||||
module.exports = function(app) {
|
||||
module.exports = function (app) {
|
||||
const router = app.loopback.Router();
|
||||
const User = app.models.User;
|
||||
|
||||
@ -168,7 +168,7 @@ module.exports = function(app) {
|
||||
githubSecret
|
||||
].join(''),
|
||||
githubHeaders,
|
||||
function(err, status1, pulls) {
|
||||
function (err, status1, pulls) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -185,7 +185,7 @@ module.exports = function(app) {
|
||||
githubSecret
|
||||
].join(''),
|
||||
githubHeaders,
|
||||
function(err, status2, issues) {
|
||||
function (err, status2, issues) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
@ -77,9 +77,7 @@ function refetchCompletedChallenges(req, res, next) {
|
||||
}
|
||||
|
||||
const updateMyEmailValidators = [
|
||||
check('email')
|
||||
.isEmail()
|
||||
.withMessage('Email format is invalid.')
|
||||
check('email').isEmail().withMessage('Email format is invalid.')
|
||||
];
|
||||
|
||||
function updateMyEmail(req, res, next) {
|
||||
@ -117,9 +115,7 @@ function updateMyCurrentChallenge(req, res, next) {
|
||||
}
|
||||
|
||||
const updateMyThemeValidators = [
|
||||
check('theme')
|
||||
.isIn(Object.keys(themes))
|
||||
.withMessage('Theme is invalid.')
|
||||
check('theme').isIn(Object.keys(themes)).withMessage('Theme is invalid.')
|
||||
];
|
||||
|
||||
function updateMyTheme(req, res, next) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
module.exports = function(app) {
|
||||
module.exports = function (app) {
|
||||
var router = app.loopback.Router();
|
||||
router.get('/wiki/*', showForum);
|
||||
|
||||
|
@ -125,7 +125,7 @@ function getUnlinkSocial(req, res, next) {
|
||||
}
|
||||
};
|
||||
|
||||
return user.identities(query, function(err, identities) {
|
||||
return user.identities(query, function (err, identities) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -137,7 +137,7 @@ function getUnlinkSocial(req, res, next) {
|
||||
return res.redirect('/' + username);
|
||||
}
|
||||
|
||||
return identity.destroy(function(err) {
|
||||
return identity.destroy(function (err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -181,7 +181,7 @@ function postResetProgress(req, res, next) {
|
||||
isMachineLearningPyCertV7: false,
|
||||
completedChallenges: []
|
||||
},
|
||||
function(err) {
|
||||
function (err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -193,7 +193,7 @@ function postResetProgress(req, res, next) {
|
||||
function createPostDeleteAccount(app) {
|
||||
const { User } = app.models;
|
||||
return function postDeleteAccount(req, res, next) {
|
||||
return User.destroyById(req.user.id, function(err) {
|
||||
return User.destroyById(req.user.id, function (err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import accepts from 'accepts';
|
||||
import { getRedirectParams } from '../utils/redirection';
|
||||
|
||||
export default function fourOhFour(app) {
|
||||
app.all('*', function(req, res) {
|
||||
app.all('*', function (req, res) {
|
||||
const accept = accepts(req);
|
||||
const type = accept.type('html', 'json', 'text');
|
||||
const { path } = req;
|
||||
|
@ -53,7 +53,7 @@ export function setupPassport(app) {
|
||||
|
||||
configurator.init();
|
||||
|
||||
Object.keys(passportProviders).map(function(strategy) {
|
||||
Object.keys(passportProviders).map(function (strategy) {
|
||||
let config = passportProviders[strategy];
|
||||
config.session = config.session !== false;
|
||||
|
||||
|
@ -64,9 +64,12 @@ boot(app, __dirname, err => {
|
||||
setupPassport(app);
|
||||
|
||||
const { db } = app.datasources;
|
||||
db.on('connected', _.once(() => log('db connected')));
|
||||
app.start = _.once(function() {
|
||||
const server = app.listen(app.get('port'), function() {
|
||||
db.on(
|
||||
'connected',
|
||||
_.once(() => log('db connected'))
|
||||
);
|
||||
app.start = _.once(function () {
|
||||
const server = app.listen(app.get('port'), function () {
|
||||
app.emit('started');
|
||||
log(
|
||||
'freeCodeCamp server listening on port %d in %s',
|
||||
|
@ -2,7 +2,7 @@ import { homeLocation } from '../../../../config/env';
|
||||
import { allowedOrigins } from '../../../../config/cors-settings';
|
||||
|
||||
export default function constantHeaders() {
|
||||
return function(req, res, next) {
|
||||
return function (req, res, next) {
|
||||
if (
|
||||
req.headers &&
|
||||
req.headers.origin &&
|
||||
|
@ -1,6 +1,6 @@
|
||||
import csurf from 'csurf';
|
||||
|
||||
export default function() {
|
||||
export default function () {
|
||||
const protection = csurf({
|
||||
cookie: {
|
||||
domain: process.env.COOKIE_DOMAIN || 'localhost',
|
||||
|
@ -25,7 +25,7 @@ const isDev = process.env.FREECODECAMP_NODE_ENV !== 'production';
|
||||
export default function prodErrorHandler() {
|
||||
// error handling in production.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
return function(err, req, res, next) {
|
||||
return function (err, req, res, next) {
|
||||
const { origin } = getRedirectParams(req);
|
||||
const handled = unwrapHandledError(err);
|
||||
// respect handled error status
|
||||
|
@ -1,7 +1,7 @@
|
||||
import qs from 'query-string';
|
||||
|
||||
// add rx methods to express
|
||||
export default function() {
|
||||
export default function () {
|
||||
return function expressExtensions(req, res, next) {
|
||||
res.redirectWithFlash = uri => {
|
||||
const flash = req.flash();
|
||||
|
@ -10,7 +10,7 @@ const EXCLUDED_PATHS = [
|
||||
];
|
||||
|
||||
export default function flashCheaters() {
|
||||
return function(req, res, next) {
|
||||
return function (req, res, next) {
|
||||
if (
|
||||
ALLOWED_METHODS.indexOf(req.method) !== -1 &&
|
||||
EXCLUDED_PATHS.indexOf(req.path) === -1 &&
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Observable } from 'rx';
|
||||
|
||||
export default function(AuthToken) {
|
||||
export default function (AuthToken) {
|
||||
AuthToken.on('dataSourceAttached', () => {
|
||||
AuthToken.findOne$ = Observable.fromNodeCallback(
|
||||
AuthToken.findOne.bind(AuthToken)
|
||||
|
@ -7,7 +7,7 @@ import InMemoryCache from '../utils/in-memory-cache';
|
||||
const log = debug('fcc:boot:donate');
|
||||
const fiveMinutes = 1000 * 60 * 5;
|
||||
|
||||
export default function(Donation) {
|
||||
export default function (Donation) {
|
||||
let activeDonationUpdateInterval = null;
|
||||
const activeDonationCountCacheTTL = fiveMinutes;
|
||||
const activeDonationCountCache = InMemoryCache(0, reportError);
|
||||
|
@ -3,14 +3,8 @@ import moment from 'moment-timezone';
|
||||
// day count between two epochs (inclusive)
|
||||
export function dayCount([head, tail], timezone = 'UTC') {
|
||||
return Math.ceil(
|
||||
moment(
|
||||
moment(head)
|
||||
.tz(timezone)
|
||||
.endOf('day')
|
||||
).diff(
|
||||
moment(tail)
|
||||
.tz(timezone)
|
||||
.startOf('day'),
|
||||
moment(moment(head).tz(timezone).endOf('day')).diff(
|
||||
moment(tail).tz(timezone).startOf('day'),
|
||||
'days',
|
||||
true
|
||||
)
|
||||
|
@ -28,7 +28,7 @@ export async function getAsyncPaypalToken() {
|
||||
}
|
||||
|
||||
export function capitalizeKeys(object) {
|
||||
Object.keys(object).forEach(function(key) {
|
||||
Object.keys(object).forEach(function (key) {
|
||||
object[key.toUpperCase()] = object[key];
|
||||
});
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ export default function populateUser(db, user) {
|
||||
{ $match: { _id: user.id } },
|
||||
{ $project: { points: { $size: '$progressTimestamps' } } }
|
||||
])
|
||||
.get(function(err, [{ points = 1 } = {}]) {
|
||||
.get(function (err, [{ points = 1 } = {}]) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
import { getRedirectParams } from './redirection';
|
||||
|
||||
export function ifNoUserRedirectHome(message, type = 'errors') {
|
||||
return function(req, res, next) {
|
||||
return function (req, res, next) {
|
||||
const { path } = req;
|
||||
if (req.user) {
|
||||
return next();
|
||||
@ -24,7 +24,7 @@ export function ifNoUserRedirectHome(message, type = 'errors') {
|
||||
}
|
||||
|
||||
export function ifNoUserSend(sendThis) {
|
||||
return function(req, res, next) {
|
||||
return function (req, res, next) {
|
||||
if (req.user) {
|
||||
return next();
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ import debugFactory from 'debug';
|
||||
const debug = debugFactory('fcc:rxUtils');
|
||||
|
||||
export function saveInstance(instance) {
|
||||
return new Rx.Observable.create(function(observer) {
|
||||
return new Rx.Observable.create(function (observer) {
|
||||
if (!instance || typeof instance.save !== 'function') {
|
||||
debug('no instance or save method');
|
||||
observer.onNext();
|
||||
return observer.onCompleted();
|
||||
}
|
||||
return instance.save(function(err, savedInstance) {
|
||||
return instance.save(function (err, savedInstance) {
|
||||
if (err) {
|
||||
return observer.onError(err);
|
||||
}
|
||||
@ -49,9 +49,7 @@ export function timeCache(time, unit) {
|
||||
// set new expire time in MS and create new subscription to source
|
||||
if (!expireCacheAt || expireCacheAt < Date.now()) {
|
||||
// set expire in ms;
|
||||
expireCacheAt = moment()
|
||||
.add(time, unit)
|
||||
.valueOf();
|
||||
expireCacheAt = moment().add(time, unit).valueOf();
|
||||
cache = new AsyncSubject();
|
||||
source.subscribe(cache);
|
||||
}
|
||||
|
@ -25,36 +25,23 @@ export function prepUniqueDaysByHours(cals, tz = 'UTC') {
|
||||
data.push(cur);
|
||||
prev = cur;
|
||||
} else if (
|
||||
moment(cur)
|
||||
.tz(tz)
|
||||
.diff(
|
||||
moment(prev)
|
||||
.tz(tz)
|
||||
.startOf('day'),
|
||||
'hours'
|
||||
) >= hoursDay
|
||||
moment(cur).tz(tz).diff(moment(prev).tz(tz).startOf('day'), 'hours') >=
|
||||
hoursDay
|
||||
) {
|
||||
data.push(cur);
|
||||
prev = cur;
|
||||
}
|
||||
}, []),
|
||||
sortBy(e => e),
|
||||
map(ts =>
|
||||
moment(ts)
|
||||
.tz(tz)
|
||||
.startOf('hours')
|
||||
.valueOf()
|
||||
)
|
||||
map(ts => moment(ts).tz(tz).startOf('hours').valueOf())
|
||||
)(cals);
|
||||
}
|
||||
|
||||
export function calcCurrentStreak(cals, tz = 'UTC') {
|
||||
let prev = last(cals);
|
||||
if (
|
||||
moment()
|
||||
.tz(tz)
|
||||
.startOf('day')
|
||||
.diff(moment(prev).tz(tz), 'hours') > hoursBetween
|
||||
moment().tz(tz).startOf('day').diff(moment(prev).tz(tz), 'hours') >
|
||||
hoursBetween
|
||||
) {
|
||||
return 0;
|
||||
}
|
||||
@ -62,10 +49,8 @@ export function calcCurrentStreak(cals, tz = 'UTC') {
|
||||
let streakContinues = true;
|
||||
forEachRight(cur => {
|
||||
if (
|
||||
moment(prev)
|
||||
.tz(tz)
|
||||
.startOf('day')
|
||||
.diff(moment(cur).tz(tz), 'hours') <= hoursBetween
|
||||
moment(prev).tz(tz).startOf('day').diff(moment(cur).tz(tz), 'hours') <=
|
||||
hoursBetween
|
||||
) {
|
||||
prev = cur;
|
||||
currentStreak++;
|
||||
@ -86,10 +71,8 @@ export function calcLongestStreak(cals, tz = 'UTC') {
|
||||
const last = cals[index === 0 ? 0 : index - 1];
|
||||
// is streak broken
|
||||
if (
|
||||
moment(head)
|
||||
.tz(tz)
|
||||
.startOf('day')
|
||||
.diff(moment(last).tz(tz), 'hours') > hoursBetween
|
||||
moment(head).tz(tz).startOf('day').diff(moment(last).tz(tz), 'hours') >
|
||||
hoursBetween
|
||||
) {
|
||||
tail = head;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ describe('user stats', () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe('calcCurrentStreak', function() {
|
||||
describe('calcCurrentStreak', function () {
|
||||
it('should return 1 day when today one challenge was completed', () => {
|
||||
expect(
|
||||
calcCurrentStreak(
|
||||
@ -291,7 +291,7 @@ describe('user stats', () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe('calcLongestStreak', function() {
|
||||
describe('calcLongestStreak', function () {
|
||||
it(
|
||||
'should return 1 when there is the only one one-day-long ' +
|
||||
'streak available',
|
||||
|
Reference in New Issue
Block a user