feat: use eslint with prettier to format code
This commit is contained in:
committed by
mrugesh mohapatra
parent
be36915605
commit
fc8c71ad16
@ -25,7 +25,7 @@ export default function addReturnToUrl() {
|
||||
req.method !== 'GET' ||
|
||||
pathsOfNoReturnRegex.test(path) ||
|
||||
!whiteListRegex.test(path) ||
|
||||
(/hot/i).test(req.path)
|
||||
/hot/i.test(req.path)
|
||||
) {
|
||||
return next();
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ export default function() {
|
||||
});
|
||||
return function csrf(req, res, next) {
|
||||
const path = req.path.split('/')[1];
|
||||
if ((/(^api$|^unauthenticated$|^internal$|^p$)/).test(path)) {
|
||||
if (/(^api$|^unauthenticated$|^internal$|^p$)/.test(path)) {
|
||||
return next();
|
||||
}
|
||||
return protection(req, res, next);
|
||||
|
@ -49,7 +49,9 @@ export function _cachedMap({ Block, Challenge }) {
|
||||
});
|
||||
const blockMap = Observable.combineLatest(
|
||||
blocks.map(blocks =>
|
||||
blocks.map(block => block.toJSON()).reduce((hash, block) => {
|
||||
blocks
|
||||
.map(block => block.toJSON())
|
||||
.reduce((hash, block) => {
|
||||
hash[block.dashedName] = block;
|
||||
return hash;
|
||||
}, {})
|
||||
|
@ -35,14 +35,14 @@ export const wrapPageElement = ({ element, props }) => {
|
||||
</DefaultLayout>
|
||||
);
|
||||
}
|
||||
if ((/^\/guide(\/.*)*/).test(pathname)) {
|
||||
if (/^\/guide(\/.*)*/.test(pathname)) {
|
||||
return (
|
||||
<DefaultLayout>
|
||||
<GuideLayout>{element}</GuideLayout>
|
||||
</DefaultLayout>
|
||||
);
|
||||
}
|
||||
if ((/^\/learn(\/.*)*/).test(pathname)) {
|
||||
if (/^\/learn(\/.*)*/.test(pathname)) {
|
||||
return <DefaultLayout showFooter={false}>{element}</DefaultLayout>;
|
||||
}
|
||||
return <DefaultLayout>{element}</DefaultLayout>;
|
||||
|
@ -148,8 +148,8 @@ exports.onCreateWebpackConfig = ({ stage, rules, plugins, actions }) => {
|
||||
/* eslint-disable max-len */
|
||||
exclude: modulePath => {
|
||||
return (
|
||||
(/node_modules/).test(modulePath) &&
|
||||
!(/(ansi-styles|chalk|strict-uri-encode|react-freecodecamp-search)/).test(
|
||||
/node_modules/.test(modulePath) &&
|
||||
!/(ansi-styles|chalk|strict-uri-encode|react-freecodecamp-search)/.test(
|
||||
modulePath
|
||||
)
|
||||
);
|
||||
|
@ -35,14 +35,14 @@ export const wrapPageElement = ({ element, props }) => {
|
||||
</DefaultLayout>
|
||||
);
|
||||
}
|
||||
if ((/^\/guide(\/.*)*/).test(pathname)) {
|
||||
if (/^\/guide(\/.*)*/.test(pathname)) {
|
||||
return (
|
||||
<DefaultLayout>
|
||||
<GuideLayout>{element}</GuideLayout>
|
||||
</DefaultLayout>
|
||||
);
|
||||
}
|
||||
if ((/^\/learn(\/.*)*/).test(pathname)) {
|
||||
if (/^\/learn(\/.*)*/.test(pathname)) {
|
||||
return <DefaultLayout showFooter={false}>{element}</DefaultLayout>;
|
||||
}
|
||||
return <DefaultLayout>{element}</DefaultLayout>;
|
||||
|
@ -31,10 +31,8 @@ exports.sourceNodes = function sourceChallengesSourceNodes(
|
||||
persistent: true
|
||||
});
|
||||
|
||||
watcher.on('ready', sourceAndCreateNodes).on(
|
||||
'change',
|
||||
filePath =>
|
||||
(/\.md$/).test(filePath)
|
||||
watcher.on('ready', sourceAndCreateNodes).on('change', filePath =>
|
||||
/\.md$/.test(filePath)
|
||||
? onSourceChange(filePath)
|
||||
.then(challenge => {
|
||||
reporter.info(
|
||||
|
@ -20,10 +20,7 @@ function markdownToHTML(node) {
|
||||
}
|
||||
|
||||
module.exports = function forumEmojiPlugin({ markdownAST }) {
|
||||
visit(
|
||||
markdownAST,
|
||||
'image',
|
||||
imageNode =>
|
||||
visit(markdownAST, 'image', imageNode =>
|
||||
emojiRE.test(imageNode.title) ? markdownToHTML(imageNode) : imageNode
|
||||
);
|
||||
};
|
||||
|
@ -20,9 +20,12 @@ import DonateText from './DonateText';
|
||||
|
||||
import '../Donation.css';
|
||||
|
||||
const mapStateToProps = createSelector(isDonationModalOpenSelector, show => ({
|
||||
const mapStateToProps = createSelector(
|
||||
isDonationModalOpenSelector,
|
||||
show => ({
|
||||
show
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
|
@ -19,7 +19,7 @@ const ColHeader = ({ children, ...other }) => (
|
||||
ColHeader.propTypes = propTypes;
|
||||
|
||||
const Link = ({ children, to, external, ...other }) => {
|
||||
if (!external && (/^\/(?!\/)/).test(to)) {
|
||||
if (!external && /^\/(?!\/)/.test(to)) {
|
||||
return (
|
||||
<GatsbyLink to={to} {...other}>
|
||||
{children}
|
||||
|
@ -12,9 +12,12 @@ import { gtagReportConversion } from '../../../analytics/gtag';
|
||||
|
||||
import './login.css';
|
||||
|
||||
const mapStateToProps = createSelector(isSignedInSelector, isSignedIn => ({
|
||||
const mapStateToProps = createSelector(
|
||||
isSignedInSelector,
|
||||
isSignedIn => ({
|
||||
isSignedIn
|
||||
}));
|
||||
})
|
||||
);
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
navigate: location => dispatch(hardGoTo(location))
|
||||
});
|
||||
|
@ -6,9 +6,12 @@ import { createSelector } from 'reselect';
|
||||
|
||||
import { userSelector } from '../../../redux';
|
||||
|
||||
const mapStateToProps = createSelector(userSelector, ({ picture }) => ({
|
||||
const mapStateToProps = createSelector(
|
||||
userSelector,
|
||||
({ picture }) => ({
|
||||
picture
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
function SignedIn({ picture }) {
|
||||
return (
|
||||
|
@ -14,9 +14,10 @@ import { ChallengeNode } from '../../../redux/propTypes';
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const expandedSelector = makeExpandedSuperBlockSelector(ownProps.superBlock);
|
||||
|
||||
return createSelector(expandedSelector, isExpanded => ({ isExpanded }))(
|
||||
state
|
||||
);
|
||||
return createSelector(
|
||||
expandedSelector,
|
||||
isExpanded => ({ isExpanded })
|
||||
)(state);
|
||||
};
|
||||
|
||||
function mapDispatchToProps(dispatch) {
|
||||
|
@ -65,7 +65,7 @@ export function getValidationState(field) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ((/https?:\/\/glitch\.com\/edit\/#!\/.*/g).test(field.value)) {
|
||||
if (/https?:\/\/glitch\.com\/edit\/#!\/.*/g.test(field.value)) {
|
||||
return 'glitch-warning';
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ class PortfolioSettings extends Component {
|
||||
if (isImage && !maybeUrl) {
|
||||
return { state: null, message: '' };
|
||||
}
|
||||
if (isImage && !(/\.(png|jpg|jpeg|gif)$/).test(maybeUrl)) {
|
||||
if (isImage && !/\.(png|jpg|jpeg|gif)$/.test(maybeUrl)) {
|
||||
return {
|
||||
state: 'error',
|
||||
message: 'URL must link directly to an image file'
|
||||
|
@ -14,10 +14,13 @@ import Spacer from '../helpers/Spacer';
|
||||
import ToggleSetting from './ToggleSetting';
|
||||
import SectionHeader from './SectionHeader';
|
||||
|
||||
const mapStateToProps = createSelector(userSelector, user => ({
|
||||
const mapStateToProps = createSelector(
|
||||
userSelector,
|
||||
user => ({
|
||||
...user.profileUI,
|
||||
user
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators({ submitProfileUI }, dispatch);
|
||||
@ -130,7 +133,7 @@ class PrivacySettings extends Component {
|
||||
toggleFlag={this.toggleFlag('showLocation')}
|
||||
/>
|
||||
<ToggleSetting
|
||||
action='My "about me"'
|
||||
action='My "about me"'
|
||||
flag={!showAbout}
|
||||
flagName='showAbout'
|
||||
offLabel='Public'
|
||||
|
@ -91,9 +91,8 @@ class UsernameSettings extends Component {
|
||||
characterValidation: { valid }
|
||||
} = this.state;
|
||||
|
||||
return this.setState(
|
||||
{ submitClicked: true },
|
||||
() => (valid ? submitNewUsername(formValue) : null)
|
||||
return this.setState({ submitClicked: true }, () =>
|
||||
valid ? submitNewUsername(formValue) : null
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ const propTypes = {
|
||||
};
|
||||
|
||||
function emptyInstruction(instructions) {
|
||||
return (/^<section\s+id\s*=\s*("|')instructions\1\s*>\s*<\/section>$/).test(
|
||||
return /^<section\s+id\s*=\s*("|')instructions\1\s*>\s*<\/section>$/.test(
|
||||
instructions
|
||||
);
|
||||
}
|
||||
|
@ -16,9 +16,12 @@ const propTypes = {
|
||||
reset: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
const mapStateToProps = createSelector(isResetModalOpenSelector, isOpen => ({
|
||||
const mapStateToProps = createSelector(
|
||||
isResetModalOpenSelector,
|
||||
isOpen => ({
|
||||
isOpen
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
|
@ -13,9 +13,12 @@ import { initConsole, challengeTestsSelector } from '../redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import './side-panel.css';
|
||||
|
||||
const mapStateToProps = createSelector(challengeTestsSelector, tests => ({
|
||||
const mapStateToProps = createSelector(
|
||||
challengeTestsSelector,
|
||||
tests => ({
|
||||
tests
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
|
@ -59,4 +59,3 @@ export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(ToolPanel);
|
||||
|
||||
|
@ -105,7 +105,9 @@ function loadCodeEpic(action$, state$) {
|
||||
const codeFound = getCode(id);
|
||||
if (codeFound && isFilesAllPoly(codeFound)) {
|
||||
finalFiles = {
|
||||
...fileKeys.map(key => files[key]).reduce(
|
||||
...fileKeys
|
||||
.map(key => files[key])
|
||||
.reduce(
|
||||
(files, file) => ({
|
||||
...files,
|
||||
[file.key]: {
|
||||
|
@ -23,7 +23,9 @@ const propTypes = {
|
||||
};
|
||||
|
||||
function renderMenuItems({ edges = [] }) {
|
||||
return edges.map(({ node }) => node).map(({ title, fields: { slug } }) => (
|
||||
return edges
|
||||
.map(({ node }) => node)
|
||||
.map(({ title, fields: { slug } }) => (
|
||||
<Link key={'intro-' + slug} to={slug}>
|
||||
<ListGroupItem>{title}</ListGroupItem>
|
||||
</Link>
|
||||
|
@ -45,7 +45,7 @@ function textToData(sectionIds) {
|
||||
const lines = child.value.split('\n');
|
||||
if (lines.filter(Boolean).length > 0) {
|
||||
lines.forEach((line, index) => {
|
||||
if ((/^\s*$/).test(line)) {
|
||||
if (/^\s*$/.test(line)) {
|
||||
currentParagraph = null;
|
||||
} else {
|
||||
if (!currentParagraph || index > 0) {
|
||||
|
@ -70,7 +70,7 @@ const challengeFrontmatterValidator = file => frontmatter => {
|
||||
|
||||
function isChallengeParseable(file) {
|
||||
const { stat, fullPath } = file;
|
||||
if (!stat.isFile() || (/_meta/).test(fullPath)) {
|
||||
if (!stat.isFile() || /_meta/.test(fullPath)) {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
return parseMarkdown(fullPath);
|
||||
|
Reference in New Issue
Block a user