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 -3
View File
@@ -16,7 +16,5 @@ module.exports = {
transform: {
'^.+\\.js$': '<rootDir>/jest.transform.js'
},
transformIgnorePatterns: [
'node_modules/(?!(gatsby)/)'
]
transformIgnorePatterns: ['node_modules/(?!(gatsby)/)']
};
+3 -5
View File
@@ -1,12 +1,10 @@
const babelOptions = {
presets: [
'@babel/preset-env',
'@babel/react'
],
presets: ['@babel/preset-env', '@babel/react'],
plugins: [
'@babel/plugin-proposal-function-bind',
[
'transform-imports', {
'transform-imports',
{
'@freecodecamp/react-bootstrap': {
transform: '@freecodecamp/react-bootstrap/lib/${member}',
preventFullImport: true
@@ -29,7 +29,10 @@ exports.createNavigationNode = function createNavigationNode(node) {
const nodeDir = path.resolve(fileAbsolutePath).replace(indexMdRe, '');
const dashedName = nodeDir.split(path.sep).slice(-1)[0];
const nodePath = nodeDir.split(pagesDir)[1].split(path.sep).join('/');
const nodePath = nodeDir
.split(pagesDir)[1]
.split(path.sep)
.join('/');
const parentPath = nodePath
.split('/')
.slice(0, -1)
@@ -33,15 +33,9 @@ function DonateCompletion({ processing, reset, success, error = null }) {
/>
)}
{success && (
<p>
Thank you for supporting the freeCodeCamp.org community.
</p>
)}
{error && (
<p>
{error}
</p>
<p>Thank you for supporting the freeCodeCamp.org community.</p>
)}
{error && <p>{error}</p>}
</div>
<p className='donation-completion-buttons'>
{error && (
@@ -20,10 +20,9 @@ import DonateText from './DonateText';
import '../Donation.css';
const mapStateToProps = createSelector(
isDonationModalOpenSelector,
show => ({ show })
);
const mapStateToProps = createSelector(isDonationModalOpenSelector, show => ({
show
}));
const mapDispatchToProps = dispatch =>
bindActionCreators(
@@ -73,7 +72,9 @@ class DonateModal extends Component {
};
return (
<div className='modal-close-btn-container'>
<Button bsStyle='link' onClick={handleClick}>Close</Button>
<Button bsStyle='link' onClick={handleClick}>
Close
</Button>
</div>
);
}
@@ -84,25 +85,25 @@ class DonateModal extends Component {
ga.modalview('/donation-modal');
}
return (
<StripeProvider stripe={this.state.stripe}>
<Elements>
<Modal bsSize='lg' className='donation-modal' show={show}>
<Modal.Header className='fcc-modal'>
<Modal.Title className='text-center'>
Support Our NonProfit
</Modal.Title>
</Modal.Header>
<Modal.Body>
<DonateText />
<DonateForm />
{this.renderMaybe()}
</Modal.Body>
<Modal.Footer>
<StripeProvider stripe={this.state.stripe}>
<Elements>
<Modal bsSize='lg' className='donation-modal' show={show}>
<Modal.Header className='fcc-modal'>
<Modal.Title className='text-center'>
Support Our NonProfit
</Modal.Title>
</Modal.Header>
<Modal.Body>
<DonateText />
<DonateForm />
{this.renderMaybe()}
</Modal.Body>
<Modal.Footer>
<PoweredByStripe />
</Modal.Footer>
</Modal>
</Elements>
</StripeProvider>
</Modal.Footer>
</Modal>
</Elements>
</StripeProvider>
);
}
}
@@ -19,15 +19,14 @@ const DonateText = ({ activeDonations }) => {
return (
<div className='text-center'>
<p>
freeCodeCamp.org is a tiny nonprofit that's helping millions of
people learn to code for free.
freeCodeCamp.org is a tiny nonprofit that's helping millions of people
learn to code for free.
</p>
<p>
Join <strong>{donationsLocale}</strong> supporters.
</p>
<p>
Your $5 / month donation will help keep tech education free and
open.
Your $5 / month donation will help keep tech education free and open.
</p>
</div>
);
@@ -77,9 +77,7 @@ class StripeCardForm extends Component {
return (
<div className='donation-elements'>
<FormGroup>
<ControlLabel>
Your Card Number:
</ControlLabel>
<ControlLabel>Your Card Number:</ControlLabel>
<CardNumberElement
className='form-control donate-input-element'
onChange={this.handleInputChange}
@@ -87,9 +85,7 @@ class StripeCardForm extends Component {
/>
</FormGroup>
<FormGroup>
<ControlLabel>
Your Card Expiration Month:
</ControlLabel>
<ControlLabel>Your Card Expiration Month:</ControlLabel>
<CardExpiryElement
className='form-control donate-input-element'
onChange={this.handleInputChange}
@@ -97,9 +93,7 @@ class StripeCardForm extends Component {
/>
</FormGroup>
<FormGroup>
<ControlLabel>
Your Card CVC (3-digit security number):
</ControlLabel>
<ControlLabel>Your Card CVC (3-digit security number):</ControlLabel>
<CardCVCElement
className='form-control donate-input-element'
onChange={this.handleInputChange}
+2 -6
View File
@@ -96,12 +96,8 @@ function Footer() {
</Col>
<Col lg={3} sm={2} xs={12}>
<ColHeader>Our Learning Resources</ColHeader>
<Link to='/learn'>
Learn
</Link>
<Link to='/guide'>
Guide
</Link>
<Link to='/learn'>Learn</Link>
<Link to='/guide'>Guide</Link>
<Link to='https://www.youtube.com/freecodecamp'>Youtube</Link>
<Link to='https://podcast.freecodecamp.org'>Podcast</Link>
<Link to='https://twitter.com/freecodecamp'>Twitter</Link>
@@ -154,4 +154,7 @@ export class Block extends Component {
Block.displayName = 'Block';
Block.propTypes = propTypes;
export default connect(mapStateToProps, mapDispatchToProps)(Block);
export default connect(
mapStateToProps,
mapDispatchToProps
)(Block);
+3 -1
View File
@@ -33,7 +33,9 @@ export function DynamicForm({
errors,
fields,
handleSubmit,
fields: { _meta: { allPristine } },
fields: {
_meta: { allPristine }
},
// HOC
buttonText,
+1 -1
View File
@@ -166,7 +166,7 @@ class DefaultLayout extends Component {
) : null}
{children}
</div>
{showFooter && (<Footer />)}
{showFooter && <Footer />}
</Fragment>
);
}
@@ -67,7 +67,9 @@ class NavPanel extends Component {
'caret ' + (isExpanded ? 'caretStyle expanded' : 'caretStyle')
}
/>
<Link onClick={this.handleTitleClick} to={path}>{title}</Link>
<Link onClick={this.handleTitleClick} to={path}>
{title}
</Link>
</div>
);
}
+157 -124
View File
@@ -8,32 +8,38 @@ import ReactGA from '../analytics/index.js';
import Spacer from '../components/helpers/Spacer';
const paypalMonthlyDonations = [
{ eventLabel: 'paypal',
{
eventLabel: 'paypal',
eventValue: 5,
defaultValueHash: 'KTAXU8B4MYAT8',
defaultValue: 'Donate $5 each month'
},
{ eventLabel: 'paypal',
{
eventLabel: 'paypal',
eventValue: 10,
defaultValueHash: 'BYEBQEHS5LHNC',
defaultValue: 'Donate $10 each month'
},
{ eventLabel: 'paypal',
{
eventLabel: 'paypal',
eventValue: 35,
defaultValueHash: '57ZPMKJ8G893Y',
defaultValue: 'Donate $35 each month'
},
{ eventLabel: 'paypal',
{
eventLabel: 'paypal',
eventValue: 50,
defaultValueHash: '2ZVYTHK6Q7AFW',
defaultValue: 'Donate $50 each month'
},
{ eventLabel: 'paypal',
{
eventLabel: 'paypal',
eventValue: 100,
defaultValueHash: 'C7PUT3LMJHKK2',
defaultValue: 'Donate $100 each month'
},
{ eventLabel: 'paypal',
{
eventLabel: 'paypal',
eventValue: 250,
defaultValueHash: '69JGTY4DHSTEN',
defaultValue: 'Donate $250 each month'
@@ -48,13 +54,19 @@ const paypalOneTimeDonation = {
};
class DonateOtherPage extends Component {
renderForm(item) {
return (
<form
action='https://www.paypal.com/cgi-bin/webscr'
method='post'
onSubmit={() => ReactGA.event({category: 'donation', action: 'click', label: item.eventLabel, value: item.eventValue})}
onSubmit={() =>
ReactGA.event({
category: 'donation',
action: 'click',
label: item.eventLabel,
value: item.eventValue
})
}
target='_blank'
>
<input defaultValue='_s-xclick' name='cmd' type='hidden' />{' '}
@@ -74,122 +86,143 @@ class DonateOtherPage extends Component {
}
render() {
return (
<Fragment>
<Helmet title='Other ways to donate | freeCodeCamp.org' />
<Spacer />
<Grid className='container'>
<Row>
<Col md={6} mdOffset={3} sm={10} smOffset={1} xs={12}>
<h2 className='text-center'>
Other ways you can support the freeCodeCamp.org nonprofit
</h2>
<p>
freeCodeCamp is a small donor-supported 501(c)(3) public charity. We
are tax-exempt, so you can deduct donations you make to our
nonprofit from your taxes. You can{' '}
<a href='https://s3.amazonaws.com/freecodecamp/Free+Code+Camp+Inc+IRS+Determination+Letter.pdf'>
download our IRS Determination Letter here
</a>.
</p>
<hr />
<h3>Set up a monthly donation using PayPal</h3>
<p>
You can set up a monthly donation to freeCodeCamp by clicking one of
the links below and following the instructions on PayPal. You can
easily stop your donations at any time in the future.
</p>
{paypalMonthlyDonations.map((item) => {
return this.renderForm(item);
})}
<hr />
<h3>Make a one-time donation using PayPal</h3>
<p>
You can make a one-time monthly donation to freeCodeCamp for any
amount of money by clicking one of the links below and following the
instructions on PayPal:
</p>
{this.renderForm(paypalOneTimeDonation)}
<hr />
<h3>Get your employer to match your donation</h3>
<p>
Many freeCodeCamp supporters are able to get their employers to
match their donations to freeCodeCamp. Our Tax-exempt number (EIN)
is 82-0779546. If we can help you with setting this up, please email{' '}
<a href='mailto:team@freecodecamp.org'>team@freecodecamp.org</a>.
</p>
<hr />
<h3>Donate through a payroll deduction</h3>
<p>
In the US and Canada, some employers have a convenient way to give
to freeCodeCamp through a payroll deduction. Ask your employer if
they can do this, and have them send any necessary paperwork to:
</p>
<p>
Free Code Camp, Inc.<br />7800 W Hefner Rd, PO BOX 721024<br />Oklahoma
City, Oklahoma 73172<br />United States
</p>
<hr />
<h3>Donate cryptocurrency to freeCodeCamp</h3>
<p>
Below are our wallets where we can receive cryptocurrency donations.
</p>
<h4>Make a one-time Bitcoin donation</h4>
<p className='negative-15'>
Our Bitcoin wallet is{' '}
<code>12skYi7aMCjDUdrVdoB3JjZ77ug8gxJfbL</code>
</p>
<h4>Make a one-time Ethereum donation</h4>
<p className='negative-15'>
Our Ethereum wallet is{' '}
<code>0x0ADbEf2471416BD8732cf0f3944294eE393CcAF5</code>
</p>
<h4>Make a one-time Litecoin donation</h4>
<p className='negative-15'>
Our Litecoin wallet is{' '}
<code>LKu8UG8Z1nbTxnq9Do96PsC3FwbNtycf3X</code>
</p>
<h4>Make a one-time Bitcoin Cash donation</h4>
<p className='negative-15'>
Our Bitcoin Cash wallet is{' '}
<code>1EBxPEJWrGZWxe2UayyAsnd5VsRg5H9xfu</code>
</p>
<hr />
<h3>Donate to freeCodeCamp by mailing us a check</h3>
<p>Our mailing address is:</p>
<p>
Free Code Camp, Inc.<br />7800 W Hefner Rd, PO BOX 721024<br />Oklahoma
City, Oklahoma 73172<br />United States
</p>
<hr />
<h3>Donate Stock to freeCodeCamp</h3>
<p>
If you want to donate stocks to freeCodeCamp, please email us at{' '}
<a href='mailto:team@freecodecamp.org'>team@freecodecamp.org</a>.
</p>
<hr />
<h3>Legacy Gift</h3>
<p>
You can help future generations of learners by listing freeCodeCamp
in your will or living trust. If you're interested in doing this,
email Quincy directly and we can discuss this:{' '}
<a href='mailto:quincy@freecodecamp.org'>quincy@freecodecamp.org</a>.
</p>
<hr />
<h3>
Thank you for supporting our nonprofit and the freeCodeCamp
community.
</h3>
<Spacer />
<div className='text-center'>
<Link to='/donate'>Or donate using a Credit or Debit Card.</Link>
</div>
<Spacer />
</Col>
</Row>
</Grid>
</Fragment>
);
return (
<Fragment>
<Helmet title='Other ways to donate | freeCodeCamp.org' />
<Spacer />
<Grid className='container'>
<Row>
<Col md={6} mdOffset={3} sm={10} smOffset={1} xs={12}>
<h2 className='text-center'>
Other ways you can support the freeCodeCamp.org nonprofit
</h2>
<p>
freeCodeCamp is a small donor-supported 501(c)(3) public
charity. We are tax-exempt, so you can deduct donations you make
to our nonprofit from your taxes. You can{' '}
<a href='https://s3.amazonaws.com/freecodecamp/Free+Code+Camp+Inc+IRS+Determination+Letter.pdf'>
download our IRS Determination Letter here
</a>
.
</p>
<hr />
<h3>Set up a monthly donation using PayPal</h3>
<p>
You can set up a monthly donation to freeCodeCamp by clicking
one of the links below and following the instructions on PayPal.
You can easily stop your donations at any time in the future.
</p>
{paypalMonthlyDonations.map(item => {
return this.renderForm(item);
})}
<hr />
<h3>Make a one-time donation using PayPal</h3>
<p>
You can make a one-time monthly donation to freeCodeCamp for any
amount of money by clicking one of the links below and following
the instructions on PayPal:
</p>
{this.renderForm(paypalOneTimeDonation)}
<hr />
<h3>Get your employer to match your donation</h3>
<p>
Many freeCodeCamp supporters are able to get their employers to
match their donations to freeCodeCamp. Our Tax-exempt number
(EIN) is 82-0779546. If we can help you with setting this up,
please email{' '}
<a href='mailto:team@freecodecamp.org'>team@freecodecamp.org</a>
.
</p>
<hr />
<h3>Donate through a payroll deduction</h3>
<p>
In the US and Canada, some employers have a convenient way to
give to freeCodeCamp through a payroll deduction. Ask your
employer if they can do this, and have them send any necessary
paperwork to:
</p>
<p>
Free Code Camp, Inc.
<br />
7800 W Hefner Rd, PO BOX 721024
<br />
Oklahoma City, Oklahoma 73172
<br />
United States
</p>
<hr />
<h3>Donate cryptocurrency to freeCodeCamp</h3>
<p>
Below are our wallets where we can receive cryptocurrency
donations.
</p>
<h4>Make a one-time Bitcoin donation</h4>
<p className='negative-15'>
Our Bitcoin wallet is{' '}
<code>12skYi7aMCjDUdrVdoB3JjZ77ug8gxJfbL</code>
</p>
<h4>Make a one-time Ethereum donation</h4>
<p className='negative-15'>
Our Ethereum wallet is{' '}
<code>0x0ADbEf2471416BD8732cf0f3944294eE393CcAF5</code>
</p>
<h4>Make a one-time Litecoin donation</h4>
<p className='negative-15'>
Our Litecoin wallet is{' '}
<code>LKu8UG8Z1nbTxnq9Do96PsC3FwbNtycf3X</code>
</p>
<h4>Make a one-time Bitcoin Cash donation</h4>
<p className='negative-15'>
Our Bitcoin Cash wallet is{' '}
<code>1EBxPEJWrGZWxe2UayyAsnd5VsRg5H9xfu</code>
</p>
<hr />
<h3>Donate to freeCodeCamp by mailing us a check</h3>
<p>Our mailing address is:</p>
<p>
Free Code Camp, Inc.
<br />
7800 W Hefner Rd, PO BOX 721024
<br />
Oklahoma City, Oklahoma 73172
<br />
United States
</p>
<hr />
<h3>Donate Stock to freeCodeCamp</h3>
<p>
If you want to donate stocks to freeCodeCamp, please email us at{' '}
<a href='mailto:team@freecodecamp.org'>team@freecodecamp.org</a>
.
</p>
<hr />
<h3>Legacy Gift</h3>
<p>
You can help future generations of learners by listing
freeCodeCamp in your will or living trust. If you're interested
in doing this, email Quincy directly and we can discuss this:{' '}
<a href='mailto:quincy@freecodecamp.org'>
quincy@freecodecamp.org
</a>
.
</p>
<hr />
<h3>
Thank you for supporting our nonprofit and the freeCodeCamp
community.
</h3>
<Spacer />
<div className='text-center'>
<Link to='/donate'>
Or donate using a Credit or Debit Card.
</Link>
</div>
<Spacer />
</Col>
</Row>
</Grid>
</Fragment>
);
}
}
+1 -3
View File
@@ -60,9 +60,7 @@ class DonatePage extends Component {
<Spacer />
<Row>
<Col sm={8} smOffset={2} xs={12}>
<h2 className='text-center'>
Become a Supporter
</h2>
<h2 className='text-center'>Become a Supporter</h2>
<DonateText />
</Col>
<Col sm={6} smOffset={3} xs={12}>
+1 -3
View File
@@ -85,9 +85,7 @@ export const query = graphql`
slug
}
}
allChallengeNode(
sort: { fields: [superOrder, order, challengeOrder] }
) {
allChallengeNode(sort: { fields: [superOrder, order, challengeOrder] }) {
edges {
node {
fields {
+1 -1
View File
@@ -16,7 +16,7 @@ function setTheme(currentTheme = defaultTheme, theme) {
html.classList.add(theme);
}
function* updateLocalThemeSaga({ payload: {user, theme } }) {
function* updateLocalThemeSaga({ payload: { user, theme } }) {
const currentTheme = store.get(themeKey) || defaultTheme;
if (user) {
const { theme = defaultTheme } = user;
+1 -6
View File
@@ -6,10 +6,5 @@ import { sagas as challengeSagas } from '../templates/Challenges/redux';
import { sagas as settingsSagas } from './settings';
export default function* rootSaga() {
yield all([
...errorSagas,
...appSagas,
...challengeSagas,
...settingsSagas
]);
yield all([...errorSagas, ...appSagas, ...challengeSagas, ...settingsSagas]);
}
@@ -170,7 +170,7 @@ export class BackEnd extends Component {
<LearnLayout>
<Grid>
<Row>
<Col md={8} mdOffset={2} sm={10} smOffset={1} xs={12} >
<Col md={8} mdOffset={2} sm={10} smOffset={1} xs={12}>
<Spacer />
<ChallengeTitle>{blockNameTitle}</ChallengeTitle>
<ChallengeDescription
@@ -10,8 +10,9 @@ const propTypes = {
};
function emptyInstruction(instructions) {
return (/^<section\s+id\s*=\s*("|')instructions\1\s*>\s*<\/section>$/)
.test(instructions);
return (/^<section\s+id\s*=\s*("|')instructions\1\s*>\s*<\/section>$/).test(
instructions
);
}
function ChallengeDescription({ description, instructions, section }) {
@@ -73,4 +73,7 @@ function ResetModal({ reset, close, isOpen }) {
ResetModal.displayName = 'ResetModal';
ResetModal.propTypes = propTypes;
export default connect(mapStateToProps, mapDispatchToProps)(ResetModal);
export default connect(
mapStateToProps,
mapDispatchToProps
)(ResetModal);
@@ -41,9 +41,11 @@ function ToolPanel({
}) {
return (
<Fragment>
<div className={`tool-panel-group ${
<div
className={`tool-panel-group ${
isMobile ? 'tool-panel-group-mobile' : ''
}`}>
}`}
>
<Button block={true} bsStyle='primary' onClick={executeChallenge}>
{isMobile ? 'Run' : 'Run the Tests'}
</Button>
@@ -92,7 +94,10 @@ function ToolPanel({
ToolPanel.displayName = 'ToolPanel';
ToolPanel.propTypes = propTypes;
export default connect(mapStateToProps, mapDispatchToProps)(ToolPanel);
export default connect(
mapStateToProps,
mapDispatchToProps
)(ToolPanel);
/*
<Button
@@ -89,7 +89,9 @@ export class ProjectForm extends Component {
}
}
handleSubmit(values) {
const { keysDown: { Control, Enter } } = this.state;
const {
keysDown: { Control, Enter }
} = this.state;
if ((Control && Enter) || !Enter) {
this.props.openModal('completion');
this.props.updateProjectForm(values);
@@ -55,35 +55,8 @@ export class ToolPanel extends Component {
ToolPanel.displayName = 'ProjectToolPanel';
ToolPanel.propTypes = propTypes;
export default connect(mapStateToProps, mapDispatchToProps)(ToolPanel);
export default connect(
mapStateToProps,
mapDispatchToProps
)(ToolPanel);
/**
*
* <Fragment>
<ProjectForm isFrontEnd={isFrontEnd} openModal={openCompletionModal} />
<ButtonSpacer />
{guideUrl && (
<Fragment>
<Button
block={true}
bsStyle='primary'
className='btn-primary-ghost btn-big'
href={guideUrl}
target='_blank'
>
Get a hint
</Button>
<ButtonSpacer />
</Fragment>
)}
<Button
block={true}
bsStyle='primary'
className='btn-primary-ghost btn-big'
onClick={openHelpModal}
>
Ask for help on the forum
</Button>
<ButtonSpacer />
</Fragment>
*/
@@ -1,4 +1,4 @@
import {cond, identity, stubTrue, conforms} from 'lodash';
import { cond, identity, stubTrue, conforms } from 'lodash';
const HTML$JSReg = /html|js/;
@@ -46,9 +46,7 @@ export const testJS$JSX = overSome(testJS, testJSX);
export const replaceNBSP = cond([
[
testHTML$JS$JSX,
partial(vinyl.transformContents, contents =>
contents.replace(NBSPReg, ' ')
)
partial(vinyl.transformContents, contents => contents.replace(NBSPReg, ' '))
],
[stubTrue, identity]
]);
@@ -3,7 +3,10 @@ import { ofType } from 'redux-observable';
import { types, unlockCode } from './';
function codeLockEpic(action$) {
return action$.pipe(ofType(types.updateFile), map(unlockCode));
return action$.pipe(
ofType(types.updateFile),
map(unlockCode)
);
}
export default codeLockEpic;
@@ -7,16 +7,12 @@ function* fetchIdToNameMapSaga() {
try {
const { data } = yield call(getIdToNameMap);
yield put(
fetchIdToNameMapComplete(data)
);
yield put(fetchIdToNameMapComplete(data));
} catch (e) {
yield put(fetchIdToNameMapError(e));
}
}
export function createIdToNameMapSaga(types) {
return [
takeEvery(types.fetchIdToNameMap, fetchIdToNameMapSaga)
];
return [takeEvery(types.fetchIdToNameMap, fetchIdToNameMapSaga)];
}
@@ -58,7 +58,6 @@ export function createFetchLink() {
}
const link = await axios
.get({ url: href, crossDomain })
.then(thing => { console.log(thing); return thing;})
.then(res => {
if (res.status !== 200) {
throw new Error('Request error: ' + res.status);
@@ -67,7 +66,7 @@ export function createFetchLink() {
.then(({ data }) => data)
.then(styles => `<style>${styles}</style>`)
.catch(() => '');
cache.set(href, link);
cache.set(href, link);
return link;
};
}
@@ -13,7 +13,10 @@ const propTypes = {
};
function SuperBlockIntroductionPage({ data: { markdownRemark } }) {
const { html, frontmatter: { superBlock } } = markdownRemark;
const {
html,
frontmatter: { superBlock }
} = markdownRemark;
return (
<Fragment>
<Helmet>
+5 -4
View File
@@ -17,10 +17,11 @@ const arrToString = arr =>
exports.localeChallengesRootDir = getChallengesDirForLang(locale);
exports.replaceChallengeNode =
async function replaceChallengeNode(fullFilePath) {
return prepareChallenge(await createChallenge(fullFilePath));
};
exports.replaceChallengeNode = async function replaceChallengeNode(
fullFilePath
) {
return prepareChallenge(await createChallenge(fullFilePath));
};
exports.buildChallenges = async function buildChallenges() {
const curriculum = await getChallengesForLang(locale);
+1 -1
View File
@@ -157,7 +157,7 @@ const stopWords = [
'in',
'into',
'it',
'it\'s',
"it's",
'its',
'no',
'nor',
+11 -12
View File
@@ -17,7 +17,10 @@ function prototyper(str) {
if (prototypeRE.test(str)) {
if (str.length > 9) {
return prototyper(
str.trim().split('prototype').join('-prototype-')
str
.trim()
.split('prototype')
.join('-prototype-')
);
}
return str;
@@ -26,15 +29,13 @@ function prototyper(str) {
})
.join(' ')
.split(' ');
const noProto = formatted
.filter(removeProto)
.filter(x => !!x);
const noProto = formatted.filter(removeProto).filter(x => !!x);
if (noProto.length === 2) {
const [ first, second ] = noProto;
const [first, second] = noProto;
const secondLC = second.toLowerCase();
const finalSecond = preFormatted[secondLC] ?
preFormatted[secondLC] :
secondLC;
const finalSecond = preFormatted[secondLC]
? preFormatted[secondLC]
: secondLC;
return `${titleify(first)}.prototype.${finalSecond}`;
}
if (noProto.length === 1) {
@@ -43,7 +44,7 @@ function prototyper(str) {
.toLowerCase()
.split('.')
.join('-')
);
);
}
return titleify(str, true);
}
@@ -62,9 +63,7 @@ function titleify(str, triedPrototyper) {
if (stopWords.some(x => x === word) && i !== 0) {
return word;
}
return preFormatted[word] ?
preFormatted[word] :
titleCase(word);
return preFormatted[word] ? preFormatted[word] : titleCase(word);
})
.join(' ');
}