fix: order imports and remove circular dependencies (#41824)
* fix: remove circular dependency redux depended on templates/Challenges/redux and vice versa. This meant that import order mattered and confusing bugs could arise. (cherry picked from commit 7d67a4e70922bbb3051f2f9982dcc69e240d43dc) * feat: require imports to be in alphabetical order Import order generally does not matter, but there are edge cases (circular imports and css imports, for example) where changing order changes behaviour (cherry picked from commit b8d1393a91ec6e068caf8e8498a5c95df68c2b2c) * chore: order imports * fix: lift up challenge description + title comps This brings the classic Show closer to the others as they now all create the description and title components * fix: remove donation-saga/index circular import (cherry picked from commit 51a44ca668a700786d2744feffeae4fdba5fd207) * refactor: extract action-types from settings (cherry picked from commit 25e26124d691c84a0d0827d41dafb761c686fadd) * fix: lint errors * feat: prevent useless renames
This commit is contained in:
committed by
GitHub
parent
c7b27a53e7
commit
e118dda13a
@ -1,11 +1,11 @@
|
||||
import { Observable } from 'rx';
|
||||
import debug from 'debug';
|
||||
import { Observable } from 'rx';
|
||||
|
||||
import { observeMethod, observeQuery } from '../../server/utils/rx';
|
||||
import {
|
||||
createUserUpdatesFromProfile,
|
||||
getSocialProvider
|
||||
} from '../../server/utils/auth';
|
||||
import { observeMethod, observeQuery } from '../../server/utils/rx';
|
||||
|
||||
const log = debug('fcc:models:UserCredential');
|
||||
module.exports = function (UserCredential) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import dedent from 'dedent';
|
||||
import { Observable } from 'rx';
|
||||
// import debug from 'debug';
|
||||
import dedent from 'dedent';
|
||||
import { isEmail } from 'validator';
|
||||
|
||||
import { observeMethod, observeQuery } from '../../server/utils/rx';
|
||||
import { wrapHandledError } from '../../server/utils/create-handled-error.js';
|
||||
import { observeMethod, observeQuery } from '../../server/utils/rx';
|
||||
|
||||
// const log = debug('fcc:models:userIdent');
|
||||
|
||||
|
@ -5,18 +5,31 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import badwordFilter from 'bad-words';
|
||||
import debugFactory from 'debug';
|
||||
import dedent from 'dedent';
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
import generate from 'nanoid/generate';
|
||||
import { Observable } from 'rx';
|
||||
import uuid from 'uuid/v4';
|
||||
import moment from 'moment';
|
||||
import dedent from 'dedent';
|
||||
import debugFactory from 'debug';
|
||||
import { isEmail } from 'validator';
|
||||
import _ from 'lodash';
|
||||
import generate from 'nanoid/generate';
|
||||
import badwordFilter from 'bad-words';
|
||||
|
||||
import { blocklistedUsernames } from '../../../../config/constants';
|
||||
import { apiLocation } from '../../../../config/env.json';
|
||||
|
||||
import { wrapHandledError } from '../../server/utils/create-handled-error.js';
|
||||
import {
|
||||
setAccessTokenToResponse,
|
||||
removeCookies
|
||||
} from '../../server/utils/getSetAccessToken';
|
||||
import {
|
||||
normaliseUserFields,
|
||||
getProgress,
|
||||
publicUserProps
|
||||
} from '../../server/utils/publicUserProps';
|
||||
import { saveUser, observeMethod } from '../../server/utils/rx.js';
|
||||
import { getEmailSender } from '../../server/utils/url-utils';
|
||||
import {
|
||||
fixCompletedChallengeItem,
|
||||
getEncodedEmail,
|
||||
@ -26,20 +39,6 @@ import {
|
||||
renderSignInEmail
|
||||
} from '../utils';
|
||||
|
||||
import { blocklistedUsernames } from '../../../../config/constants';
|
||||
import { wrapHandledError } from '../../server/utils/create-handled-error.js';
|
||||
import { saveUser, observeMethod } from '../../server/utils/rx.js';
|
||||
import { getEmailSender } from '../../server/utils/url-utils';
|
||||
import {
|
||||
normaliseUserFields,
|
||||
getProgress,
|
||||
publicUserProps
|
||||
} from '../../server/utils/publicUserProps';
|
||||
import {
|
||||
setAccessTokenToResponse,
|
||||
removeCookies
|
||||
} from '../../server/utils/getSetAccessToken';
|
||||
|
||||
const log = debugFactory('fcc:models:user');
|
||||
const BROWNIEPOINTS_TIMEOUT = [1, 'hour'];
|
||||
const nanoidCharSet =
|
||||
|
@ -1,9 +1,9 @@
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../../.env') });
|
||||
|
||||
const createDebugger = require('debug');
|
||||
const nodemon = require('nodemon');
|
||||
const SmeeClient = require('smee-client');
|
||||
const createDebugger = require('debug');
|
||||
|
||||
const log = createDebugger('fcc:start:development');
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// this ensures node understands the future
|
||||
const _ = require('lodash');
|
||||
const createDebugger = require('debug');
|
||||
const _ = require('lodash');
|
||||
|
||||
const log = createDebugger('fcc:server:production-start');
|
||||
const startTime = Date.now();
|
||||
|
@ -1,20 +1,20 @@
|
||||
import passport from 'passport';
|
||||
import dedent from 'dedent';
|
||||
import { check } from 'express-validator';
|
||||
import { isEmail } from 'validator';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import passport from 'passport';
|
||||
import { isEmail } from 'validator';
|
||||
|
||||
import { jwtSecret } from '../../../../config/secrets';
|
||||
|
||||
import { decodeEmail } from '../../common/utils';
|
||||
import {
|
||||
createPassportCallbackAuthenticator,
|
||||
devSaveResponseAuthCookies,
|
||||
devLoginRedirect
|
||||
} from '../component-passport';
|
||||
import { ifUserRedirectTo, ifNoUserRedirectHome } from '../utils/middleware';
|
||||
import { wrapHandledError } from '../utils/create-handled-error.js';
|
||||
import { removeCookies } from '../utils/getSetAccessToken';
|
||||
import { decodeEmail } from '../../common/utils';
|
||||
import { ifUserRedirectTo, ifNoUserRedirectHome } from '../utils/middleware';
|
||||
import { getRedirectParams } from '../utils/redirection';
|
||||
|
||||
const passwordlessGetValidators = [
|
||||
|
@ -1,17 +1,10 @@
|
||||
import path from 'path';
|
||||
import debug from 'debug';
|
||||
import dedent from 'dedent';
|
||||
import _ from 'lodash';
|
||||
import loopback from 'loopback';
|
||||
import path from 'path';
|
||||
import dedent from 'dedent';
|
||||
import { Observable } from 'rx';
|
||||
import debug from 'debug';
|
||||
import { isEmail } from 'validator';
|
||||
import { reportError } from '../middlewares/sentry-error-handler.js';
|
||||
|
||||
import { ifNoUser401 } from '../utils/middleware';
|
||||
import { observeQuery } from '../utils/rx';
|
||||
|
||||
import { getChallenges } from '../utils/get-curriculum';
|
||||
|
||||
import {
|
||||
completionHours,
|
||||
certTypes,
|
||||
@ -22,6 +15,11 @@ import {
|
||||
oldDataVizId,
|
||||
superBlockCertTypeMap
|
||||
} from '../../../../config/certification-settings';
|
||||
import { reportError } from '../middlewares/sentry-error-handler.js';
|
||||
|
||||
import { getChallenges } from '../utils/get-curriculum';
|
||||
import { ifNoUser401 } from '../utils/middleware';
|
||||
import { observeQuery } from '../utils/rx';
|
||||
|
||||
const {
|
||||
legacyFrontEndChallengeId,
|
||||
|
@ -4,17 +4,17 @@
|
||||
* a db migration to fix all completedChallenges
|
||||
*
|
||||
*/
|
||||
import { Observable } from 'rx';
|
||||
import { isEmpty, pick, omit, find, uniqBy } from 'lodash';
|
||||
import debug from 'debug';
|
||||
import dedent from 'dedent';
|
||||
import { isEmpty, pick, omit, find, uniqBy } from 'lodash';
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { Observable } from 'rx';
|
||||
import isNumeric from 'validator/lib/isNumeric';
|
||||
import isURL from 'validator/lib/isURL';
|
||||
|
||||
import { ifNoUserSend } from '../utils/middleware';
|
||||
import { fixCompletedChallengeItem } from '../../common/utils';
|
||||
import { getChallenges } from '../utils/get-curriculum';
|
||||
import { ifNoUserSend } from '../utils/middleware';
|
||||
import {
|
||||
getRedirectParams,
|
||||
normalizeParams,
|
||||
|
@ -1,11 +1,11 @@
|
||||
import debug from 'debug';
|
||||
import keys from '../../../../config/secrets';
|
||||
import {
|
||||
getAsyncPaypalToken,
|
||||
verifyWebHook,
|
||||
updateUser,
|
||||
verifyWebHookType
|
||||
} from '../utils/donation';
|
||||
import keys from '../../../../config/secrets';
|
||||
|
||||
const log = debug('fcc:boot:donate');
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import debug from 'debug';
|
||||
import { check } from 'express-validator';
|
||||
|
||||
import { ifNoUser401, createValidatorErrorHandler } from '../utils/middleware';
|
||||
import { themes } from '../../common/utils/themes.js';
|
||||
import { alertTypes } from '../../common/utils/flash.js';
|
||||
import { isValidUsername } from '../../../../utils/validate';
|
||||
import { alertTypes } from '../../common/utils/flash.js';
|
||||
import { themes } from '../../common/utils/themes.js';
|
||||
import { ifNoUser401, createValidatorErrorHandler } from '../utils/middleware';
|
||||
|
||||
const log = debug('fcc:boot:settings');
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
import dedent from 'dedent';
|
||||
import debugFactory from 'debug';
|
||||
import dedent from 'dedent';
|
||||
import { body } from 'express-validator';
|
||||
import { pick } from 'lodash';
|
||||
import { Observable } from 'rx';
|
||||
import { body } from 'express-validator';
|
||||
|
||||
import { fixCompletedChallengeItem } from '../../common/utils';
|
||||
import { removeCookies } from '../utils/getSetAccessToken';
|
||||
import { ifNoUser401, ifNoUserRedirectHome } from '../utils/middleware';
|
||||
import {
|
||||
getProgress,
|
||||
normaliseUserFields,
|
||||
userPropsForSession
|
||||
} from '../utils/publicUserProps';
|
||||
import { fixCompletedChallengeItem } from '../../common/utils';
|
||||
import { ifNoUser401, ifNoUserRedirectHome } from '../utils/middleware';
|
||||
import { removeCookies } from '../utils/getSetAccessToken';
|
||||
import { trimTags } from '../utils/validators';
|
||||
import { getRedirectParams } from '../utils/redirection';
|
||||
import { trimTags } from '../utils/validators';
|
||||
|
||||
const log = debugFactory('fcc:boot:user');
|
||||
const sendNonUserToHome = ifNoUserRedirectHome();
|
||||
|
@ -1,12 +1,13 @@
|
||||
import passport from 'passport';
|
||||
// eslint-disable-next-line
|
||||
import {
|
||||
// prettier ignore
|
||||
PassportConfigurator
|
||||
} from '@freecodecamp/loopback-component-passport';
|
||||
import dedent from 'dedent';
|
||||
import passport from 'passport';
|
||||
|
||||
import { getUserById } from './utils/user-stats';
|
||||
import { availableLangs } from '../../../config/i18n/all-langs';
|
||||
import { jwtSecret } from '../../../config/secrets';
|
||||
import passportProviders from './passport-providers';
|
||||
import { setAccessTokenToResponse } from './utils/getSetAccessToken';
|
||||
import {
|
||||
@ -15,8 +16,7 @@ import {
|
||||
getRedirectParams,
|
||||
haveSamePath
|
||||
} from './utils/redirection';
|
||||
import { jwtSecret } from '../../../config/secrets';
|
||||
import { availableLangs } from '../../../config/i18n/all-langs';
|
||||
import { getUserById } from './utils/user-stats';
|
||||
|
||||
const passportOptions = {
|
||||
emailOptional: true,
|
||||
|
@ -1,12 +1,12 @@
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });
|
||||
|
||||
const Sentry = require('@sentry/node');
|
||||
const createDebugger = require('debug');
|
||||
const _ = require('lodash');
|
||||
const loopback = require('loopback');
|
||||
const boot = require('loopback-boot');
|
||||
const createDebugger = require('debug');
|
||||
const morgan = require('morgan');
|
||||
const Sentry = require('@sentry/node');
|
||||
|
||||
const { sentry } = require('../../../config/secrets');
|
||||
const { setupPassport } = require('./component-passport');
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { homeLocation } from '../../../../config/env.json';
|
||||
import { allowedOrigins } from '../../../../config/cors-settings';
|
||||
import { homeLocation } from '../../../../config/env.json';
|
||||
|
||||
export default function constantHeaders() {
|
||||
return function (req, res, next) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { Observable } from 'rx';
|
||||
import { login } from 'passport/lib/http/request';
|
||||
import { Observable } from 'rx';
|
||||
|
||||
// make login polymorphic
|
||||
// if supplied callback it works as normal
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
import { getUserById as _getUserById } from '../utils/user-stats';
|
||||
import { jwtSecret as _jwtSecret } from '../../../../config/secrets';
|
||||
|
||||
import { wrapHandledError } from '../utils/create-handled-error';
|
||||
import {
|
||||
getAccessTokenFromRequest,
|
||||
errorTypes,
|
||||
authHeaderNS
|
||||
} from '../utils/getSetAccessToken';
|
||||
import { jwtSecret as _jwtSecret } from '../../../../config/secrets';
|
||||
|
||||
import { wrapHandledError } from '../utils/create-handled-error';
|
||||
import { getRedirectParams } from '../utils/redirection';
|
||||
import { getUserById as _getUserById } from '../utils/user-stats';
|
||||
|
||||
const authRE = /^\/auth\//;
|
||||
const confirmEmailRE = /^\/confirm-email$/;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { mockReq as mockRequest, mockRes } from '../boot_tests/challenge.test';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
import { homeLocation } from '../../../../config/env.json';
|
||||
import { mockReq as mockRequest, mockRes } from '../boot_tests/challenge.test';
|
||||
import createRequestAuthorization, {
|
||||
isAllowedPath
|
||||
} from './request-authorization';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import session from 'express-session';
|
||||
import MongoStoreFactory from 'connect-mongo';
|
||||
import session from 'express-session';
|
||||
|
||||
const MongoStore = MongoStoreFactory(session);
|
||||
const sessionSecret = process.env.SESSION_SECRET;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Observable } from 'rx';
|
||||
import debug from 'debug';
|
||||
import { Observable } from 'rx';
|
||||
|
||||
import { reportError } from '../middlewares/sentry-error-handler.js';
|
||||
import InMemoryCache from '../utils/in-memory-cache';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { auth0 } from '../../../config/secrets';
|
||||
import { homeLocation, apiLocation } from '../../../config/env.json';
|
||||
import { auth0 } from '../../../config/secrets';
|
||||
|
||||
const { clientID, clientSecret, domain } = auth0;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import compareDesc from 'date-fns/compare_desc';
|
||||
import debug from 'debug';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { getLybsynFeed } from './lybsyn';
|
||||
|
||||
|
@ -1,14 +1,6 @@
|
||||
/* eslint-disable camelcase */
|
||||
import axios from 'axios';
|
||||
import keys from '../../../../config/secrets';
|
||||
import {
|
||||
getAsyncPaypalToken,
|
||||
verifyWebHook,
|
||||
updateUser,
|
||||
capitalizeKeys,
|
||||
createDonationObj
|
||||
} from './donation';
|
||||
import { mockActivationHook, mockCancellationHook } from './__mocks__/donation';
|
||||
import {
|
||||
mockApp,
|
||||
createDonationMockFn,
|
||||
@ -16,6 +8,14 @@ import {
|
||||
updateDonationAttr,
|
||||
updateUserAttr
|
||||
} from '../boot_tests/fixtures';
|
||||
import { mockActivationHook, mockCancellationHook } from './__mocks__/donation';
|
||||
import {
|
||||
getAsyncPaypalToken,
|
||||
verifyWebHook,
|
||||
updateUser,
|
||||
capitalizeKeys,
|
||||
createDonationObj
|
||||
} from './donation';
|
||||
|
||||
jest.mock('axios');
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { isBefore } from 'date-fns';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
import { jwtSecret as _jwtSecret } from '../../../../config/secrets';
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { mockReq, mockRes } from '../boot_tests/challenge.test';
|
||||
import {
|
||||
getAccessTokenFromRequest,
|
||||
errorTypes,
|
||||
setAccessTokenToResponse,
|
||||
removeCookies
|
||||
} from './getSetAccessToken';
|
||||
import { mockReq, mockRes } from '../boot_tests/challenge.test';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
describe('getSetAccessToken', () => {
|
||||
const validJWTSecret = 'this is a super secret string';
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { isURL } from 'validator';
|
||||
|
||||
import { addPlaceholderImage } from './';
|
||||
import {
|
||||
prepUniqueDaysByHours,
|
||||
calcCurrentStreak,
|
||||
calcLongestStreak
|
||||
} from '../utils/user-stats';
|
||||
import { addPlaceholderImage } from './';
|
||||
|
||||
export const publicUserProps = [
|
||||
'about',
|
||||
|
@ -1,9 +1,9 @@
|
||||
const jwt = require('jsonwebtoken');
|
||||
const { availableLangs } = require('../../../../config/i18n/all-langs');
|
||||
const { allowedOrigins } = require('../../../../config/cors-settings');
|
||||
// homeLocation is being used as a fallback here. If the one provided by the
|
||||
// client is invalid we default to this.
|
||||
const { homeLocation } = require('../../../../config/env.json');
|
||||
const { availableLangs } = require('../../../../config/i18n/all-langs');
|
||||
|
||||
function getReturnTo(encryptedParams, secret, _homeLocation = homeLocation) {
|
||||
let params;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Rx, { AsyncSubject, Observable } from 'rx';
|
||||
import moment from 'moment';
|
||||
import debugFactory from 'debug';
|
||||
import moment from 'moment';
|
||||
import Rx, { AsyncSubject, Observable } from 'rx';
|
||||
|
||||
const debug = debugFactory('fcc:rxUtils');
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import loopback from 'loopback';
|
||||
import { isEmpty } from 'lodash';
|
||||
import compose from 'lodash/fp/compose';
|
||||
import forEachRight from 'lodash/fp/forEachRight';
|
||||
import last from 'lodash/fp/last';
|
||||
import map from 'lodash/fp/map';
|
||||
import sortBy from 'lodash/fp/sortBy';
|
||||
import trans from 'lodash/fp/transform';
|
||||
import last from 'lodash/fp/last';
|
||||
import forEachRight from 'lodash/fp/forEachRight';
|
||||
import { isEmpty } from 'lodash';
|
||||
import loopback from 'loopback';
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
import { dayCount } from '../utils/date-utils';
|
||||
|
@ -1,12 +1,12 @@
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
import { mockUserID, mockApp, mockUser } from '../boot_tests/fixtures';
|
||||
import {
|
||||
prepUniqueDaysByHours,
|
||||
calcCurrentStreak,
|
||||
calcLongestStreak,
|
||||
getUserById
|
||||
} from './user-stats';
|
||||
import { mockUserID, mockApp, mockUser } from '../boot_tests/fixtures';
|
||||
|
||||
jest.useFakeTimers('modern');
|
||||
const PST = 'America/Los_Angeles';
|
||||
|
Reference in New Issue
Block a user