chore(deps): update dependency prettier to v2.3.0 (#42074)

* chore(deps): update dependency prettier to v2.3.0

* chore: apply formating per prettier

* fix: correctly disable import/no-unresolved

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Mrugesh Mohapatra <hi@mrugesh.dev>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
renovate[bot]
2021-05-10 08:48:49 -07:00
committed by GitHub
parent 66dd85f64a
commit 21dd80c47a
30 changed files with 212 additions and 254 deletions

View File

@ -676,10 +676,8 @@ export default function initializeUser(User) {
const updateData = { $set: {} };
return this.getCompletedChallenges$()
.flatMap(() => {
const {
updated,
isNewCompletionCount
} = buildCompletedChallengesUpdate(this.completedChallenges, project);
const { updated, isNewCompletionCount } =
buildCompletedChallengesUpdate(this.completedChallenges, project);
updateData.$set.completedChallenges = updated;
if (isNewCompletionCount) {
let points = [];
@ -830,12 +828,8 @@ export default function initializeUser(User) {
if (!user) {
return Observable.of({});
}
const {
completedChallenges,
progressTimestamps,
timezone,
profileUI
} = user;
const { completedChallenges, progressTimestamps, timezone, profileUI } =
user;
const allUser = {
..._.pick(user, publicUserProps),
isGithub: !!user.githubProfile,

View File

@ -97,57 +97,54 @@ export const devLoginRedirect = () => {
};
};
export const createPassportCallbackAuthenticator = (strategy, config) => (
req,
res,
next
) => {
return passport.authenticate(
strategy,
{ session: false },
(err, user, userInfo) => {
if (err) {
return next(err);
}
export const createPassportCallbackAuthenticator =
(strategy, config) => (req, res, next) => {
return passport.authenticate(
strategy,
{ session: false },
(err, user, userInfo) => {
if (err) {
return next(err);
}
if (!user || !userInfo) {
return res.redirect('/signin');
}
if (!user || !userInfo) {
return res.redirect('/signin');
}
const { accessToken } = userInfo;
const { provider } = config;
if (accessToken && accessToken.id) {
if (provider === 'auth0') {
req.flash('success', 'flash.signin-success');
} else if (user.email) {
req.flash(
'info',
dedent`
const { accessToken } = userInfo;
const { provider } = config;
if (accessToken && accessToken.id) {
if (provider === 'auth0') {
req.flash('success', 'flash.signin-success');
} else if (user.email) {
req.flash(
'info',
dedent`
We are moving away from social authentication for privacy reasons. Next time
we recommend using your email address: ${user.email} to sign in instead.
`
);
);
}
setAccessTokenToResponse({ accessToken }, req, res);
req.login(user);
}
const state = req && req.query && req.query.state;
// returnTo, origin and pathPrefix are audited by getReturnTo
let { returnTo, origin, pathPrefix } = getReturnTo(state, jwtSecret);
const redirectBase = getRedirectBase(origin, pathPrefix);
// TODO: getReturnTo could return a success flag to show a flash message,
// but currently it immediately gets overwritten by a second message. We
// should either change the message if the flag is present or allow
// multiple messages to appear at once.
if (user.acceptedPrivacyTerms) {
returnTo += isRootPath(redirectBase, returnTo) ? '/learn' : '';
return res.redirectWithFlash(returnTo);
} else {
return res.redirectWithFlash(`${redirectBase}/email-sign-up`);
}
setAccessTokenToResponse({ accessToken }, req, res);
req.login(user);
}
const state = req && req.query && req.query.state;
// returnTo, origin and pathPrefix are audited by getReturnTo
let { returnTo, origin, pathPrefix } = getReturnTo(state, jwtSecret);
const redirectBase = getRedirectBase(origin, pathPrefix);
// TODO: getReturnTo could return a success flag to show a flash message,
// but currently it immediately gets overwritten by a second message. We
// should either change the message if the flag is present or allow
// multiple messages to appear at once.
if (user.acceptedPrivacyTerms) {
returnTo += isRootPath(redirectBase, returnTo) ? '/learn' : '';
return res.redirectWithFlash(returnTo);
} else {
return res.redirectWithFlash(`${redirectBase}/email-sign-up`);
}
}
)(req, res, next);
};
)(req, res, next);
};

View File

@ -53,14 +53,12 @@ export const mockCancellationHook = {
},
links: [
{
href:
'https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-1VF24938EU372274X-83540367M0110254R',
href: 'https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-1VF24938EU372274X-83540367M0110254R',
rel: 'self',
method: 'GET'
},
{
href:
'https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-1VF24938EU372274X-83540367M0110254R/resend',
href: 'https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-1VF24938EU372274X-83540367M0110254R/resend',
rel: 'resend',
method: 'POST'
}
@ -156,32 +154,27 @@ export const mockActivationHook = {
},
links: [
{
href:
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G',
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G',
rel: 'self',
method: 'GET'
},
{
href:
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G',
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G',
rel: 'edit',
method: 'PATCH'
},
{
href:
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/suspend',
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/suspend',
rel: 'suspend',
method: 'POST'
},
{
href:
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/cancel',
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/cancel',
rel: 'cancel',
method: 'POST'
},
{
href:
'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/capture',
href: 'https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/capture',
rel: 'capture',
method: 'POST'
}
@ -194,15 +187,13 @@ export const mockActivationHook = {
},
links: [
{
href:
'https://api.paypal.com/v1/notifications/webhooks-events/WH-77687562XN25889J8-8Y6T55435R66168T6',
href: 'https://api.paypal.com/v1/notifications/webhooks-events/WH-77687562XN25889J8-8Y6T55435R66168T6',
rel: 'self',
method: 'GET',
encType: 'application/json'
},
{
href:
'https://api.paypal.com/v1/notifications/webhooks-events/WH-77687562XN25889J8-8Y6T55435R66168T6/resend',
href: 'https://api.paypal.com/v1/notifications/webhooks-events/WH-77687562XN25889J8-8Y6T55435R66168T6/resend',
rel: 'resend',
method: 'POST',
encType: 'application/json'

View File

@ -17,11 +17,13 @@ export function wrapHandledError(
}
// for use with express-validator error formatter
export const createValidatorErrorFormatter = (type, redirectTo) => ({ msg }) =>
wrapHandledError(new Error(msg), {
type,
message: msg,
redirectTo,
// we default to 400 as these are malformed requests
status: 400
});
export const createValidatorErrorFormatter =
(type, redirectTo) =>
({ msg }) =>
wrapHandledError(new Error(msg), {
type,
message: msg,
redirectTo,
// we default to 400 as these are malformed requests
status: 400
});

View File

@ -24,10 +24,8 @@ jest.mock('axios');
const verificationUrl = `https://api.sandbox.paypal.com/v1/notifications/verify-webhook-signature`;
const tokenUrl = `https://api.sandbox.paypal.com/v1/oauth2/token`;
const {
body: activationHookBody,
headers: activationHookHeaders
} = mockActivationHook;
const { body: activationHookBody, headers: activationHookHeaders } =
mockActivationHook;
describe('donation', () => {
describe('getAsyncPaypalToken', () => {

View File

@ -78,15 +78,17 @@ export function ifUserRedirectTo(status) {
}
// for use with express-validator error formatter
export const createValidatorErrorHandler = (...args) => (req, res, next) => {
const validation = validationResult(req).formatWith(
createValidatorErrorFormatter(...args)
);
export const createValidatorErrorHandler =
(...args) =>
(req, res, next) => {
const validation = validationResult(req).formatWith(
createValidatorErrorFormatter(...args)
);
if (!validation.isEmpty()) {
const errors = validation.array();
return next(errors.pop());
}
if (!validation.isEmpty()) {
const errors = validation.array();
return next(errors.pop());
}
return next();
};
return next();
};

View File

@ -25,10 +25,14 @@ const propTypes = {
showLoading: PropTypes.bool
};
const createRequestedUserSelector = () => (state, { maybeUser = '' }) =>
userByNameSelector(maybeUser.toLowerCase())(state);
const createIsSessionUserSelector = () => (state, { maybeUser = '' }) =>
maybeUser.toLowerCase() === usernameSelector(state);
const createRequestedUserSelector =
() =>
(state, { maybeUser = '' }) =>
userByNameSelector(maybeUser.toLowerCase())(state);
const createIsSessionUserSelector =
() =>
(state, { maybeUser = '' }) =>
maybeUser.toLowerCase() === usernameSelector(state);
const makeMapStateToProps = () => (state, props) => {
const requestedUserSelector = createRequestedUserSelector();

View File

@ -14,15 +14,17 @@ function rendererCreateWithRedux(ui) {
describe('<Intro />', () => {
it('has no blockquotes when loggedOut', () => {
const container = rendererCreateWithRedux(<Intro {...loggedOutProps} />)
.root;
const container = rendererCreateWithRedux(
<Intro {...loggedOutProps} />
).root;
expect(container.findAllByType('blockquote').length === 0).toBeTruthy();
expect(container.findAllByType('h1').length === 1).toBeTruthy();
});
it('has a blockquote when loggedIn', () => {
const container = rendererCreateWithRedux(<Intro {...loggedInProps} />)
.root;
const container = rendererCreateWithRedux(
<Intro {...loggedInProps} />
).root;
expect(container.findAllByType('blockquote').length === 1).toBeTruthy();
expect(container.findAllByType('h1').length === 1).toBeTruthy();
});

View File

@ -21,13 +21,8 @@ const propTypes = {
};
const ProjectModal = props => {
const {
isOpen,
projectTitle,
files,
solution,
handleSolutionModalHide
} = props;
const { isOpen, projectTitle, files, solution, handleSolutionModalHide } =
props;
const { t } = useTranslation();
return (
<Modal

View File

@ -1,10 +1,12 @@
import { navigate } from 'gatsby';
const createRedirect = (to = '/') => () => {
if (typeof window !== 'undefined') {
navigate(to);
}
return null;
};
const createRedirect =
(to = '/') =>
() => {
if (typeof window !== 'undefined') {
navigate(to);
}
return null;
};
export default createRedirect;

View File

@ -2,8 +2,10 @@ import React from 'react';
import { Trans } from 'react-i18next';
// Matches editor links for: Replit, Glitch, CodeSandbox, GitHub
const editorRegex = /repl\.?it(\.com)?\/(@|join\/)|glitch\.com\/edit\/#!|codesandbox\.io\/s\/|github\.com/;
const fCCRegex = /codepen\.io\/freecodecamp|freecodecamp\.rocks|github\.com\/freecodecamp/i;
const editorRegex =
/repl\.?it(\.com)?\/(@|join\/)|glitch\.com\/edit\/#!|codesandbox\.io\/s\/|github\.com/;
const fCCRegex =
/codepen\.io\/freecodecamp|freecodecamp\.rocks|github\.com\/freecodecamp/i;
const localhostRegex = /localhost:/;
const httpRegex = /http(?!s|([^s]+?localhost))/;
@ -21,5 +23,7 @@ export const localhostValidator = value =>
export const httpValidator = value =>
httpRegex.test(value) ? <Trans>validation.http-url</Trans> : null;
export const composeValidators = (...validators) => value =>
validators.reduce((error, validator) => error ?? validator?.(value), null);
export const composeValidators =
(...validators) =>
value =>
validators.reduce((error, validator) => error ?? validator?.(value), null);

View File

@ -285,13 +285,8 @@ export class CertificationSettings extends Component {
);
};
renderProjectsFor = (certName, isCert) => {
const {
username,
isHonest,
createFlashMessage,
t,
verifyCert
} = this.props;
const { username, isHonest, createFlashMessage, t, verifyCert } =
this.props;
const { certSlug } = first(projectMap[certName]);
const certLocation = `/certification/${username}/${certSlug}`;
const createClickHandler = certSlug => e => {
@ -332,12 +327,8 @@ export class CertificationSettings extends Component {
// legacy projects rendering
handleSubmitLegacy({ values: formChalObj }) {
const {
isHonest,
createFlashMessage,
verifyCert,
updateLegacyCert
} = this.props;
const { isHonest, createFlashMessage, verifyCert, updateLegacyCert } =
this.props;
let legacyTitle;
let certSlug;
let certs = Object.keys(legacyProjectMap);

View File

@ -141,17 +141,11 @@ class EmailSettings extends Component {
emailForm: { newEmail, confirmNewEmail, currentEmail, isPristine }
} = this.state;
const {
isEmailVerified,
updateQuincyEmail,
sendQuincyEmail,
t
} = this.props;
const { isEmailVerified, updateQuincyEmail, sendQuincyEmail, t } =
this.props;
const {
state: newEmailValidation,
message: newEmailValidationMessage
} = this.getValidationForNewEmail();
const { state: newEmailValidation, message: newEmailValidationMessage } =
this.getValidationForNewEmail();
const {
state: confirmEmailValidation,

View File

@ -165,20 +165,14 @@ class InternetSettings extends Component {
message: githubProfileValidationMessage
} = this.getValidationStateFor(githubProfile);
const {
state: linkedinValidation,
message: linkedinValidationMessage
} = this.getValidationStateFor(linkedin);
const { state: linkedinValidation, message: linkedinValidationMessage } =
this.getValidationStateFor(linkedin);
const {
state: twitterValidation,
message: twitterValidationMessage
} = this.getValidationStateFor(twitter);
const { state: twitterValidation, message: twitterValidationMessage } =
this.getValidationStateFor(twitter);
const {
state: websiteValidation,
message: websiteValidationMessage
} = this.getValidationStateFor(website);
const { state: websiteValidation, message: websiteValidationMessage } =
this.getValidationStateFor(website);
return (
<Fragment>

View File

@ -123,9 +123,8 @@ class PortfolioSettings extends Component {
const { state: titleState } = this.getTitleValidation(title);
const { state: urlState } = this.getUrlValidation(url);
const { state: imageState } = this.getUrlValidation(image, true);
const { state: descriptionState } = this.getDescriptionValidation(
description
);
const { state: descriptionState } =
this.getDescriptionValidation(description);
return [titleState, imageState, urlState, descriptionState]
.filter(Boolean)
.every(state => state === 'success');
@ -192,19 +191,15 @@ class PortfolioSettings extends Component {
const { t } = this.props;
const { id, title, description, url, image } = portfolio;
const pristine = this.isFormPristine(id);
const {
state: titleState,
message: titleMessage
} = this.getTitleValidation(title);
const { state: titleState, message: titleMessage } =
this.getTitleValidation(title);
const { state: urlState, message: urlMessage } = this.getUrlValidation(url);
const { state: imageState, message: imageMessage } = this.getUrlValidation(
image,
true
);
const {
state: descriptionState,
message: descriptionMessage
} = this.getDescriptionValidation(description);
const { state: descriptionState, message: descriptionMessage } =
this.getDescriptionValidation(description);
return (
<div key={id}>

View File

@ -206,13 +206,8 @@ class ShowClassic extends Component {
}
renderInstructionsPanel({ showToolPanel }) {
const {
block,
description,
instructions,
superBlock,
translationPending
} = this.getChallenge();
const { block, description, instructions, superBlock, translationPending } =
this.getChallenge();
const { forumTopicId, title } = this.getChallenge();
return (

View File

@ -32,9 +32,8 @@ function createQuestionEpic(action$, state$, { window }) {
tap(() => {
const state = state$.value;
const files = challengeFilesSelector(state);
const { title: challengeTitle, helpCategory } = challengeMetaSelector(
state
);
const { title: challengeTitle, helpCategory } =
challengeMetaSelector(state);
const {
navigator: { userAgent },
location: { href }

View File

@ -74,9 +74,9 @@ export function* executeChallengeSaga({
yield put(initLogs());
yield put(initConsole(i18next.t('learn.running-tests')));
// reset tests to initial state
const tests = (yield select(
challengeTestsSelector
)).map(({ text, testString }) => ({ text, testString }));
const tests = (yield select(challengeTestsSelector)).map(
({ text, testString }) => ({ text, testString })
);
yield put(updateTests(tests));
yield fork(takeEveryLog, consoleProxy);

View File

@ -67,22 +67,24 @@ const createFrame = (document, id) => ctx => {
};
const hiddenFrameClassName = 'hide-test-frame';
const mountFrame = document => ({ element, ...rest }) => {
const oldFrame = document.getElementById(element.id);
if (oldFrame) {
element.className = oldFrame.className || hiddenFrameClassName;
oldFrame.parentNode.replaceChild(element, oldFrame);
} else {
element.className = hiddenFrameClassName;
document.body.appendChild(element);
}
return {
...rest,
element,
document: element.contentDocument,
window: element.contentWindow
const mountFrame =
document =>
({ element, ...rest }) => {
const oldFrame = document.getElementById(element.id);
if (oldFrame) {
element.className = oldFrame.className || hiddenFrameClassName;
oldFrame.parentNode.replaceChild(element, oldFrame);
} else {
element.className = hiddenFrameClassName;
document.body.appendChild(element);
}
return {
...rest,
element,
document: element.contentDocument,
window: element.contentWindow
};
};
};
const buildProxyConsole = proxyLogger => ctx => {
const oldLog = ctx.window.console.log.bind(ctx.window.console);

View File

@ -20,9 +20,11 @@ const CertificationCard = ({ certSlug, superBlock, i18nCertText }) => {
setIsExpanded(!isExpanded);
};
const { expand: expandText, collapse: collapseText, steps: stepsText } = t(
'intro:misc-text'
);
const {
expand: expandText,
collapse: collapseText,
steps: stepsText
} = t('intro:misc-text');
return (
<ScrollableAnchor id='claim-cert-block'>
<div className={`block ${isExpanded ? 'open' : ''}`}>

View File

@ -14,10 +14,8 @@ function SuperBlockIntro(props) {
const { superBlock } = props;
const superBlockIntroObj = t(`intro:${superBlock}`);
const {
title: i18nSuperBlock,
intro: superBlockIntroText
} = superBlockIntroObj;
const { title: i18nSuperBlock, intro: superBlockIntroText } =
superBlockIntroObj;
return (
<>

View File

@ -8,10 +8,8 @@ import htmlTestValues from './__fixtures/curriculum-helpers-html';
import whiteSpaceTestValues from './__fixtures/curriculum-helpers-remove-white-space';
/* eslint-enable max-len */
const {
stringWithWhiteSpaceChars,
stringWithWhiteSpaceCharsRemoved
} = whiteSpaceTestValues;
const { stringWithWhiteSpaceChars, stringWithWhiteSpaceCharsRemoved } =
whiteSpaceTestValues;
const { cssFullExample, cssCodeWithCommentsRemoved } = cssTestValues;

View File

@ -49,36 +49,38 @@ const getPrevChallengePath = (node, index, nodeArray) => {
const getTemplateComponent = challengeType => views[viewTypes[challengeType]];
exports.createChallengePages = createPage => ({ node }, index, thisArray) => {
const {
superBlock,
block,
fields: { slug },
required = [],
template,
challengeType,
id
} = node;
// TODO: challengeType === 7 and isPrivate are the same, right? If so, we
// should remove one of them.
exports.createChallengePages =
createPage =>
({ node }, index, thisArray) => {
const {
superBlock,
block,
fields: { slug },
required = [],
template,
challengeType,
id
} = node;
// TODO: challengeType === 7 and isPrivate are the same, right? If so, we
// should remove one of them.
return createPage({
path: slug,
component: getTemplateComponent(challengeType),
context: {
challengeMeta: {
superBlock,
block,
template,
required,
nextChallengePath: getNextChallengePath(node, index, thisArray),
prevChallengePath: getPrevChallengePath(node, index, thisArray),
id
},
slug
}
});
};
return createPage({
path: slug,
component: getTemplateComponent(challengeType),
context: {
challengeMeta: {
superBlock,
block,
template,
required,
nextChallengePath: getNextChallengePath(node, index, thisArray),
prevChallengePath: getPrevChallengePath(node, index, thisArray),
id
},
slug
}
});
};
exports.createBlockIntroPages = createPage => edge => {
const {

View File

@ -15,9 +15,8 @@ const { isAuditedCert } = require('../utils/is-audited');
const { dasherize } = require('../utils/slugs');
const { createPoly } = require('../utils/polyvinyl');
const { helpCategoryMap } = require('../client/utils/challengeTypes');
const {
curriculum: curriculumLangs
} = require('../config/i18n/all-langs').availableLangs;
const { curriculum: curriculumLangs } =
require('../config/i18n/all-langs').availableLangs;
const access = util.promisify(fs.access);

View File

@ -68,9 +68,10 @@ const TRANSLATABLE_COMMENTS = getTranslatableComments(
);
// the config files are created during the build, but not before linting
// eslint-disable-next-line import/no-unresolved
const testEvaluator = require('../../config/client/test-evaluator.json')
.filename;
/* eslint-disable import/no-unresolved */
const testEvaluator =
require('../../config/client/test-evaluator.json').filename;
/* eslint-enable import/no-unresolved */
const { inspect } = require('util');
const commentExtractors = {

View File

@ -1,9 +1,8 @@
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
const {
curriculum: curriculumLangs
} = require('../config/i18n/all-langs').availableLangs;
const { curriculum: curriculumLangs } =
require('../config/i18n/all-langs').availableLangs;
exports.testedLang = function testedLang() {
if (process.env.CURRICULUM_LOCALE) {

View File

@ -20,8 +20,7 @@ describe('The Document Metadata', () => {
const scripts = {
mathjax: {
selector: 'body script[id="mathjax"]',
src:
'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML'
src: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML'
}
};
it('landing page has correct <meta> for description', () => {

6
package-lock.json generated
View File

@ -16457,9 +16457,9 @@
"dev": true
},
"prettier": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz",
"integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==",
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.0.tgz",
"integrity": "sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==",
"dev": true
},
"prettier-linter-helpers": {

View File

@ -117,7 +117,7 @@
"markdownlint": "0.21.0",
"npm-run-all": "4.1.5",
"ora": "5.4.0",
"prettier": "2.2.1",
"prettier": "2.3.0",
"prismjs": "1.23.0",
"shx": "0.3.3",
"sinon": "10.0.0",

View File

@ -44,9 +44,8 @@ const hideNonTranslatedStrings = async projectId => {
const crowdinStrings = await getStrings({ projectId });
if (crowdinStrings && crowdinStrings.length) {
for (let string of crowdinStrings) {
const { crowdinFilePath, challengeTitle } = challengeTitleLookup[
string.data.fileId
];
const { crowdinFilePath, challengeTitle } =
challengeTitleLookup[string.data.fileId];
await updateFileString({
projectId,
string,