chore(deps): upgrade eslint, prettier & related packages

This commit is contained in:
Mrugesh Mohapatra
2021-03-11 00:31:46 +05:30
committed by Mrugesh Mohapatra
parent 0a53a1d7f0
commit 6c91f81b0e
94 changed files with 1462 additions and 1411 deletions

View File

@ -1,4 +1,3 @@
**/node_modules/**
client/.cache/** client/.cache/**
client/static/** client/static/**
client/public/** client/public/**

View File

@ -1,210 +1,210 @@
{ {
"rules": { "rules": {
"max-len": [ "max-len": [
"error", "error",
{ "code": 80, "ignoreUrls": true, "ignoreTemplateLiterals": true } { "code": 80, "ignoreUrls": true, "ignoreTemplateLiterals": true }
], ],
"block-scoped-var": 0, "block-scoped-var": 0,
"brace-style": [2, "1tbs", { "allowSingleLine": true }], "brace-style": [2, "1tbs", { "allowSingleLine": true }],
"camelcase": 2, "camelcase": 2,
"comma-dangle": 2, "comma-dangle": 2,
"comma-spacing": [2, { "before": false, "after": true }], "comma-spacing": [2, { "before": false, "after": true }],
"comma-style": [2, "last"], "comma-style": [2, "last"],
"complexity": 0, "complexity": 0,
"consistent-return": 2, "consistent-return": 2,
"consistent-this": 0, "consistent-this": 0,
"curly": 2, "curly": 2,
"default-case": 2, "default-case": 2,
"dot-notation": 0, "dot-notation": 0,
"eol-last": 2, "eol-last": 2,
"eqeqeq": 2, "eqeqeq": 2,
"func-call-spacing": 2, "func-call-spacing": 2,
"func-names": 0, "func-names": 0,
"func-style": 0, "func-style": 0,
"guard-for-in": 2, "guard-for-in": 2,
"handle-callback-err": 2, "handle-callback-err": 2,
"import/default": 2, "import/default": 2,
"import/export": 2, "import/export": 2,
"import/extensions": [0, "always"], "import/extensions": [0, "always"],
"import/first": 2, "import/first": 2,
"import/named": 2, "import/named": 2,
"import/namespace": 2, "import/namespace": 2,
"import/newline-after-import": 2, "import/newline-after-import": 2,
"import/no-duplicates": 2, "import/no-duplicates": 2,
"import/no-unresolved": [2, {"commonjs": true}], "import/no-unresolved": [2, { "commonjs": true }],
"import/unambiguous": 2, "import/unambiguous": 2,
"jsx-quotes": [2, "prefer-single"], "jsx-quotes": [2, "prefer-single"],
"jsx-a11y/accessible-emoji": "error", "jsx-a11y/accessible-emoji": "error",
"jsx-a11y/alt-text": "error", "jsx-a11y/alt-text": "error",
"jsx-a11y/anchor-has-content": "error", "jsx-a11y/anchor-has-content": "error",
"jsx-a11y/anchor-is-valid": "error", "jsx-a11y/anchor-is-valid": "error",
"jsx-a11y/aria-activedescendant-has-tabindex": "error", "jsx-a11y/aria-activedescendant-has-tabindex": "error",
"jsx-a11y/aria-props": "error", "jsx-a11y/aria-props": "error",
"jsx-a11y/aria-proptypes": "error", "jsx-a11y/aria-proptypes": "error",
"jsx-a11y/aria-role": "error", "jsx-a11y/aria-role": "error",
"jsx-a11y/aria-unsupported-elements": "error", "jsx-a11y/aria-unsupported-elements": "error",
"jsx-a11y/control-has-associated-label": "error", "jsx-a11y/control-has-associated-label": "error",
"jsx-a11y/click-events-have-key-events": "error", "jsx-a11y/click-events-have-key-events": "error",
"jsx-a11y/heading-has-content": "error", "jsx-a11y/heading-has-content": "error",
"jsx-a11y/html-has-lang": "error", "jsx-a11y/html-has-lang": "error",
"jsx-a11y/iframe-has-title": "error", "jsx-a11y/iframe-has-title": "error",
"jsx-a11y/img-redundant-alt": "error", "jsx-a11y/img-redundant-alt": "error",
"jsx-a11y/interactive-supports-focus": "error", "jsx-a11y/interactive-supports-focus": "error",
"jsx-a11y/label-has-associated-control": "error", "jsx-a11y/label-has-associated-control": "error",
"jsx-a11y/lang": "error", "jsx-a11y/lang": "error",
"jsx-a11y/media-has-caption": "error", "jsx-a11y/media-has-caption": "error",
"jsx-a11y/mouse-events-have-key-events": "error", "jsx-a11y/mouse-events-have-key-events": "error",
"jsx-a11y/no-access-key": "error", "jsx-a11y/no-access-key": "error",
"jsx-a11y/no-autofocus": "error", "jsx-a11y/no-autofocus": "error",
"jsx-a11y/no-distracting-elements": "error", "jsx-a11y/no-distracting-elements": "error",
"jsx-a11y/no-interactive-element-to-noninteractive-role": "error", "jsx-a11y/no-interactive-element-to-noninteractive-role": "error",
"jsx-a11y/no-noninteractive-element-interactions": "error", "jsx-a11y/no-noninteractive-element-interactions": "error",
"jsx-a11y/no-noninteractive-element-to-interactive-role": "error", "jsx-a11y/no-noninteractive-element-to-interactive-role": "error",
"jsx-a11y/no-noninteractive-tabindex": "error", "jsx-a11y/no-noninteractive-tabindex": "error",
"jsx-a11y/no-onchange": "error", "jsx-a11y/no-onchange": "error",
"jsx-a11y/no-redundant-roles": "error", "jsx-a11y/no-redundant-roles": "error",
"jsx-a11y/no-static-element-interactions": "error", "jsx-a11y/no-static-element-interactions": "error",
"jsx-a11y/role-has-required-aria-props": "error", "jsx-a11y/role-has-required-aria-props": "error",
"jsx-a11y/role-supports-aria-props": "error", "jsx-a11y/role-supports-aria-props": "error",
"jsx-a11y/scope": "error", "jsx-a11y/scope": "error",
"jsx-a11y/tabindex-no-positive": "error", "jsx-a11y/tabindex-no-positive": "error",
"key-spacing": [2, { "beforeColon": false, "afterColon": true }], "key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"keyword-spacing": [2], "keyword-spacing": [2],
"max-depth": 0, "max-depth": 0,
"max-nested-callbacks": 0, "max-nested-callbacks": 0,
"max-params": 0, "max-params": 0,
"max-statements": 0, "max-statements": 0,
"new-cap": 0, "new-cap": 0,
"new-parens": 2, "new-parens": 2,
"no-alert": 2, "no-alert": 2,
"no-array-constructor": 2, "no-array-constructor": 2,
"no-bitwise": 2, "no-bitwise": 2,
"no-caller": 2, "no-caller": 2,
"no-cond-assign": 2, "no-cond-assign": 2,
"no-console": 0, "no-console": 0,
"no-constant-condition": 2, "no-constant-condition": 2,
"no-control-regex": 2, "no-control-regex": 2,
"no-debugger": 2, "no-debugger": 2,
"no-delete-var": 2, "no-delete-var": 2,
"no-div-regex": 2, "no-div-regex": 2,
"no-dupe-keys": 2, "no-dupe-keys": 2,
"no-else-return": 0, "no-else-return": 0,
"no-empty": 2, "no-empty": 2,
"no-empty-character-class": 2, "no-empty-character-class": 2,
"no-eq-null": 2, "no-eq-null": 2,
"no-eval": 2, "no-eval": 2,
"no-ex-assign": 2, "no-ex-assign": 2,
"no-extend-native": 2, "no-extend-native": 2,
"no-extra-bind": 2, "no-extra-bind": 2,
"no-extra-boolean-cast": 2, "no-extra-boolean-cast": 2,
"no-extra-parens": 0, "no-extra-parens": 0,
"no-extra-semi": 2, "no-extra-semi": 2,
"no-fallthrough": 2, "no-fallthrough": 2,
"no-floating-decimal": 2, "no-floating-decimal": 2,
"no-func-assign": 2, "no-func-assign": 2,
"no-global-assign": 2, "no-global-assign": 2,
"no-implied-eval": 2, "no-implied-eval": 2,
"no-inline-comments": 2, "no-inline-comments": 2,
"no-inner-declarations": 2, "no-inner-declarations": 2,
"no-invalid-regexp": 2, "no-invalid-regexp": 2,
"no-irregular-whitespace": 2, "no-irregular-whitespace": 2,
"no-iterator": 2, "no-iterator": 2,
"no-label-var": 2, "no-label-var": 2,
"no-labels": 2, "no-labels": 2,
"no-lone-blocks": 2, "no-lone-blocks": 2,
"no-lonely-if": 2, "no-lonely-if": 2,
"no-loop-func": 2, "no-loop-func": 2,
"no-mixed-requires": 0, "no-mixed-requires": 0,
"no-mixed-spaces-and-tabs": 2, "no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2, "no-multi-spaces": 2,
"no-multi-str": 2, "no-multi-str": 2,
"no-multiple-empty-lines": [2, { "max": 2 }], "no-multiple-empty-lines": [2, { "max": 2 }],
"no-nested-ternary": 2, "no-nested-ternary": 2,
"no-new": 2, "no-new": 2,
"no-new-func": 2, "no-new-func": 2,
"no-new-object": 2, "no-new-object": 2,
"no-new-require": 2, "no-new-require": 2,
"no-new-wrappers": 2, "no-new-wrappers": 2,
"no-obj-calls": 2, "no-obj-calls": 2,
"no-octal": 2, "no-octal": 2,
"no-octal-escape": 2, "no-octal-escape": 2,
"no-path-concat": 2, "no-path-concat": 2,
"no-plusplus": 0, "no-plusplus": 0,
"no-process-env": 0, "no-process-env": 0,
"no-process-exit": 2, "no-process-exit": 2,
"no-proto": 2, "no-proto": 2,
"no-regex-spaces": 2, "no-regex-spaces": 2,
"no-reserved-keys": 0, "no-reserved-keys": 0,
"no-restricted-modules": 0, "no-restricted-modules": 0,
"no-return-assign": 2, "no-return-assign": 2,
"no-script-url": 2, "no-script-url": 2,
"no-self-compare": 2, "no-self-compare": 2,
"no-sequences": 2, "no-sequences": 2,
"no-shadow": 0, "no-shadow": 0,
"no-shadow-restricted-names": 2, "no-shadow-restricted-names": 2,
"no-sparse-arrays": 2, "no-sparse-arrays": 2,
"no-sync": 0, "no-sync": 0,
"no-ternary": 0, "no-ternary": 0,
"no-trailing-spaces": 2, "no-trailing-spaces": 2,
"no-undef": 2, "no-undef": 2,
"no-undef-init": 2, "no-undef-init": 2,
"no-undefined": 2, "no-undefined": 2,
"no-underscore-dangle": 0, "no-underscore-dangle": 0,
"no-unreachable": 2, "no-unreachable": 2,
"no-unsafe-negation": 2, "no-unsafe-negation": 2,
"no-unused-expressions": 2, "no-unused-expressions": 2,
"no-unused-vars": 2, "no-unused-vars": 2,
"no-use-before-define": 0, "no-use-before-define": 0,
"no-void": 0, "no-void": 0,
"no-warning-comments": [2, { "terms": ["fixme"], "location": "start" }], "no-warning-comments": [2, { "terms": ["fixme"], "location": "start" }],
"no-with": 2, "no-with": 2,
"one-var": 0, "one-var": 0,
"operator-assignment": 0, "operator-assignment": 0,
"padded-blocks": 0, "padded-blocks": 0,
"prefer-object-spread/prefer-object-spread": 2, "prefer-object-spread/prefer-object-spread": 2,
"prettier/prettier": "error", "prettier/prettier": "error",
"quote-props": [2, "as-needed"], "quote-props": [2, "as-needed"],
"quotes": [2, "single", "avoid-escape"], "quotes": [2, "single", "avoid-escape"],
"radix": 2, "radix": 2,
"react/display-name": 2, "react/display-name": 2,
"react/jsx-boolean-value": [2, "always"], "react/jsx-boolean-value": [2, "always"],
"react/jsx-closing-bracket-location": [ "react/jsx-closing-bracket-location": [
2, 2,
{ "selfClosing": "line-aligned", "nonEmpty": "props-aligned" } { "selfClosing": "line-aligned", "nonEmpty": "props-aligned" }
], ],
"react/jsx-no-undef": 2, "react/jsx-no-undef": 2,
"react/jsx-sort-props": [2, { "ignoreCase": true }], "react/jsx-sort-props": [2, { "ignoreCase": true }],
"react/jsx-uses-react": 2, "react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2, "react/jsx-uses-vars": 2,
"react/jsx-wrap-multilines": 2, "react/jsx-wrap-multilines": 2,
"react/no-did-mount-set-state": 2, "react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2, "react/no-did-update-set-state": 2,
"react/no-multi-comp": [2, { "ignoreStateless": true }], "react/no-multi-comp": [2, { "ignoreStateless": true }],
"react/no-unescaped-entities": 0, "react/no-unescaped-entities": 0,
"react/no-unknown-property": 2, "react/no-unknown-property": 2,
"react/prop-types": 2, "react/prop-types": 2,
"react/react-in-jsx-scope": 2, "react/react-in-jsx-scope": 2,
"react/self-closing-comp": 2, "react/self-closing-comp": 2,
"react/sort-prop-types": 2, "react/sort-prop-types": 2,
"react-hooks/rules-of-hooks": "error", "react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error", "react-hooks/exhaustive-deps": "error",
"semi": [2, "always"], "semi": [2, "always"],
"semi-spacing": [2, { "before": false, "after": true }], "semi-spacing": [2, { "before": false, "after": true }],
"sort-vars": 0, "sort-vars": 0,
"space-before-blocks": [2, "always"], "space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"], "space-before-function-paren": [2, "never"],
"space-in-brackets": 0, "space-in-brackets": 0,
"space-in-parens": 0, "space-in-parens": 0,
"space-infix-ops": 2, "space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }], "space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [2, "always", { "exceptions": ["-"] }], "spaced-comment": [2, "always", { "exceptions": ["-"] }],
"strict": 0, "strict": 0,
"use-isnan": 2, "use-isnan": 2,
"valid-jsdoc": 0, "valid-jsdoc": 0,
"valid-typeof": 2, "valid-typeof": 2,
"vars-on-top": 0, "vars-on-top": 0,
"wrap-iife": [2, "any"], "wrap-iife": [2, "any"],
"wrap-regex": 2, "wrap-regex": 2,
"yoda": 0 "yoda": 0
} }
} }

View File

@ -1,27 +1,43 @@
{ {
"env": { "env": {
"es6": true, "es6": true,
"browser": true, "browser": true,
"mocha": true, "mocha": true,
"node": true "node": true
}, },
"parser": "babel-eslint", "parser": "babel-eslint",
"root": true, "root": true,
"extends": ["./.eslintrc-base.json", "prettier", "prettier/react"], "extends": [
"plugins": ["react", "import", "prefer-object-spread", "prettier", "react-hooks", "jsx-a11y"], "./.eslintrc-base.json",
"prettier"
],
"plugins": [
"react",
"import",
"prefer-object-spread",
"prettier",
"react-hooks",
"jsx-a11y"
],
"globals": { "globals": {
"Promise": true, "Promise": true,
"window": true, "window": true,
"$": true, "$": true,
"ga": true, "ga": true,
"jQuery": true, "jQuery": true,
"router": true "router": true
}, },
"settings": { "settings": {
"react": { "react": {
"version": "16.4.2", "version": "16.4.2",
"import/ignore": ["node_modules", "\\.json$"], "import/ignore": [
"import/extensions": [".js", ".jsx"] "node_modules",
"\\.json$"
],
"import/extensions": [
".js",
".jsx"
]
} }
} }
} }

View File

@ -4,5 +4,6 @@
"singleQuote": true, "singleQuote": true,
"jsxSingleQuote": true, "jsxSingleQuote": true,
"tabWidth": 2, "tabWidth": 2,
"trailingComma": "none" "trailingComma": "none",
"arrowParens": "avoid"
} }

View File

@ -8,8 +8,8 @@ import {
} from '../../server/utils/auth'; } from '../../server/utils/auth';
const log = debug('fcc:models:UserCredential'); const log = debug('fcc:models:UserCredential');
module.exports = function(UserCredential) { module.exports = function (UserCredential) {
UserCredential.link = function( UserCredential.link = function (
userId, userId,
_provider, _provider,
authScheme, authScheme,

View File

@ -14,12 +14,12 @@ export function ensureLowerCaseEmail(profile) {
: ''; : '';
} }
export default function(UserIdent) { export default function (UserIdent) {
UserIdent.on('dataSourceAttached', () => { UserIdent.on('dataSourceAttached', () => {
UserIdent.findOne$ = observeMethod(UserIdent, 'findOne'); UserIdent.findOne$ = observeMethod(UserIdent, 'findOne');
}); });
UserIdent.login = function( UserIdent.login = function (
_provider, _provider,
authScheme, authScheme,
profile, profile,

View File

@ -1,6 +1,6 @@
import { Observable } from 'rx'; import { Observable } from 'rx';
export default function(Block) { export default function (Block) {
Block.on('dataSourceAttached', () => { Block.on('dataSourceAttached', () => {
Block.findOne$ = Observable.fromNodeCallback(Block.findOne, Block); Block.findOne$ = Observable.fromNodeCallback(Block.findOne, Block);
Block.findById$ = Observable.fromNodeCallback(Block.findById, Block); Block.findById$ = Observable.fromNodeCallback(Block.findById, Block);

View File

@ -152,7 +152,7 @@ function populateRequiredFields(user) {
return; return;
} }
export default function(User) { export default function (User) {
// set salt factor for passwords // set salt factor for passwords
User.settings.saltWorkFactor = 5; User.settings.saltWorkFactor = 5;
// set user.rand to random number // 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) const beforeCreate = Observable.of(ctx)
.filter(({ isNewInstance }) => isNewInstance) .filter(({ isNewInstance }) => isNewInstance)
// User.create // User.create
@ -229,7 +229,7 @@ export default function(User) {
}); });
// remove lingering user identities before deleting 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 UserIdentity = User.app.models.UserIdentity;
const UserCredential = User.app.models.UserCredential; const UserCredential = User.app.models.UserCredential;
log('removing user', ctx.where); log('removing user', ctx.where);
@ -240,21 +240,21 @@ export default function(User) {
return Observable.combineLatest( return Observable.combineLatest(
destroyAll(id, UserIdentity), destroyAll(id, UserIdentity),
destroyAll(id, UserCredential), destroyAll(id, UserCredential),
function(identData, credData) { function (identData, credData) {
return { return {
identData: identData, identData: identData,
credData: credData credData: credData
}; };
} }
).subscribe( ).subscribe(
function(data) { function (data) {
log('deleted', data); log('deleted', data);
}, },
function(err) { function (err) {
log('error deleting user %s stuff', id, err); log('error deleting user %s stuff', id, err);
next(err); next(err);
}, },
function() { function () {
log('user stuff deleted for user %s', id); log('user stuff deleted for user %s', id);
next(); next();
} }
@ -263,7 +263,7 @@ export default function(User) {
log('setting up user hooks'); log('setting up user hooks');
// overwrite lb confirm // overwrite lb confirm
User.confirm = function(uid, token, redirectTo) { User.confirm = function (uid, token, redirectTo) {
return this.findById(uid).then(user => { return this.findById(uid).then(user => {
if (!user) { if (!user) {
throw wrapHandledError(new Error(`User not found: ${uid}`), { 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); removeCookies(req, res);
next(); next();
}); });
@ -802,7 +802,7 @@ export default function(User) {
...user, ...user,
about: showAbout ? about : '', about: showAbout ? about : '',
calendar: showHeatMap ? calendar : {}, calendar: showHeatMap ? calendar : {},
completedChallenges: (function() { completedChallenges: (function () {
if (showTimeLine) { if (showTimeLine) {
return showCerts return showCerts
? completedChallenges ? completedChallenges

View File

@ -41,9 +41,9 @@ export default function donateBoot(app, done) {
metadata: { metadata: {
/* eslint-disable camelcase */ /* eslint-disable camelcase */
sb_service: `freeCodeCamp.org`, sb_service: `freeCodeCamp.org`,
sb_tier: `${ sb_tier: `${donationSubscriptionConfig.duration[duration]} $${
donationSubscriptionConfig.duration[duration] amount / 100
} $${amount / 100} Donation` } Donation`
/* eslint-enable camelcase */ /* eslint-enable camelcase */
} }
}, },
@ -68,11 +68,11 @@ export default function donateBoot(app, done) {
} }
function connectToStripe() { function connectToStripe() {
return new Promise(function(resolve) { return new Promise(function (resolve) {
// connect to stripe API // connect to stripe API
stripe = Stripe(keys.stripe.secret); stripe = Stripe(keys.stripe.secret);
// parse stripe plans // parse stripe plans
stripe.plans.list({}, function(err, stripePlans) { stripe.plans.list({}, function (err, stripePlans) {
if (err) { if (err) {
throw err; throw err;
} }
@ -96,7 +96,7 @@ export default function donateBoot(app, done) {
function createStripePlan(plan) { function createStripePlan(plan) {
log(`Creating subscription plan: ${plan.product.name}`); log(`Creating subscription plan: ${plan.product.name}`);
stripe.plans.create(plan, function(err) { stripe.plans.create(plan, function (err) {
if (err) { if (err) {
log(err); log(err);
} }

View File

@ -12,7 +12,7 @@ module.exports = function mountLoopBackExplorer(app) {
} catch (err) { } catch (err) {
// Print the message only when the app was started via `app.listen()`. // 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. // Do not print any message when the project is used as a component.
app.once('started', function() { app.once('started', function () {
log( log(
'Run `npm install loopback-component-explorer` to enable ' + 'Run `npm install loopback-component-explorer` to enable ' +
'the LoopBack explorer' 'the LoopBack explorer'
@ -25,7 +25,7 @@ module.exports = function mountLoopBackExplorer(app) {
const mountPath = '/explorer'; const mountPath = '/explorer';
explorer(app, { basePath: restApiRoot, mountPath }); explorer(app, { basePath: restApiRoot, mountPath });
app.once('started', function() { app.once('started', function () {
const baseUrl = app.get('url').replace(/\/$/, ''); const baseUrl = app.get('url').replace(/\/$/, '');
log('Browse your REST API at %s%s', baseUrl, mountPath); log('Browse your REST API at %s%s', baseUrl, mountPath);

View File

@ -6,7 +6,7 @@ import { getRedirectParams } from '../utils/redirection';
const githubClient = process.env.GITHUB_ID; const githubClient = process.env.GITHUB_ID;
const githubSecret = process.env.GITHUB_SECRET; const githubSecret = process.env.GITHUB_SECRET;
module.exports = function(app) { module.exports = function (app) {
const router = app.loopback.Router(); const router = app.loopback.Router();
const User = app.models.User; const User = app.models.User;
@ -168,7 +168,7 @@ module.exports = function(app) {
githubSecret githubSecret
].join(''), ].join(''),
githubHeaders, githubHeaders,
function(err, status1, pulls) { function (err, status1, pulls) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -185,7 +185,7 @@ module.exports = function(app) {
githubSecret githubSecret
].join(''), ].join(''),
githubHeaders, githubHeaders,
function(err, status2, issues) { function (err, status2, issues) {
if (err) { if (err) {
return next(err); return next(err);
} }

View File

@ -77,9 +77,7 @@ function refetchCompletedChallenges(req, res, next) {
} }
const updateMyEmailValidators = [ const updateMyEmailValidators = [
check('email') check('email').isEmail().withMessage('Email format is invalid.')
.isEmail()
.withMessage('Email format is invalid.')
]; ];
function updateMyEmail(req, res, next) { function updateMyEmail(req, res, next) {
@ -117,9 +115,7 @@ function updateMyCurrentChallenge(req, res, next) {
} }
const updateMyThemeValidators = [ const updateMyThemeValidators = [
check('theme') check('theme').isIn(Object.keys(themes)).withMessage('Theme is invalid.')
.isIn(Object.keys(themes))
.withMessage('Theme is invalid.')
]; ];
function updateMyTheme(req, res, next) { function updateMyTheme(req, res, next) {

View File

@ -1,4 +1,4 @@
module.exports = function(app) { module.exports = function (app) {
var router = app.loopback.Router(); var router = app.loopback.Router();
router.get('/wiki/*', showForum); router.get('/wiki/*', showForum);

View File

@ -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) { if (err) {
return next(err); return next(err);
} }
@ -137,7 +137,7 @@ function getUnlinkSocial(req, res, next) {
return res.redirect('/' + username); return res.redirect('/' + username);
} }
return identity.destroy(function(err) { return identity.destroy(function (err) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -181,7 +181,7 @@ function postResetProgress(req, res, next) {
isMachineLearningPyCertV7: false, isMachineLearningPyCertV7: false,
completedChallenges: [] completedChallenges: []
}, },
function(err) { function (err) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -193,7 +193,7 @@ function postResetProgress(req, res, next) {
function createPostDeleteAccount(app) { function createPostDeleteAccount(app) {
const { User } = app.models; const { User } = app.models;
return function postDeleteAccount(req, res, next) { return function postDeleteAccount(req, res, next) {
return User.destroyById(req.user.id, function(err) { return User.destroyById(req.user.id, function (err) {
if (err) { if (err) {
return next(err); return next(err);
} }

View File

@ -2,7 +2,7 @@ import accepts from 'accepts';
import { getRedirectParams } from '../utils/redirection'; import { getRedirectParams } from '../utils/redirection';
export default function fourOhFour(app) { export default function fourOhFour(app) {
app.all('*', function(req, res) { app.all('*', function (req, res) {
const accept = accepts(req); const accept = accepts(req);
const type = accept.type('html', 'json', 'text'); const type = accept.type('html', 'json', 'text');
const { path } = req; const { path } = req;

View File

@ -53,7 +53,7 @@ export function setupPassport(app) {
configurator.init(); configurator.init();
Object.keys(passportProviders).map(function(strategy) { Object.keys(passportProviders).map(function (strategy) {
let config = passportProviders[strategy]; let config = passportProviders[strategy];
config.session = config.session !== false; config.session = config.session !== false;

View File

@ -64,9 +64,12 @@ boot(app, __dirname, err => {
setupPassport(app); setupPassport(app);
const { db } = app.datasources; const { db } = app.datasources;
db.on('connected', _.once(() => log('db connected'))); db.on(
app.start = _.once(function() { 'connected',
const server = app.listen(app.get('port'), function() { _.once(() => log('db connected'))
);
app.start = _.once(function () {
const server = app.listen(app.get('port'), function () {
app.emit('started'); app.emit('started');
log( log(
'freeCodeCamp server listening on port %d in %s', 'freeCodeCamp server listening on port %d in %s',

View File

@ -2,7 +2,7 @@ import { homeLocation } from '../../../../config/env';
import { allowedOrigins } from '../../../../config/cors-settings'; import { allowedOrigins } from '../../../../config/cors-settings';
export default function constantHeaders() { export default function constantHeaders() {
return function(req, res, next) { return function (req, res, next) {
if ( if (
req.headers && req.headers &&
req.headers.origin && req.headers.origin &&

View File

@ -1,6 +1,6 @@
import csurf from 'csurf'; import csurf from 'csurf';
export default function() { export default function () {
const protection = csurf({ const protection = csurf({
cookie: { cookie: {
domain: process.env.COOKIE_DOMAIN || 'localhost', domain: process.env.COOKIE_DOMAIN || 'localhost',

View File

@ -25,7 +25,7 @@ const isDev = process.env.FREECODECAMP_NODE_ENV !== 'production';
export default function prodErrorHandler() { export default function prodErrorHandler() {
// error handling in production. // error handling in production.
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
return function(err, req, res, next) { return function (err, req, res, next) {
const { origin } = getRedirectParams(req); const { origin } = getRedirectParams(req);
const handled = unwrapHandledError(err); const handled = unwrapHandledError(err);
// respect handled error status // respect handled error status

View File

@ -1,7 +1,7 @@
import qs from 'query-string'; import qs from 'query-string';
// add rx methods to express // add rx methods to express
export default function() { export default function () {
return function expressExtensions(req, res, next) { return function expressExtensions(req, res, next) {
res.redirectWithFlash = uri => { res.redirectWithFlash = uri => {
const flash = req.flash(); const flash = req.flash();

View File

@ -10,7 +10,7 @@ const EXCLUDED_PATHS = [
]; ];
export default function flashCheaters() { export default function flashCheaters() {
return function(req, res, next) { return function (req, res, next) {
if ( if (
ALLOWED_METHODS.indexOf(req.method) !== -1 && ALLOWED_METHODS.indexOf(req.method) !== -1 &&
EXCLUDED_PATHS.indexOf(req.path) === -1 && EXCLUDED_PATHS.indexOf(req.path) === -1 &&

View File

@ -1,6 +1,6 @@
import { Observable } from 'rx'; import { Observable } from 'rx';
export default function(AuthToken) { export default function (AuthToken) {
AuthToken.on('dataSourceAttached', () => { AuthToken.on('dataSourceAttached', () => {
AuthToken.findOne$ = Observable.fromNodeCallback( AuthToken.findOne$ = Observable.fromNodeCallback(
AuthToken.findOne.bind(AuthToken) AuthToken.findOne.bind(AuthToken)

View File

@ -7,7 +7,7 @@ import InMemoryCache from '../utils/in-memory-cache';
const log = debug('fcc:boot:donate'); const log = debug('fcc:boot:donate');
const fiveMinutes = 1000 * 60 * 5; const fiveMinutes = 1000 * 60 * 5;
export default function(Donation) { export default function (Donation) {
let activeDonationUpdateInterval = null; let activeDonationUpdateInterval = null;
const activeDonationCountCacheTTL = fiveMinutes; const activeDonationCountCacheTTL = fiveMinutes;
const activeDonationCountCache = InMemoryCache(0, reportError); const activeDonationCountCache = InMemoryCache(0, reportError);

View File

@ -3,14 +3,8 @@ import moment from 'moment-timezone';
// day count between two epochs (inclusive) // day count between two epochs (inclusive)
export function dayCount([head, tail], timezone = 'UTC') { export function dayCount([head, tail], timezone = 'UTC') {
return Math.ceil( return Math.ceil(
moment( moment(moment(head).tz(timezone).endOf('day')).diff(
moment(head) moment(tail).tz(timezone).startOf('day'),
.tz(timezone)
.endOf('day')
).diff(
moment(tail)
.tz(timezone)
.startOf('day'),
'days', 'days',
true true
) )

View File

@ -28,7 +28,7 @@ export async function getAsyncPaypalToken() {
} }
export function capitalizeKeys(object) { export function capitalizeKeys(object) {
Object.keys(object).forEach(function(key) { Object.keys(object).forEach(function (key) {
object[key.toUpperCase()] = object[key]; object[key.toUpperCase()] = object[key];
}); });
} }

View File

@ -30,7 +30,7 @@ export default function populateUser(db, user) {
{ $match: { _id: user.id } }, { $match: { _id: user.id } },
{ $project: { points: { $size: '$progressTimestamps' } } } { $project: { points: { $size: '$progressTimestamps' } } }
]) ])
.get(function(err, [{ points = 1 } = {}]) { .get(function (err, [{ points = 1 } = {}]) {
if (err) { if (err) {
return reject(err); return reject(err);
} }

View File

@ -10,7 +10,7 @@ import {
import { getRedirectParams } from './redirection'; import { getRedirectParams } from './redirection';
export function ifNoUserRedirectHome(message, type = 'errors') { export function ifNoUserRedirectHome(message, type = 'errors') {
return function(req, res, next) { return function (req, res, next) {
const { path } = req; const { path } = req;
if (req.user) { if (req.user) {
return next(); return next();
@ -24,7 +24,7 @@ export function ifNoUserRedirectHome(message, type = 'errors') {
} }
export function ifNoUserSend(sendThis) { export function ifNoUserSend(sendThis) {
return function(req, res, next) { return function (req, res, next) {
if (req.user) { if (req.user) {
return next(); return next();
} }

View File

@ -5,13 +5,13 @@ import debugFactory from 'debug';
const debug = debugFactory('fcc:rxUtils'); const debug = debugFactory('fcc:rxUtils');
export function saveInstance(instance) { export function saveInstance(instance) {
return new Rx.Observable.create(function(observer) { return new Rx.Observable.create(function (observer) {
if (!instance || typeof instance.save !== 'function') { if (!instance || typeof instance.save !== 'function') {
debug('no instance or save method'); debug('no instance or save method');
observer.onNext(); observer.onNext();
return observer.onCompleted(); return observer.onCompleted();
} }
return instance.save(function(err, savedInstance) { return instance.save(function (err, savedInstance) {
if (err) { if (err) {
return observer.onError(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 // set new expire time in MS and create new subscription to source
if (!expireCacheAt || expireCacheAt < Date.now()) { if (!expireCacheAt || expireCacheAt < Date.now()) {
// set expire in ms; // set expire in ms;
expireCacheAt = moment() expireCacheAt = moment().add(time, unit).valueOf();
.add(time, unit)
.valueOf();
cache = new AsyncSubject(); cache = new AsyncSubject();
source.subscribe(cache); source.subscribe(cache);
} }

View File

@ -25,36 +25,23 @@ export function prepUniqueDaysByHours(cals, tz = 'UTC') {
data.push(cur); data.push(cur);
prev = cur; prev = cur;
} else if ( } else if (
moment(cur) moment(cur).tz(tz).diff(moment(prev).tz(tz).startOf('day'), 'hours') >=
.tz(tz) hoursDay
.diff(
moment(prev)
.tz(tz)
.startOf('day'),
'hours'
) >= hoursDay
) { ) {
data.push(cur); data.push(cur);
prev = cur; prev = cur;
} }
}, []), }, []),
sortBy(e => e), sortBy(e => e),
map(ts => map(ts => moment(ts).tz(tz).startOf('hours').valueOf())
moment(ts)
.tz(tz)
.startOf('hours')
.valueOf()
)
)(cals); )(cals);
} }
export function calcCurrentStreak(cals, tz = 'UTC') { export function calcCurrentStreak(cals, tz = 'UTC') {
let prev = last(cals); let prev = last(cals);
if ( if (
moment() moment().tz(tz).startOf('day').diff(moment(prev).tz(tz), 'hours') >
.tz(tz) hoursBetween
.startOf('day')
.diff(moment(prev).tz(tz), 'hours') > hoursBetween
) { ) {
return 0; return 0;
} }
@ -62,10 +49,8 @@ export function calcCurrentStreak(cals, tz = 'UTC') {
let streakContinues = true; let streakContinues = true;
forEachRight(cur => { forEachRight(cur => {
if ( if (
moment(prev) moment(prev).tz(tz).startOf('day').diff(moment(cur).tz(tz), 'hours') <=
.tz(tz) hoursBetween
.startOf('day')
.diff(moment(cur).tz(tz), 'hours') <= hoursBetween
) { ) {
prev = cur; prev = cur;
currentStreak++; currentStreak++;
@ -86,10 +71,8 @@ export function calcLongestStreak(cals, tz = 'UTC') {
const last = cals[index === 0 ? 0 : index - 1]; const last = cals[index === 0 ? 0 : index - 1];
// is streak broken // is streak broken
if ( if (
moment(head) moment(head).tz(tz).startOf('day').diff(moment(last).tz(tz), 'hours') >
.tz(tz) hoursBetween
.startOf('day')
.diff(moment(last).tz(tz), 'hours') > hoursBetween
) { ) {
tail = head; tail = head;
} }

View File

@ -78,7 +78,7 @@ describe('user stats', () => {
); );
}); });
describe('calcCurrentStreak', function() { describe('calcCurrentStreak', function () {
it('should return 1 day when today one challenge was completed', () => { it('should return 1 day when today one challenge was completed', () => {
expect( expect(
calcCurrentStreak( calcCurrentStreak(
@ -291,7 +291,7 @@ describe('user stats', () => {
); );
}); });
describe('calcLongestStreak', function() { describe('calcLongestStreak', function () {
it( it(
'should return 1 when there is the only one one-day-long ' + 'should return 1 when there is the only one one-day-long ' +
'streak available', 'streak available',

View File

@ -11,7 +11,8 @@ function createChallengeNode(challenge, reporter) {
// sections. // sections.
if ( if (
typeof challenge.description !== 'string' && typeof challenge.description !== 'string' &&
(challenge.challengeType !== 11 && challenge.challengeType !== 7) challenge.challengeType !== 11 &&
challenge.challengeType !== 7
) { ) {
reporter.warn(` reporter.warn(`

View File

@ -298,8 +298,9 @@ const ShowCertification = props => {
bsSize='lg' bsSize='lg'
bsStyle='primary' bsStyle='primary'
target='_blank' target='_blank'
href={`https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME&name=${certTitle}&organizationId=4831032&issueYear=${certYear}&issueMonth=${certMonth + href={`https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME&name=${certTitle}&organizationId=4831032&issueYear=${certYear}&issueMonth=${
1}&certUrl=${certURL}`} certMonth + 1
}&certUrl=${certURL}`}
> >
{t('profile.add-linkedin')} {t('profile.add-linkedin')}
</Button> </Button>
@ -399,7 +400,4 @@ const ShowCertification = props => {
ShowCertification.displayName = 'ShowCertification'; ShowCertification.displayName = 'ShowCertification';
ShowCertification.propTypes = propTypes; ShowCertification.propTypes = propTypes;
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(ShowCertification);
mapStateToProps,
mapDispatchToProps
)(ShowCertification);

View File

@ -211,7 +211,4 @@ export function ShowSettings(props) {
ShowSettings.displayName = 'ShowSettings'; ShowSettings.displayName = 'ShowSettings';
ShowSettings.propTypes = propTypes; ShowSettings.propTypes = propTypes;
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(ShowSettings);
mapStateToProps,
mapDispatchToProps
)(ShowSettings);

View File

@ -155,8 +155,5 @@ ShowUser.displayName = 'ShowUser';
ShowUser.propTypes = propTypes; ShowUser.propTypes = propTypes;
export default withTranslation()( export default withTranslation()(
connect( connect(mapStateToProps, mapDispatchToProps)(ShowUser)
mapStateToProps,
mapDispatchToProps
)(ShowUser)
); );

View File

@ -33,7 +33,7 @@ async function initTestFrame(e = { code: {} }) {
// Hardcode Deep Freeze dependency // Hardcode Deep Freeze dependency
const DeepFreeze = o => { const DeepFreeze = o => {
Object.freeze(o); Object.freeze(o);
Object.getOwnPropertyNames(o).forEach(function(prop) { Object.getOwnPropertyNames(o).forEach(function (prop) {
if ( if (
o.hasOwnProperty(prop) && o.hasOwnProperty(prop) &&
o[prop] !== null && o[prop] !== null &&

View File

@ -2,7 +2,7 @@
// https://github.com/medialize/sass.js/issues/96#issuecomment-424386171 // https://github.com/medialize/sass.js/issues/96#issuecomment-424386171
if (!self.crypto) { if (!self.crypto) {
self.crypto = { self.crypto = {
getRandomValues: function(array) { getRandomValues: function (array) {
for (var i = 0, l = array.length; i < l; i++) { for (var i = 0, l = array.length; i < l; i++) {
array[i] = Math.floor(Math.random() * 256); array[i] = Math.floor(Math.random() * 256);
} }

View File

@ -24,7 +24,4 @@ AppMountNotifier.propTypes = {
render: PropTypes.func.isRequired render: PropTypes.func.isRequired
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(AppMountNotifier);
mapStateToProps,
mapDispatchToProps
)(AppMountNotifier);

View File

@ -163,7 +163,4 @@ function DonateModal({
DonateModal.displayName = 'DonateModal'; DonateModal.displayName = 'DonateModal';
DonateModal.propTypes = propTypes; DonateModal.propTypes = propTypes;
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(DonateModal);
mapStateToProps,
mapDispatchToProps
)(DonateModal);

View File

@ -13,7 +13,7 @@ describe('<UniversalNav />', () => {
displayMenu: false, displayMenu: false,
menuButtonRef: {}, menuButtonRef: {},
searchBarRef: {}, searchBarRef: {},
toggleDisplayMenu: function() {}, toggleDisplayMenu: function () {},
pathName: '/', pathName: '/',
fetchState: { fetchState: {
pending: false pending: false

View File

@ -10,12 +10,9 @@ import { apiLocation, homeLocation } from '../../../../../config/env.json';
import './login.css'; import './login.css';
const mapStateToProps = createSelector( const mapStateToProps = createSelector(isSignedInSelector, isSignedIn => ({
isSignedInSelector, isSignedIn
isSignedIn => ({ }));
isSignedIn
})
);
function Login(props) { function Login(props) {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -207,7 +207,4 @@ export class NavLinks extends Component {
NavLinks.propTypes = propTypes; NavLinks.propTypes = propTypes;
NavLinks.displayName = 'NavLinks'; NavLinks.displayName = 'NavLinks';
export default connect( export default connect(null, mapDispatchToProps)(withTranslation()(NavLinks));
null,
mapDispatchToProps
)(withTranslation()(NavLinks));

View File

@ -22,7 +22,7 @@ function OfflineWarning({ isOnline, isSignedIn }) {
} }
function timeout() { function timeout() {
id = setTimeout(function() { id = setTimeout(function () {
setShowWarning(true); setShowWarning(true);
}, delayInMilliSeconds); }, delayInMilliSeconds);
} }

View File

@ -7,10 +7,7 @@ const createLanguageRedirect = ({ clientLocale, lang }) => {
.filter(item => (item !== clientLocale && item !== lang ? item : '')) .filter(item => (item !== clientLocale && item !== lang ? item : ''))
.join('/'); .join('/');
const hostTail = window?.location?.host const hostTail = window?.location?.host.split('.').slice(1).join('.');
.split('.')
.slice(1)
.join('.');
const nextClient = lang !== 'chinese' ? 'www' : 'chinese'; const nextClient = lang !== 'chinese' ? 'www' : 'chinese';
const nextLocation = `${window?.location?.protocol}//${nextClient}.${hostTail}`; const nextLocation = `${window?.location?.protocol}//${nextClient}.${hostTail}`;

View File

@ -6,12 +6,9 @@ import { fetchUser, isSignedInSelector, executeGA } from '../../redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
const mapStateToProps = createSelector( const mapStateToProps = createSelector(isSignedInSelector, isSignedIn => ({
isSignedInSelector, isSignedIn
isSignedIn => ({ }));
isSignedIn
})
);
const mapDispatchToProps = { fetchUser, executeGA }; const mapDispatchToProps = { fetchUser, executeGA };

View File

@ -90,7 +90,4 @@ LearnLayout.propTypes = {
}) })
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(LearnLayout);
mapStateToProps,
mapDispatchToProps
)(LearnLayout);

View File

@ -336,9 +336,17 @@ function useIdToNameMap() {
certPath: getPathFromID(id) certPath: getPathFromID(id)
}); });
} }
edges.forEach(({ node: { id, title, fields: { slug } } }) => { edges.forEach(
idToNameMap.set(id, { challengeTitle: title, challengePath: slug }); ({
}); node: {
id,
title,
fields: { slug }
}
}) => {
idToNameMap.set(id, { challengeTitle: title, challengePath: slug });
}
);
return idToNameMap; return idToNameMap;
} }

View File

@ -386,9 +386,7 @@ export class CertificationSettings extends Component {
newChallengeFound = true; newChallengeFound = true;
} }
const valuesSaved = values(formChalObj) const valuesSaved = values(formChalObj).filter(Boolean).filter(isString);
.filter(Boolean)
.filter(isString);
const isProjectSectionComplete = valuesSaved.length === oldSubmissions; const isProjectSectionComplete = valuesSaved.length === oldSubmissions;
@ -409,7 +407,7 @@ export class CertificationSettings extends Component {
const initialObject = {}; const initialObject = {};
let filledforms = 0; let filledforms = 0;
legacyProjectMap[certName].forEach(project => { legacyProjectMap[certName].forEach(project => {
let completedProject = find(completedChallenges, function(challenge) { let completedProject = find(completedChallenges, function (challenge) {
return challenge['id'] === project['id']; return challenge['id'] === project['id'];
}); });
if (!completedProject) { if (!completedProject) {

View File

@ -14,12 +14,9 @@ import Spacer from '../helpers/Spacer';
import ToggleSetting from './ToggleSetting'; import ToggleSetting from './ToggleSetting';
import SectionHeader from './SectionHeader'; import SectionHeader from './SectionHeader';
const mapStateToProps = createSelector( const mapStateToProps = createSelector(userSelector, user => ({
userSelector, user
user => ({ }));
user
})
);
const mapDispatchToProps = dispatch => const mapDispatchToProps = dispatch =>
bindActionCreators({ submitProfileUI }, dispatch); bindActionCreators({ submitProfileUI }, dispatch);

View File

@ -45,7 +45,4 @@ class SearchPage extends Component {
SearchPage.displayName = 'SearchPage'; SearchPage.displayName = 'SearchPage';
SearchPage.propTypes = propTypes; SearchPage.propTypes = propTypes;
export default connect( export default connect(null, mapDispatchToProps)(withTranslation()(SearchPage));
null,
mapDispatchToProps
)(withTranslation()(SearchPage));

View File

@ -971,9 +971,6 @@ Editor.propTypes = propTypes;
// NOTE: withRef gets replaced by forwardRef in react-redux 6, // NOTE: withRef gets replaced by forwardRef in react-redux 6,
// https://github.com/reduxjs/react-redux/releases/tag/v6.0.0 // https://github.com/reduxjs/react-redux/releases/tag/v6.0.0
export default connect( export default connect(mapStateToProps, mapDispatchToProps, null, {
mapStateToProps, withRef: true
mapDispatchToProps, })(Editor);
null,
{ withRef: true }
)(Editor);

View File

@ -86,7 +86,4 @@ class EditorTabs extends Component {
EditorTabs.displayName = 'EditorTabs'; EditorTabs.displayName = 'EditorTabs';
EditorTabs.propTypes = propTypes; EditorTabs.propTypes = propTypes;
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(EditorTabs);
mapStateToProps,
mapDispatchToProps
)(EditorTabs);

View File

@ -101,7 +101,4 @@ class MobileLayout extends Component {
MobileLayout.displayName = 'MobileLayout'; MobileLayout.displayName = 'MobileLayout';
MobileLayout.propTypes = propTypes; MobileLayout.propTypes = propTypes;
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(MobileLayout);
mapStateToProps,
mapDispatchToProps
)(MobileLayout);

View File

@ -274,9 +274,6 @@ MultifileEditor.propTypes = propTypes;
// NOTE: withRef gets replaced by forwardRef in react-redux 6, // NOTE: withRef gets replaced by forwardRef in react-redux 6,
// https://github.com/reduxjs/react-redux/releases/tag/v6.0.0 // https://github.com/reduxjs/react-redux/releases/tag/v6.0.0
export default connect( export default connect(mapStateToProps, mapDispatchToProps, null, {
mapStateToProps, withRef: true
mapDispatchToProps, })(MultifileEditor);
null,
{ withRef: true }
)(MultifileEditor);

View File

@ -54,7 +54,7 @@ const mapStateToProps = createSelector(
}) })
); );
const mapDispatchToProps = function(dispatch) { const mapDispatchToProps = function (dispatch) {
const dispatchers = { const dispatchers = {
close: () => dispatch(closeModal('completion')), close: () => dispatch(closeModal('completion')),
submitChallenge: () => { submitChallenge: () => {

View File

@ -90,7 +90,4 @@ function Hotkeys({
Hotkeys.displayName = 'Hotkeys'; Hotkeys.displayName = 'Hotkeys';
Hotkeys.propTypes = propTypes; Hotkeys.propTypes = propTypes;
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(Hotkeys);
mapStateToProps,
mapDispatchToProps
)(Hotkeys);

View File

@ -63,7 +63,4 @@ class Preview extends Component {
Preview.displayName = 'Preview'; Preview.displayName = 'Preview';
Preview.propTypes = propTypes; Preview.propTypes = propTypes;
export default connect( export default connect(null, mapDispatchToProps)(withTranslation()(Preview));
null,
mapDispatchToProps
)(withTranslation()(Preview));

View File

@ -18,12 +18,9 @@ const propTypes = {
reset: PropTypes.func.isRequired reset: PropTypes.func.isRequired
}; };
const mapStateToProps = createSelector( const mapStateToProps = createSelector(isResetModalOpenSelector, isOpen => ({
isResetModalOpenSelector, isOpen
isOpen => ({ }));
isOpen
})
);
const mapDispatchToProps = dispatch => const mapDispatchToProps = dispatch =>
bindActionCreators( bindActionCreators(
@ -80,7 +77,4 @@ function ResetModal({ reset, close, isOpen }) {
ResetModal.displayName = 'ResetModal'; ResetModal.displayName = 'ResetModal';
ResetModal.propTypes = propTypes; ResetModal.propTypes = propTypes;
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(ResetModal);
mapStateToProps,
mapDispatchToProps
)(ResetModal);

View File

@ -47,7 +47,10 @@ export class SidePanel extends Component {
// users navigate from another challenge // users navigate from another challenge
MathJax.Hub.Config({ MathJax.Hub.Config({
tex2jax: { tex2jax: {
inlineMath: [['$', '$'], ['\\(', '\\)']], inlineMath: [
['$', '$'],
['\\(', '\\)']
],
processEscapes: true, processEscapes: true,
processClass: 'rosetta-code|project-euler' processClass: 'rosetta-code|project-euler'
} }

View File

@ -105,7 +105,4 @@ function ToolPanel({
ToolPanel.displayName = 'ToolPanel'; ToolPanel.displayName = 'ToolPanel';
ToolPanel.propTypes = propTypes; ToolPanel.propTypes = propTypes;
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(ToolPanel);
mapStateToProps,
mapDispatchToProps
)(ToolPanel);

View File

@ -43,11 +43,7 @@ const padContentWithCssCatch = partial(compileHeadTail, cssCatch);
export const jsToHtml = cond([ export const jsToHtml = cond([
[ [
matchesProperty('ext', 'js'), matchesProperty('ext', 'js'),
flow( flow(padContentWithJsCatch, wrapInScript, setExtToHTML)
padContentWithJsCatch,
wrapInScript,
setExtToHTML
)
], ],
[stubTrue, identity] [stubTrue, identity]
]); ]);
@ -55,11 +51,7 @@ export const jsToHtml = cond([
export const cssToHtml = cond([ export const cssToHtml = cond([
[ [
matchesProperty('ext', 'css'), matchesProperty('ext', 'css'),
flow( flow(padContentWithCssCatch, wrapInStyle, setExtToHTML)
padContentWithCssCatch,
wrapInStyle,
setExtToHTML
)
], ],
[stubTrue, identity] [stubTrue, identity]
]); ]);

View File

@ -29,7 +29,7 @@ const nestedJQCallReg = /\$\s*?\(\s*?\$\s*?\)/gi;
const throwIfNestedJquery = cond([ const throwIfNestedJquery = cond([
[ [
testHTMLJS, testHTMLJS,
function({ contents }) { function ({ contents }) {
if (nestedJQCallReg.test(contents)) { if (nestedJQCallReg.test(contents)) {
throw new SyntaxError('Nested jQuery calls breaks browsers'); throw new SyntaxError('Nested jQuery calls breaks browsers');
} }
@ -44,7 +44,7 @@ const functionCallReg = /function\s*?\(|function\s+\w+\s*?\(/gi;
const ThrowIfUnfinishedFunction = cond([ const ThrowIfUnfinishedFunction = cond([
[ [
testHTMLJS, testHTMLJS,
function({ contents }) { function ({ contents }) {
if (functionReg.test(contents) && !functionCallReg.test(contents)) { if (functionReg.test(contents) && !functionCallReg.test(contents)) {
throw new SyntaxError('Unsafe or unfinished function declaration'); throw new SyntaxError('Unsafe or unfinished function declaration');
} }
@ -58,7 +58,7 @@ const unsafeConsoleCallReg = /if\s\(null\)\sconsole\.log\(1\);/gi;
const throwIfUnsafeConsoleCall = cond([ const throwIfUnsafeConsoleCall = cond([
[ [
testHTMLJS, testHTMLJS,
function({ contents }) { function ({ contents }) {
if (unsafeConsoleCallReg.test(contents)) { if (unsafeConsoleCallReg.test(contents)) {
throw new SyntaxError( throw new SyntaxError(
'`if (null) console.log(1)` detected. This will break tests' '`if (null) console.log(1)` detected. This will break tests'
@ -74,7 +74,7 @@ const goMixReg = /glitch\.(com|me)/gi;
const throwIfGomixDetected = cond([ const throwIfGomixDetected = cond([
[ [
testHTMLJS, testHTMLJS,
function({ contents }) { function ({ contents }) {
if (goMixReg.test(contents)) { if (goMixReg.test(contents)) {
throw new Error('Glitch.com or Glitch.me should not be in the code'); throw new Error('Glitch.com or Glitch.me should not be in the code');
} }

View File

@ -199,7 +199,7 @@ async function transformScript(element) {
}); });
} }
const transformHtml = async function(file) { const transformHtml = async function (file) {
const div = document.createElement('div'); const div = document.createElement('div');
div.innerHTML = file.contents; div.innerHTML = file.contents;
await Promise.all([transformSASS(div), transformScript(div)]); await Promise.all([transformSASS(div), transformScript(div)]);

View File

@ -3,10 +3,7 @@ import { ofType } from 'redux-observable';
import { types, unlockCode } from './'; import { types, unlockCode } from './';
function codeLockEpic(action$) { function codeLockEpic(action$) {
return action$.pipe( return action$.pipe(ofType(types.updateFile), map(unlockCode));
ofType(types.updateFile),
map(unlockCode)
);
} }
export default codeLockEpic; export default codeLockEpic;

View File

@ -58,9 +58,11 @@ function createQuestionEpic(action$, state$, { window }) {
? `**Your project link(s)**\n` ? `**Your project link(s)**\n`
: `**Your code so far**` : `**Your code so far**`
} }
${projectFormValues ${
?.map(([key, val]) => `${key}: ${val}\n`) projectFormValues
?.join('') || filesToMarkdown(files)} ?.map(([key, val]) => `${key}: ${val}\n`)
?.join('') || filesToMarkdown(files)
}
${endingText}` ${endingText}`
); );

View File

@ -74,9 +74,9 @@ export function* executeChallengeSaga({
yield put(initLogs()); yield put(initLogs());
yield put(initConsole(i18next.t('learn.running-tests'))); yield put(initConsole(i18next.t('learn.running-tests')));
// reset tests to initial state // reset tests to initial state
const tests = (yield select(challengeTestsSelector)).map( const tests = (yield select(
({ text, testString }) => ({ text, testString }) challengeTestsSelector
); )).map(({ text, testString }) => ({ text, testString }));
yield put(updateTests(tests)); yield put(updateTests(tests));
yield fork(takeEveryLog, consoleProxy); yield fork(takeEveryLog, consoleProxy);
@ -116,7 +116,7 @@ export function* executeChallengeSaga({
function* takeEveryLog(channel) { function* takeEveryLog(channel) {
// TODO: move all stringifying and escaping into the reducer so there is a // TODO: move all stringifying and escaping into the reducer so there is a
// single place responsible for formatting the logs. // single place responsible for formatting the logs.
yield takeEvery(channel, function*(args) { yield takeEvery(channel, function* (args) {
yield put(updateLogs(escape(args))); yield put(updateLogs(escape(args)));
}); });
} }
@ -124,7 +124,7 @@ function* takeEveryLog(channel) {
function* takeEveryConsole(channel) { function* takeEveryConsole(channel) {
// TODO: move all stringifying and escaping into the reducer so there is a // TODO: move all stringifying and escaping into the reducer so there is a
// single place responsible for formatting the console output. // single place responsible for formatting the console output.
yield takeEvery(channel, function*(args) { yield takeEvery(channel, function* (args) {
yield put(updateConsole(escape(args))); yield put(updateConsole(escape(args)));
}); });
} }

View File

@ -29,7 +29,7 @@ const globalRequires = [
]; ];
const applyFunction = fn => const applyFunction = fn =>
async function(file) { async function (file) {
try { try {
if (file.error) { if (file.error) {
return file; return file;

View File

@ -49,7 +49,7 @@ const createHeader = (id = mainId) => `
</script> </script>
`; `;
export const runTestInTestFrame = async function(document, test, timeout) { export const runTestInTestFrame = async function (document, test, timeout) {
const { contentDocument: frame } = document.getElementById(testId); const { contentDocument: frame } = document.getElementById(testId);
return await Promise.race([ return await Promise.race([
new Promise((_, reject) => setTimeout(() => reject('timeout'), timeout)), new Promise((_, reject) => setTimeout(() => reject('timeout'), timeout)),
@ -115,7 +115,7 @@ const initMainFrame = (frameReady, proxyLogger) => ctx => {
// Overwriting the onerror added by createHeader to catch any errors thrown // Overwriting the onerror added by createHeader to catch any errors thrown
// after the frame is ready. It has to be overwritten, as proxyLogger cannot // after the frame is ready. It has to be overwritten, as proxyLogger cannot
// be added as part of createHeader. // be added as part of createHeader.
ctx.window.onerror = function(msg) { ctx.window.onerror = function (msg) {
var string = msg.toLowerCase(); var string = msg.toLowerCase();
if (string.includes('script error')) { if (string.includes('script error')) {
msg = 'Error, open your browser console to learn more.'; msg = 'Error, open your browser console to learn more.';

View File

@ -65,7 +65,7 @@ class WorkerExecutor {
execute(data, timeout = 1000) { execute(data, timeout = 1000) {
const task = eventify({}); const task = eventify({});
task._execute = function(getWorker) { task._execute = function (getWorker) {
getWorker().then( getWorker().then(
worker => { worker => {
task._worker = worker; task._worker = worker;

View File

@ -3,7 +3,7 @@
import createWorker from './worker-executor'; import createWorker from './worker-executor';
function mockWorker({ init, postMessage, terminate } = {}) { function mockWorker({ init, postMessage, terminate } = {}) {
global.Worker = jest.fn(function() { global.Worker = jest.fn(function () {
setImmediate( setImmediate(
(init && init(this)) || (init && init(this)) ||
(() => (() =>
@ -12,7 +12,7 @@ function mockWorker({ init, postMessage, terminate } = {}) {
this.onmessage = null; this.onmessage = null;
this.postMessage = this.postMessage =
postMessage || postMessage ||
function(data) { function (data) {
setImmediate( setImmediate(
() => this.onmessage && this.onmessage({ data: `${data} processed` }) () => this.onmessage && this.onmessage({ data: `${data} processed` })
); );
@ -169,7 +169,7 @@ it('Worker executor should reject task', async () => {
it('Worker executor should emit LOG events', async () => { it('Worker executor should emit LOG events', async () => {
mockWorker({ mockWorker({
postMessage: function(data) { postMessage: function (data) {
setImmediate(() => { setImmediate(() => {
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
// eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions

View File

@ -18,12 +18,9 @@ const propTypes = {
}; };
const mapStateToProps = state => { const mapStateToProps = state => {
return createSelector( return createSelector(userSelector, user => ({
userSelector, user
user => ({ }))(state);
user
})
)(state);
}; };
export class CertChallenge extends Component { export class CertChallenge extends Component {

View File

@ -11,12 +11,9 @@ import GreenPass from '../../../assets/icons/GreenPass';
import GreenNotCompleted from '../../../assets/icons/GreenNotCompleted'; import GreenNotCompleted from '../../../assets/icons/GreenNotCompleted';
const mapStateToProps = state => { const mapStateToProps = state => {
return createSelector( return createSelector(completedChallengesSelector, completedChallenges => ({
completedChallengesSelector, completedChallenges: completedChallenges.map(({ id }) => id)
completedChallenges => ({ }))(state);
completedChallenges: completedChallenges.map(({ id }) => id)
})
)(state);
}; };
const mapDispatchToProps = dispatch => const mapDispatchToProps = dispatch =>

View File

@ -16,12 +16,7 @@ function prototyper(str) {
.map(str => { .map(str => {
if (prototypeRE.test(str)) { if (prototypeRE.test(str)) {
if (str.length > 9) { if (str.length > 9) {
return prototyper( return prototyper(str.trim().split('prototype').join('-prototype-'));
str
.trim()
.split('prototype')
.join('-prototype-')
);
} }
return str; return str;
} }
@ -39,12 +34,7 @@ function prototyper(str) {
return `${titleify(first)}.prototype.${finalSecond}`; return `${titleify(first)}.prototype.${finalSecond}`;
} }
if (noProto.length === 1) { if (noProto.length === 1) {
return prototyper( return prototyper(noProto[0].toLowerCase().split('.').join('-'));
noProto[0]
.toLowerCase()
.split('.')
.join('-')
);
} }
return titleify(str, true); return titleify(str, true);
} }

View File

@ -53,22 +53,22 @@ const donationSubscriptionConfig = {
const paypalConfigTypes = { const paypalConfigTypes = {
live: { live: {
month: { month: {
'500': { planId: 'P-1L11422374370240ULZKX3PA' }, 500: { planId: 'P-1L11422374370240ULZKX3PA' },
'1000': { planId: 'P-61K21421WY874920PL6E36YI' }, 1000: { planId: 'P-61K21421WY874920PL6E36YI' },
'2000': { planId: 'P-31999436LF709112VL6E374A' }, 2000: { planId: 'P-31999436LF709112VL6E374A' },
'3000': { planId: 'P-1KY930839N8045117L6E4BKY' }, 3000: { planId: 'P-1KY930839N8045117L6E4BKY' },
'4000': { planId: 'P-0JW4843250567551AL6E4CAI' }, 4000: { planId: 'P-0JW4843250567551AL6E4CAI' },
'5000': { planId: 'P-0WR49877YD949401BL6E4CTA' } 5000: { planId: 'P-0WR49877YD949401BL6E4CTA' }
} }
}, },
staging: { staging: {
month: { month: {
'500': { planId: 'P-37N14480BW163382FLZYPVMA' }, 500: { planId: 'P-37N14480BW163382FLZYPVMA' },
'1000': { planId: 'P-28B62039J8092810UL6E3FXA' }, 1000: { planId: 'P-28B62039J8092810UL6E3FXA' },
'2000': { planId: 'P-7HR706961M9170433L6HI5VI' }, 2000: { planId: 'P-7HR706961M9170433L6HI5VI' },
'3000': { planId: 'P-35V33574BU596924JL6HI6XY' }, 3000: { planId: 'P-35V33574BU596924JL6HI6XY' },
'4000': { planId: 'P-45M45060289267734L6HJSXA' }, 4000: { planId: 'P-45M45060289267734L6HJSXA' },
'5000': { planId: 'P-0MD70861FY4172444L6HJTUQ' } 5000: { planId: 'P-0MD70861FY4172444L6HJTUQ' }
} }
} }
}; };

View File

@ -25,10 +25,7 @@ const schema = Joi.object()
block: Joi.string().regex(slugRE), block: Joi.string().regex(slugRE),
blockId: Joi.objectId(), blockId: Joi.objectId(),
challengeOrder: Joi.number(), challengeOrder: Joi.number(),
challengeType: Joi.number() challengeType: Joi.number().min(0).max(11).required(),
.min(0)
.max(11)
.required(),
checksum: Joi.number(), checksum: Joi.number(),
// TODO: require this only for normal challenges, not certs // TODO: require this only for normal challenges, not certs
dashedName: Joi.string().regex(slugRE), dashedName: Joi.string().regex(slugRE),
@ -62,9 +59,7 @@ const schema = Joi.object()
}), }),
question: Joi.object().keys({ question: Joi.object().keys({
text: Joi.string().required(), text: Joi.string().required(),
answers: Joi.array() answers: Joi.array().items(Joi.string()).required(),
.items(Joi.string())
.required(),
solution: Joi.number().required() solution: Joi.number().required()
}), }),
required: Joi.array().items( required: Joi.array().items(
@ -92,9 +87,7 @@ const schema = Joi.object()
Joi.object().keys({ Joi.object().keys({
id: Joi.string().allow(''), id: Joi.string().allow(''),
text: Joi.string().required(), text: Joi.string().required(),
testString: Joi.string() testString: Joi.string().allow('').required()
.allow('')
.required()
}), }),
// our tests used in certification verification // our tests used in certification verification
Joi.object().keys({ Joi.object().keys({

View File

@ -91,7 +91,7 @@ const dom = new jsdom.JSDOM('');
global.document = dom.window.document; global.document = dom.window.document;
const oldRunnerFail = Mocha.Runner.prototype.fail; const oldRunnerFail = Mocha.Runner.prototype.fail;
Mocha.Runner.prototype.fail = function(test, err) { Mocha.Runner.prototype.fail = function (test, err) {
if (err instanceof AssertionError) { if (err instanceof AssertionError) {
const errMessage = String(err.message || ''); const errMessage = String(err.message || '');
const assertIndex = errMessage.indexOf(': expected'); const assertIndex = errMessage.indexOf(': expected');
@ -198,9 +198,9 @@ async function setup() {
for (const challenge of challenges) { for (const challenge of challenges) {
const dashedBlockName = challenge.block; const dashedBlockName = challenge.block;
if (!meta[dashedBlockName]) { if (!meta[dashedBlockName]) {
meta[dashedBlockName] = (await getMetaForBlock( meta[dashedBlockName] = (
dashedBlockName await getMetaForBlock(dashedBlockName)
)).challengeOrder; ).challengeOrder;
} }
} }
return { return {
@ -221,8 +221,8 @@ function cleanup() {
} }
function runTests(challengeData) { function runTests(challengeData) {
describe('Check challenges', function() { describe('Check challenges', function () {
after(function() { after(function () {
cleanup(); cleanup();
}); });
populateTestsForLang(challengeData); populateTestsForLang(challengeData);
@ -252,15 +252,15 @@ function populateTestsForLang({ lang, challenges, meta }) {
const challengeTitles = new ChallengeTitles(); const challengeTitles = new ChallengeTitles();
const validateChallenge = challengeSchemaValidator(); const validateChallenge = challengeSchemaValidator();
describe(`Check challenges (${lang})`, function() { describe(`Check challenges (${lang})`, function () {
this.timeout(5000); this.timeout(5000);
challenges.forEach((challenge, id) => { challenges.forEach((challenge, id) => {
const dashedBlockName = challenge.block; const dashedBlockName = challenge.block;
describe(challenge.block || 'No block', function() { describe(challenge.block || 'No block', function () {
describe(challenge.title || 'No title', function() { describe(challenge.title || 'No title', function () {
// Note: the title in meta.json are purely for human readability and // Note: the title in meta.json are purely for human readability and
// do not include translations, so we do not validate against them. // do not include translations, so we do not validate against them.
it('Matches an ID in meta.json', function() { it('Matches an ID in meta.json', function () {
const index = meta[dashedBlockName].findIndex( const index = meta[dashedBlockName].findIndex(
arr => arr[0] === challenge.id arr => arr[0] === challenge.id
); );
@ -272,7 +272,7 @@ function populateTestsForLang({ lang, challenges, meta }) {
} }
}); });
it('Common checks', function() { it('Common checks', function () {
const result = validateChallenge(challenge); const result = validateChallenge(challenge);
if (result.error) { if (result.error) {
@ -374,9 +374,9 @@ function populateTestsForLang({ lang, challenges, meta }) {
return; return;
} }
describe('Check tests syntax', function() { describe('Check tests syntax', function () {
tests.forEach(test => { tests.forEach(test => {
it(`Check for: ${test.text}`, function() { it(`Check for: ${test.text}`, function () {
assert.doesNotThrow(() => new vm.Script(test.testString)); assert.doesNotThrow(() => new vm.Script(test.testString));
}); });
}); });
@ -393,7 +393,7 @@ function populateTestsForLang({ lang, challenges, meta }) {
? buildJSChallenge ? buildJSChallenge
: buildDOMChallenge; : buildDOMChallenge;
it('Test suite must fail on the initial contents', async function() { it('Test suite must fail on the initial contents', async function () {
this.timeout(5000 * tests.length + 1000); this.timeout(5000 * tests.length + 1000);
// suppress errors in the console. // suppress errors in the console.
const oldConsoleError = console.error; const oldConsoleError = console.error;
@ -473,9 +473,11 @@ function populateTestsForLang({ lang, challenges, meta }) {
return; return;
} }
describe('Check tests against solutions', function() { describe('Check tests against solutions', function () {
solutions.forEach((solution, index) => { solutions.forEach((solution, index) => {
it(`Solution ${index + 1} must pass the tests`, async function() { it(`Solution ${
index + 1
} must pass the tests`, async function () {
this.timeout(5000 * tests.length + 2000); this.timeout(5000 * tests.length + 2000);
const testRunner = await createTestRunner( const testRunner = await createTestRunner(
challenge, challenge,

View File

@ -1,7 +1,7 @@
/* global cy */ /* global cy */
describe('A certification,', function() { describe('A certification,', function () {
describe('while viewing your own,', function() { describe('while viewing your own,', function () {
before(() => { before(() => {
cy.visit('/'); cy.visit('/');
cy.contains("Get started (it's free)").click({ force: true }); cy.contains("Get started (it's free)").click({ force: true });
@ -51,7 +51,7 @@ describe('A certification,', function() {
.click({ force: true }); .click({ force: true });
}); });
it('should render a LinkedIn button', function() { it('should render a LinkedIn button', function () {
cy.contains('Add this certification to my LinkedIn profile') cy.contains('Add this certification to my LinkedIn profile')
.should('have.attr', 'href') .should('have.attr', 'href')
.and( .and(
@ -61,7 +61,7 @@ describe('A certification,', function() {
); );
}); });
it('should render a Twitter button', function() { it('should render a Twitter button', function () {
cy.contains('Share this certification on Twitter').should( cy.contains('Share this certification on Twitter').should(
'have.attr', 'have.attr',
'href', 'href',
@ -78,20 +78,20 @@ describe('A certification,', function() {
}); });
}); });
describe("while viewing someone else's,", function() { describe("while viewing someone else's,", function () {
before(() => { before(() => {
cy.go('back'); cy.go('back');
cy.contains('Sign me out of freeCodeCamp').click({ force: true }); cy.contains('Sign me out of freeCodeCamp').click({ force: true });
cy.visit('/certification/developmentuser/legacy-front-end'); cy.visit('/certification/developmentuser/legacy-front-end');
}); });
it('should not render a LinkedIn button', function() { it('should not render a LinkedIn button', function () {
cy.contains('Add this certification to my LinkedIn profile').should( cy.contains('Add this certification to my LinkedIn profile').should(
'not.exist' 'not.exist'
); );
}); });
it('should not render a Twitter button', function() { it('should not render a Twitter button', function () {
cy.contains('Share this certification on Twitter').should('not.exist'); cy.contains('Share this certification on Twitter').should('not.exist');
}); });
}); });

View File

@ -43,43 +43,28 @@ describe('Landing page', () => {
}); });
it('Has 5 brand logos', () => { it('Has 5 brand logos', () => {
cy.get('.logo-row') cy.get('.logo-row').children().its('length').should('eq', 5);
.children()
.its('length')
.should('eq', 5);
}); });
it('Has `as seens as` section', () => { it('Has `as seens as` section', () => {
cy.contains('Build projects.').should('be.visible'); cy.contains('Build projects.').should('be.visible');
cy.get('.big-heading') cy.get('.big-heading').siblings().get('svg');
.siblings()
.get('svg');
}); });
it('Has a visible large image on large viewports', function() { it('Has a visible large image on large viewports', function () {
cy.viewport(1200, 660) cy.viewport(1200, 660).get(selectors.landingPageImage).should('be.visible');
.get(selectors.landingPageImage)
.should('be.visible');
cy.viewport(1199, 660) cy.viewport(1199, 660).get(selectors.landingPageImage).should('not.exist');
.get(selectors.landingPageImage)
.should('not.exist');
}); });
it('Has links to all the certifications', function() { it('Has links to all the certifications', function () {
cy.get(selectors.certifications) cy.get(selectors.certifications).children().its('length').should('eq', 10);
.children()
.its('length')
.should('eq', 10);
cy.wrap(certifications).each(cert => { cy.wrap(certifications).each(cert => {
cy.get(selectors.certifications).contains(cert); cy.get(selectors.certifications).contains(cert);
}); });
}); });
it('Has 3 testimonial cards', function() { it('Has 3 testimonial cards', function () {
cy.get(selectors.testimonials) cy.get(selectors.testimonials).children().its('length').should('eq', 3);
.children()
.its('length')
.should('eq', 3);
}); });
}); });

View File

@ -15,7 +15,7 @@ const unhandledErrorMessage = 'Something is not quite right';
const runningOutput = '// running tests'; const runningOutput = '// running tests';
const finishedOutput = '// tests completed'; const finishedOutput = '// tests completed';
describe('Backend challenge', function() { describe('Backend challenge', function () {
it('renders', () => { it('renders', () => {
cy.visit(locations.index); cy.visit(locations.index);

View File

@ -23,7 +23,7 @@ const defaultOutput = `
// const runningOutput = '// running tests'; // const runningOutput = '// running tests';
// const finishedOutput = '// tests completed'; // const finishedOutput = '// tests completed';
describe('Classic challenge', function() { describe('Classic challenge', function () {
it('renders', () => { it('renders', () => {
cy.visit(locations.index); cy.visit(locations.index);

View File

@ -12,7 +12,7 @@ const selectors = {
let appHasStarted; let appHasStarted;
function spyOnListener(win) { function spyOnListener(win) {
const addListener = win.EventTarget.prototype.addEventListener; const addListener = win.EventTarget.prototype.addEventListener;
win.EventTarget.prototype.addEventListener = function(name) { win.EventTarget.prototype.addEventListener = function (name) {
if (name === 'click') { if (name === 'click') {
appHasStarted = true; appHasStarted = true;
win.EventTarget.prototype.addEventListener = addListener; win.EventTarget.prototype.addEventListener = addListener;
@ -68,9 +68,7 @@ describe('Navbar', () => {
() => { () => {
cy.get(selectors.menuButton).click(); cy.get(selectors.menuButton).click();
cy.get(selectors.navigationLinks).contains('Forum'); cy.get(selectors.navigationLinks).contains('Forum');
cy.get(selectors.navigationLinks) cy.get(selectors.navigationLinks).contains('Curriculum').click();
.contains('Curriculum')
.click();
cy.url().should('include', '/learn'); cy.url().should('include', '/learn');
cy.get(selectors.navigationLinks).contains('Curriculum'); cy.get(selectors.navigationLinks).contains('Curriculum');
cy.get(selectors.navigationLinks).contains('Forum'); cy.get(selectors.navigationLinks).contains('Forum');
@ -84,9 +82,7 @@ describe('Navbar', () => {
() => { () => {
cy.contains(selectors.smallCallToAction, 'Sign in'); cy.contains(selectors.smallCallToAction, 'Sign in');
cy.get(selectors.menuButton).click(); cy.get(selectors.menuButton).click();
cy.get(selectors.navigationLinks) cy.get(selectors.navigationLinks).contains('Curriculum').click();
.contains('Curriculum')
.click();
cy.contains(selectors.smallCallToAction, 'Sign in'); cy.contains(selectors.smallCallToAction, 'Sign in');
} }
); );
@ -95,9 +91,7 @@ describe('Navbar', () => {
cy.login(); cy.login();
cy.get('a[href*="/settings"]').should('be.visible'); cy.get('a[href*="/settings"]').should('be.visible');
cy.get(selectors.menuButton).click(); cy.get(selectors.menuButton).click();
cy.get(selectors.navigationLinks) cy.get(selectors.navigationLinks).contains('Profile').click();
.contains('Profile')
.click();
cy.url().should('include', '/developmentuser'); cy.url().should('include', '/developmentuser');
}); });

View File

@ -30,17 +30,13 @@ describe('Search bar', () => {
it('Should accept input and display hits', () => { it('Should accept input and display hits', () => {
search('freeCodeCamp'); search('freeCodeCamp');
cy.get('.ais-Hits-list') cy.get('.ais-Hits-list').children().should('to.have.length.of.at.least', 1);
.children()
.should('to.have.length.of.at.least', 1);
}); });
it('Should clear hits when input is cleared', () => { it('Should clear hits when input is cleared', () => {
search('freeCodeCamp'); search('freeCodeCamp');
cy.get('.ais-Hits-list') cy.get('.ais-Hits-list').children().should('to.have.length.of.at.least', 1);
.children()
.should('to.have.length.of.at.least', 1);
clear(); clear();
@ -52,9 +48,7 @@ describe('Search bar', () => {
search('freeCodeCamp'); search('freeCodeCamp');
cy.get('.ais-Hits-list') cy.get('.ais-Hits-list').children().should('to.have.length.of', 8);
.children()
.should('to.have.length.of', 8);
}); });
it('Should show up to 5 hits when height < 768px', () => { it('Should show up to 5 hits when height < 768px', () => {
@ -62,17 +56,13 @@ describe('Search bar', () => {
search('freeCodeCamp'); search('freeCodeCamp');
cy.get('.ais-Hits-list') cy.get('.ais-Hits-list').children().should('to.have.length.of', 5);
.children()
.should('to.have.length.of', 5);
}); });
it('Should show no hits for queries that do not exist in the Algolia index', () => { it('Should show no hits for queries that do not exist in the Algolia index', () => {
search('testtttt'); search('testtttt');
cy.get('.ais-Hits-list') cy.get('.ais-Hits-list').children().should('to.have.length.of', 0);
.children()
.should('to.have.length.of', 0);
cy.contains('No tutorials found'); cy.contains('No tutorials found');
}); });

View File

@ -1,11 +1,11 @@
/* global cy */ /* global cy */
describe('The `Update my account settings` button works properly', function() { describe('The `Update my account settings` button works properly', function () {
beforeEach(() => { beforeEach(() => {
cy.login(); cy.login();
}); });
it('Should take user to their account settings when clicked', function() { it('Should take user to their account settings when clicked', function () {
cy.contains('Update my account settings').click(); cy.contains('Update my account settings').click();
cy.url().should('include', '/settings'); cy.url().should('include', '/settings');
}); });

View File

@ -13,7 +13,7 @@ const locations = {
'/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements' '/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
}; };
describe('challenges/superblock redirect', function() { describe('challenges/superblock redirect', function () {
it('redirects to learn/superblock', () => { it('redirects to learn/superblock', () => {
cy.visit(locations.chalSuper); cy.visit(locations.chalSuper);
@ -24,7 +24,7 @@ describe('challenges/superblock redirect', function() {
}); });
}); });
describe('challenges/superblock/block redirect', function() { describe('challenges/superblock/block redirect', function () {
it('redirects to learn/superblock/block', () => { it('redirects to learn/superblock/block', () => {
cy.visit(locations.chalBlock); cy.visit(locations.chalBlock);
@ -35,7 +35,7 @@ describe('challenges/superblock/block redirect', function() {
}); });
}); });
describe('challenges/superblock/block/challenge redirect', function() { describe('challenges/superblock/block/challenge redirect', function () {
it('redirects to learn/superblock/block/challenge', () => { it('redirects to learn/superblock/block/challenge', () => {
cy.visit(locations.chalChallenge); cy.visit(locations.chalChallenge);

View File

@ -61,7 +61,7 @@ const warningMessage =
'If the tests fail, try disabling your extensions for the most reliable ' + 'If the tests fail, try disabling your extensions for the most reliable ' +
'experience.'; 'experience.';
describe('Basic Css Introduction page', function() { describe('Basic Css Introduction page', function () {
it('renders', () => { it('renders', () => {
cy.visit(locations.index); cy.visit(locations.index);

View File

@ -96,9 +96,7 @@ describe('Username input field', () => {
'the URL to your profile and your certifications.' 'the URL to your profile and your certifications.'
).should('not.exist'); ).should('not.exist');
cy.get('@usernameForm') cy.get('@usernameForm').contains('Save').should('be.disabled');
.contains('Save')
.should('be.disabled');
}); });
it('Should not show anything if user types their current name', () => { it('Should not show anything if user types their current name', () => {
@ -106,9 +104,7 @@ describe('Username input field', () => {
.clear({ force: true }) .clear({ force: true })
.type('developmentuser', { force: true }); .type('developmentuser', { force: true });
cy.get('@usernameForm') cy.get('@usernameForm').contains('Save').should('be.disabled');
.contains('Save')
.should('be.disabled');
}); });
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
@ -117,9 +113,7 @@ describe('Username input field', () => {
.clear({ force: true }) .clear({ force: true })
.type('developmentuser', { force: true }); .type('developmentuser', { force: true });
cy.get('@usernameForm') cy.get('@usernameForm').contains('Save').should('be.disabled');
.contains('Save')
.should('be.disabled');
}); });
it('Should show warning if username includes invalid character', () => { it('Should show warning if username includes invalid character', () => {
@ -141,9 +135,7 @@ describe('Username input field', () => {
.clear({ force: true }) .clear({ force: true })
.type('Quincy Larson', { force: true }); .type('Quincy Larson', { force: true });
cy.get('@usernameForm') cy.get('@usernameForm').contains('Save').should('be.disabled');
.contains('Save')
.should('be.disabled');
}); });
it('Should change username if `Save` button is clicked', () => { it('Should change username if `Save` button is clicked', () => {
@ -153,9 +145,7 @@ describe('Username input field', () => {
cy.contains('Username is available'); cy.contains('Username is available');
cy.get('@usernameForm') cy.get('@usernameForm').contains('Save').click({ force: true });
.contains('Save')
.click({ force: true });
cy.contains('Account Settings for quincy').should('be.visible'); cy.contains('Account Settings for quincy').should('be.visible');
cy.resetUsername(); cy.resetUsername();

1746
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -71,8 +71,8 @@
"cypress": "^6.6.0", "cypress": "^6.6.0",
"debug": "^4.3.1", "debug": "^4.3.1",
"docsify-cli": "^4.4.3", "docsify-cli": "^4.4.3",
"eslint": "^5.16.0", "eslint": "^7.21.0",
"eslint-config-prettier": "^6.12.0", "eslint-config-prettier": "^8.1.0",
"eslint-plugin-babel": "^5.3.1", "eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-jsx-a11y": "^6.4.1",
@ -92,7 +92,7 @@
"markdownlint": "^0.21.0", "markdownlint": "^0.21.0",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"ora": "^3.4.0", "ora": "^3.4.0",
"prettier": "^1.18.2", "prettier": "^2.2.1",
"prismjs": "^1.23.0", "prismjs": "^1.23.0",
"readdirp-walk": "^1.7.0", "readdirp-walk": "^1.7.0",
"shx": "^0.3.3", "shx": "^0.3.3",

View File

@ -24,8 +24,10 @@ if (
start < 1 || start < 1 ||
start !== end - 1 start !== end - 1
) { ) {
throw 'Step not created. Steps specified must be' + throw (
' consecutive numbers and start step must be greater than 0.'; 'Step not created. Steps specified must be' +
' consecutive numbers and start step must be greater than 0.'
);
} }
const existingSteps = getExistingStepNums(projectPath); const existingSteps = getExistingStepNums(projectPath);

View File

@ -73,14 +73,8 @@ const reorderSteps = () => {
const projectPath = getProjectPath(); const projectPath = getProjectPath();
const projectName = process.env.CALLING_DIR const projectName = process.env.CALLING_DIR
? process.env.CALLING_DIR.split(path.sep) ? process.env.CALLING_DIR.split(path.sep).slice(-1).toString()
.slice(-1) : process.cwd().split(path.sep).slice(-1).toString();
.toString()
: process
.cwd()
.split(path.sep)
.slice(-1)
.toString();
const curriculumPath = process.env.CALLING_DIR const curriculumPath = process.env.CALLING_DIR
? '' ? ''
@ -187,8 +181,10 @@ const getExistingStepNums = projectPath => {
) { ) {
let stepNum = fileName.split('.')[0].split('-')[1]; let stepNum = fileName.split('.')[0].split('-')[1];
if (!/^\d{3}$/.test(stepNum)) { if (!/^\d{3}$/.test(stepNum)) {
throw `Step not created. File ${fileName} has a step number containing non-digits.` + throw (
' Please run reorder-steps script first.'; `Step not created. File ${fileName} has a step number containing non-digits.` +
' Please run reorder-steps script first.'
);
} }
stepNum = parseInt(stepNum, 10); stepNum = parseInt(stepNum, 10);
stepNums.push(stepNum); stepNums.push(stepNum);

View File

@ -51,7 +51,7 @@ exports.parseMD = function parseMD(filename) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const file = readSync(filename); const file = readSync(filename);
const tree = processor.parse(file); const tree = processor.parse(file);
processor.run(tree, file, function(err, node, file) { processor.run(tree, file, function (err, node, file) {
if (!err) { if (!err) {
delete file.contents; delete file.contents;
resolve(file.data); resolve(file.data);

View File

@ -90,14 +90,16 @@ function validateEditableMarkers({ value, position }) {
lines.forEach((line, index) => { lines.forEach((line, index) => {
if (line.match(twoMarkersRE)) { if (line.match(twoMarkersRE)) {
throw Error( throw Error(
`Line ${baseLineNumber + `Line ${
index} has two markers. Each line should only have one.` baseLineNumber + index
} has two markers. Each line should only have one.`
); );
} }
if (line.match(formattedMarkerRE)) { if (line.match(formattedMarkerRE)) {
throw Error( throw Error(
`Line ${baseLineNumber + `Line ${
index} has a malformed marker. It should be --fcc-editable-region--` baseLineNumber + index
} has a malformed marker. It should be --fcc-editable-region--`
); );
} }
}); });

View File

@ -11,9 +11,7 @@ const { editableRegionMarker } = require('./add-seed');
const tableAndStrikeThrough = require('./table-and-strikethrough'); const tableAndStrikeThrough = require('./table-and-strikethrough');
async function parse(file) { async function parse(file) {
return await remark() return await remark().use(tableAndStrikeThrough).parse(file);
.use(tableAndStrikeThrough)
.parse(file);
} }
function plugin() { function plugin() {

View File

@ -12,7 +12,7 @@ const usernameIsHttpStatusCode = {
const isNumeric = num => !isNaN(num); const isNumeric = num => !isNaN(num);
const validCharsRE = /^[a-zA-Z0-9\-_+]*$/; const validCharsRE = /^[a-zA-Z0-9\-_+]*$/;
const isHttpStatusCode = str => const isHttpStatusCode = str =>
isNumeric(str) && (parseInt(str, 10) >= 100 && parseInt(str, 10) <= 599); isNumeric(str) && parseInt(str, 10) >= 100 && parseInt(str, 10) <= 599;
const isValidUsername = str => { const isValidUsername = str => {
if (!validCharsRE.test(str)) return invalidCharError; if (!validCharsRE.test(str)) return invalidCharError;
if (str.length < 3) return usernameTooShort; if (str.length < 3) return usernameTooShort;