chore: commit lint fixes for the api
This commit is contained in:
committed by
mrugesh mohapatra
parent
010fa63e76
commit
07266b7e43
@ -4,14 +4,19 @@ export function dashify(str) {
|
||||
return ('' + str)
|
||||
.toLowerCase()
|
||||
.replace(/\s/g, '-')
|
||||
.replace(/[^a-z0-9\-\.]/gi, '')
|
||||
.replace(/\:/g, '');
|
||||
.replace(/[^a-z0-9\-.]/gi, '')
|
||||
.replace(/:/g, '');
|
||||
}
|
||||
// todo: unify with server/utils/index.js:dasherize
|
||||
const dasherize = dashify;
|
||||
export { dasherize };
|
||||
|
||||
export const fixCompletedChallengeItem = obj => pick(
|
||||
obj,
|
||||
[ 'id', 'completedDate', 'solution', 'githubLink', 'challengeType', 'files' ]
|
||||
);
|
||||
export const fixCompletedChallengeItem = obj =>
|
||||
pick(obj, [
|
||||
'id',
|
||||
'completedDate',
|
||||
'solution',
|
||||
'githubLink',
|
||||
'challengeType',
|
||||
'files',
|
||||
]);
|
||||
|
@ -88,7 +88,7 @@ module.exports = function(app) {
|
||||
.then(() => {
|
||||
req.flash(
|
||||
'success',
|
||||
"We've successfully updated your email preferences."
|
||||
'We\'ve successfully updated your email preferences.'
|
||||
);
|
||||
return res.redirectWithFlash(
|
||||
`${homeLocation}/unsubscribed/${unsubscribeId}`
|
||||
@ -144,7 +144,7 @@ module.exports = function(app) {
|
||||
.then(() => {
|
||||
req.flash(
|
||||
'success',
|
||||
"We've successfully updated your email preferences. Thank you " +
|
||||
'We\'ve successfully updated your email preferences. Thank you ' +
|
||||
'for resubscribing.'
|
||||
);
|
||||
return res.redirectWithFlash(homeLocation);
|
||||
@ -175,7 +175,7 @@ module.exports = function(app) {
|
||||
}
|
||||
pulls = pulls
|
||||
? Object.keys(JSON.parse(pulls)).length
|
||||
: "Can't connect to github";
|
||||
: 'Can\'t connect to github';
|
||||
|
||||
return request(
|
||||
[
|
||||
@ -193,7 +193,7 @@ module.exports = function(app) {
|
||||
issues =
|
||||
pulls === parseInt(pulls, 10) && issues
|
||||
? Object.keys(JSON.parse(issues)).length - pulls
|
||||
: "Can't connect to GitHub";
|
||||
: 'Can\'t connect to GitHub';
|
||||
return res.send({
|
||||
issues: issues,
|
||||
pulls: pulls
|
||||
|
@ -229,7 +229,7 @@ function createPostReportUserProfile(app) {
|
||||
to: 'team@freecodecamp.org',
|
||||
cc: user.email,
|
||||
from: 'team@freecodecamp.org',
|
||||
subject: 'Abuse Report : Reporting ' + username + "'s profile.",
|
||||
subject: `Abuse Report : Reporting ${username}'s profile.`,
|
||||
text: dedent(`
|
||||
Hello Team,\n
|
||||
This is to report the profile of ${username}.\n
|
||||
|
@ -3,7 +3,7 @@ import helmet from 'helmet';
|
||||
import { homeLocation } from '../../../config/env';
|
||||
|
||||
let trusted = [
|
||||
"'self'",
|
||||
'\'self\'',
|
||||
'https://search.freecodecamp.org',
|
||||
homeLocation,
|
||||
'https://' + process.env.AUTH0_DOMAIN
|
||||
@ -31,8 +31,8 @@ export default function csp() {
|
||||
'https://*.algolia.net'
|
||||
]),
|
||||
scriptSrc: [
|
||||
"'unsafe-eval'",
|
||||
"'unsafe-inline'",
|
||||
'\'unsafe-eval\'',
|
||||
'\'unsafe-inline\'',
|
||||
'*.google-analytics.com',
|
||||
'*.gstatic.com',
|
||||
'https://*.cloudflare.com',
|
||||
@ -48,7 +48,7 @@ export default function csp() {
|
||||
'*.ytimg.com'
|
||||
].concat(trusted),
|
||||
styleSrc: [
|
||||
"'unsafe-inline'",
|
||||
'\'unsafe-inline\'',
|
||||
'*.gstatic.com',
|
||||
'*.googleapis.com',
|
||||
'*.bootstrapcdn.com',
|
||||
|
@ -11,7 +11,7 @@ function getExtract(str) {
|
||||
|
||||
|
||||
function addResponsiveClass(str) {
|
||||
return str.replace(/\<img/g, '<img class="img-responsive"');
|
||||
return str.replace(/<img/g, '<img class="img-responsive"');
|
||||
}
|
||||
|
||||
export function getMediumFeed() {
|
||||
|
@ -25,7 +25,6 @@ export default function userServices() {
|
||||
config,
|
||||
cb) {
|
||||
const queryUser = req.user;
|
||||
console.log(queryUser.completedChallengeCount)
|
||||
const source = queryUser && Observable.forkJoin(
|
||||
queryUser.getCompletedChallenges$(),
|
||||
queryUser.getPoints$(),
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
function getCompletedCertCount(user) {
|
||||
return [
|
||||
'isApisMicroservicesCert',
|
||||
@ -7,15 +6,14 @@ function getCompletedCertCount(user) {
|
||||
'isInfosecQaCert',
|
||||
'isJsAlgoDataStructCert',
|
||||
'isRespWebDesignCert'
|
||||
].reduce((sum, key) => user[key] ? sum + 1 : sum, 0);
|
||||
].reduce((sum, key) => (user[key] ? sum + 1 : sum), 0);
|
||||
}
|
||||
|
||||
function getLegacyCertCount(user) {
|
||||
return [
|
||||
'isFrontEndCert',
|
||||
'isBackEndCert',
|
||||
'isDataVisCert'
|
||||
].reduce((sum, key) => user[key] ? sum + 1 : sum, 0);
|
||||
return ['isFrontEndCert', 'isBackEndCert', 'isDataVisCert'].reduce(
|
||||
(sum, key) => (user[key] ? sum + 1 : sum),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
export default function populateUser(db, user) {
|
||||
@ -24,9 +22,12 @@ export default function populateUser(db, user) {
|
||||
db.collection('user')
|
||||
.aggregate([
|
||||
{ $match: { _id: user.id } },
|
||||
{ $project: { points: { $size: '$progressTimestamps' } } }
|
||||
]).get(function(err, [{ points = 1 } = {}]) {
|
||||
if (err) { return reject(err); }
|
||||
{ $project: { points: { $size: '$progressTimestamps' } } },
|
||||
])
|
||||
.get(function(err, [{ points = 1 } = {}]) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
user.points = points;
|
||||
let completedChallengeCount = 0;
|
||||
let completedProjectCount = 0;
|
||||
|
@ -2,25 +2,25 @@ exports.dasherize = function dasherize(name) {
|
||||
return ('' + name)
|
||||
.toLowerCase()
|
||||
.replace(/\s/g, '-')
|
||||
.replace(/[^a-z0-9\-\.]/gi, '')
|
||||
.replace(/\:/g, '');
|
||||
}
|
||||
.replace(/[^a-z0-9\-.]/gi, '')
|
||||
.replace(/:/g, '');
|
||||
};
|
||||
|
||||
exports.nameify = function nameify(str) {
|
||||
return ('' + str)
|
||||
.replace(/[^a-zA-Z0-9\s]/g, '')
|
||||
.replace(/\:/g, '');
|
||||
}
|
||||
return ('' + str).replace(/[^a-zA-Z0-9\s]/g, '').replace(/:/g, '');
|
||||
};
|
||||
|
||||
exports.unDasherize = function unDasherize(name) {
|
||||
return ('' + name)
|
||||
return (
|
||||
('' + name)
|
||||
// replace dash with space
|
||||
.replace(/\-/g, ' ')
|
||||
.replace(/-/g, ' ')
|
||||
// strip nonalphanumarics chars except whitespace
|
||||
.replace(/[^a-zA-Z\d\s]/g, '')
|
||||
.trim();
|
||||
}
|
||||
.trim()
|
||||
);
|
||||
};
|
||||
|
||||
exports.addPlaceholderImage = function addPlaceholderImage(name) {
|
||||
return `https://identicon.org?t=${name}&s=256`;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user