refactor: remove a lot of unused code (#48935)

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>
This commit is contained in:
Oliver Eyton-Williams
2023-01-07 06:03:35 +01:00
committed by GitHub
parent 2b2360d77f
commit 0a20f8fd73
32 changed files with 76 additions and 156 deletions
+3
View File
@@ -70,6 +70,7 @@
"final-form": "4.20.7",
"gatsby": "3.15.0",
"gatsby-cli": "3.15.0",
"gatsby-link": "3.15.0",
"gatsby-plugin-advanced-sitemap": "2.1.0",
"gatsby-plugin-create-client-paths": "3.15.0",
"gatsby-plugin-manifest": "3.15.0",
@@ -100,6 +101,7 @@
"react-helmet": "6.1.0",
"react-hotkeys": "2.0.0",
"react-i18next": "11.18.6",
"react-instantsearch-core": "6.38.2",
"react-instantsearch-dom": "6.38.1",
"react-lazy-load": "3.1.14",
"react-monaco-editor": "0.40.0",
@@ -133,6 +135,7 @@
"@babel/types": "7.20.7",
"@codesee/babel-plugin-instrument": "0.470.0",
"@codesee/tracker": "0.470.0",
"@faker-js/faker": "7.6.0",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"autoprefixer": "10.4.13",
@@ -59,10 +59,7 @@ const {
deploymentEnv: 'staging' | 'live';
};
export class PaypalButton extends Component<
PaypalButtonProps,
PaypalButtonState
> {
class PaypalButton extends Component<PaypalButtonProps, PaypalButtonState> {
static displayName = 'PaypalButton';
state: PaypalButtonState = {
amount: defaultDonation.donationAmount,
@@ -65,7 +65,7 @@ const mapDispatchToProps = {
openSignoutModal
};
export class NavLinks extends Component<NavLinksProps, NavlinkStates> {
class NavLinks extends Component<NavLinksProps, NavlinkStates> {
static displayName: string;
langButtonRef: React.RefObject<HTMLButtonElement>;
firstLangOptionRef: React.RefObject<HTMLButtonElement>;
-1
View File
@@ -23,7 +23,6 @@ export const actionTypes = createTypes(
'showCodeAlly',
'submitComplete',
'updateComplete',
'updateCurrentChallengeId',
'updateFailed',
'updateDonationFormState',
'updateUserToken',
-4
View File
@@ -90,9 +90,5 @@ export const hideCodeAlly = createAction(actionTypes.hideCodeAlly);
export const showCodeAlly = createAction(actionTypes.showCodeAlly);
export const tryToShowCodeAlly = createAction(actionTypes.tryToShowCodeAlly);
export const updateCurrentChallengeId = createAction(
actionTypes.updateCurrentChallengeId
);
export const closeSignoutModal = createAction(actionTypes.closeSignoutModal);
export const openSignoutModal = createAction(actionTypes.openSignoutModal);
+2 -2
View File
@@ -23,7 +23,7 @@ import { createShowCertSaga } from './show-cert-saga';
import updateCompleteEpic from './update-complete-epic';
import { createUserTokenSaga } from './user-token-saga';
export const defaultFetchState = {
const defaultFetchState = {
pending: true,
complete: false,
errored: false,
@@ -41,7 +41,7 @@ export const defaultDonationFormState = {
}
};
export const initialState = {
const initialState = {
appUsername: '',
recentlyClaimedBlock: null,
canRequestProgressDonation: true,
-70
View File
@@ -1,78 +1,8 @@
import PropTypes from 'prop-types';
import { HandlerProps } from 'react-reflex';
import { SuperBlocks } from '../../../config/certification-settings';
import { Themes } from '../components/settings/theme';
import { certMap } from '../resources/cert-and-project-map';
export const UserPropType = PropTypes.shape({
about: PropTypes.string,
completedChallenges: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string,
solution: PropTypes.string,
githubLink: PropTypes.string,
challengeType: PropTypes.number,
completedDate: PropTypes.number,
challengeFiles: PropTypes.array
})
),
email: PropTypes.string,
githubProfile: PropTypes.string,
is2018DataVisCert: PropTypes.bool,
isApisMicroservicesCert: PropTypes.bool,
isBackEndCert: PropTypes.bool,
isDataVisCert: PropTypes.bool,
isEmailVerified: PropTypes.bool,
isFrontEndCert: PropTypes.bool,
isFrontEndLibsCert: PropTypes.bool,
isFullStackCert: PropTypes.bool,
isHonest: PropTypes.bool,
isInfosecQaCert: PropTypes.bool,
isQaCertV7: PropTypes.bool,
isInfosecCertV7: PropTypes.bool,
isJsAlgoDataStructCert: PropTypes.bool,
isRelationalDatabaseCertV8: PropTypes.bool,
isRespWebDesignCert: PropTypes.bool,
isSciCompPyCertV7: PropTypes.bool,
isDataAnalysisPyCertV7: PropTypes.bool,
isMachineLearningPyCertV7: PropTypes.bool,
linkedin: PropTypes.string,
location: PropTypes.string,
name: PropTypes.string,
picture: PropTypes.string,
points: PropTypes.number,
portfolio: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
title: PropTypes.string,
url: PropTypes.string,
image: PropTypes.string,
description: PropTypes.string
})
),
savedChallenges: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string,
challengeFiles: PropTypes.array
})
),
sendQuincyEmail: PropTypes.bool,
sound: PropTypes.bool,
theme: PropTypes.string,
keyboardShortcuts: PropTypes.bool,
twitter: PropTypes.string,
username: PropTypes.string,
website: PropTypes.string
});
export const CurrentCertsPropType = PropTypes.arrayOf(
PropTypes.shape({
show: PropTypes.bool,
title: PropTypes.string,
certSlug: PropTypes.string
})
);
export type Steps = {
isHonest?: boolean;
currentCerts?: Array<CurrentCert>;
+1 -1
View File
@@ -17,7 +17,7 @@ import {
import { saveChallengeComplete } from './actions';
import { savedChallengesSelector } from './selectors';
export function* saveChallengeSaga() {
function* saveChallengeSaga() {
const { id, challengeType } = yield select(challengeMetaSelector);
const { challengeFiles } = yield select(challengeDataSelector);
const savedChallenges = yield select(savedChallengesSelector);
-2
View File
@@ -217,5 +217,3 @@ export const userSelector = state => {
return state[MainApp].user[username] || {};
};
export const sessionMetaSelector = state => state[MainApp].sessionMeta;
-14
View File
@@ -49,17 +49,3 @@ interface DefaultDonationFormState {
success: boolean;
error: null | string;
}
export const defaultFetchState = {
pending: true,
complete: false,
errored: false,
error: null
};
export const defaultDonationFormState = {
redirecting: false,
processing: false,
success: false,
error: ''
};
@@ -131,7 +131,7 @@ interface CompletionModalInnerState {
completedChallengesInBlock: number;
}
export class CompletionModalInner extends Component<
class CompletionModalInner extends Component<
CompletionModalsProps,
CompletionModalInnerState
> {
@@ -44,7 +44,7 @@ const generateSearchLink = (title: string, block: string) => {
return search;
};
export function HelpModal({
function HelpModal({
closeHelpModal,
createQuestion,
executeGA,
@@ -37,7 +37,7 @@ const mapDispatchToProps = (dispatch: Dispatch) =>
dispatch
);
export function ShortcutsModal({
function ShortcutsModal({
closeShortcutsModal,
toggleKeyboardShortcuts,
isOpen,
@@ -28,7 +28,7 @@ const mapDispatchToProps = (dispatch: Dispatch) =>
dispatch
);
export function VideoModal({
function VideoModal({
closeVideoModal,
executeGA,
isOpen,
@@ -24,7 +24,7 @@ interface ToolPanelProps {
t: TFunction;
}
export function ToolPanel({
function ToolPanel({
guideUrl,
openHelpModal,
t
@@ -99,9 +99,8 @@ const testJS = matchesProperty('ext', 'js');
const testJSX = matchesProperty('ext', 'jsx');
const testHTML = matchesProperty('ext', 'html');
const testHTML$JS$JSX = overSome(testHTML, testJS, testJSX);
export const testJS$JSX = overSome(testJS, testJSX);
export const replaceNBSP = cond([
const replaceNBSP = cond([
[
testHTML$JS$JSX,
partial(transformContents, contents => contents.replace(NBSPReg, ' '))
@@ -14,7 +14,6 @@ export const actionTypes = createTypes(
'updateConsole',
'updateChallengeMeta',
'updateFile',
'updateJSEnabled',
'updateSolutionFormValues',
'updateSuccessMessage',
'updateTests',
@@ -31,7 +31,6 @@ export const updateChallengeMeta = createAction(
export const updateFile = createAction(actionTypes.updateFile);
export const updateConsole = createAction(actionTypes.updateConsole);
export const updateLogs = createAction(actionTypes.updateLogs);
export const updateJSEnabled = createAction(actionTypes.updateJSEnabled);
export const updateSolutionFormValues = createAction(
actionTypes.updateSolutionFormValues
);
@@ -5,7 +5,7 @@ import { randomCompliment } from '../../../utils/get-words';
import { CURRENT_CHALLENGE_KEY } from './action-types';
import { updateSuccessMessage } from './actions';
export function* currentChallengeSaga({ payload: id }) {
function* currentChallengeSaga({ payload: id }) {
yield store.set(CURRENT_CHALLENGE_KEY, id);
// // Temporarily removed to reduce calls to database
// // will need to re-import things at the top
@@ -26,7 +26,7 @@ export function* currentChallengeSaga({ payload: id }) {
// }
}
export function* updateSuccessMessageSaga() {
function* updateSuccessMessageSaga() {
yield put(updateSuccessMessage(randomCompliment()));
}
@@ -57,7 +57,7 @@ import {
const previewTimeout = 2500;
// when 'run tests' is clicked, do this first
export function* executeCancellableChallengeSaga(payload) {
function* executeCancellableChallengeSaga(payload) {
const { challengeType, id } = yield select(challengeMetaSelector);
const { challengeFiles } = yield select(challengeDataSelector);
@@ -84,7 +84,7 @@ export function* executeCancellableChallengeSaga(payload) {
yield cancel(task);
}
export function* executeChallengeSaga({ payload }) {
function* executeChallengeSaga({ payload }) {
const isBuildEnabled = yield select(isBuildEnabledSelector);
if (!isBuildEnabled) {
return;
@@ -2,7 +2,6 @@ import { challengeTypes } from '../../../../utils/challenge-types';
import { completedChallengesSelector } from '../../../redux/selectors';
import { ns } from './action-types';
export const currentTabSelector = state => state[ns].currentTab;
export const challengeFilesSelector = state => state[ns].challengeFiles;
export const challengeMetaSelector = state => state[ns].challengeMeta;
export const challengeTestsSelector = state => state[ns].challengeTests;
@@ -250,7 +250,7 @@ export function buildJSChallenge(
}
}
export function buildBackendChallenge({ url }: BuildChallengeData) {
function buildBackendChallenge({ url }: BuildChallengeData) {
return {
challengeType: challengeTypes.backend,
build: concatHtml({ required: frameRunner }),
@@ -57,8 +57,7 @@ interface BlockProps {
t: TFunction;
toggleBlock: typeof toggleBlock;
}
export class Block extends Component<BlockProps> {
class Block extends Component<BlockProps> {
static displayName: string;
constructor(props: BlockProps) {
super(props);
@@ -140,8 +140,6 @@ const CertChallenge = ({
CertChallenge.displayName = 'CertChallenge';
export { CertChallenge };
export default connect(
mapStateToProps,
mapDispatchToProps
+1 -1
View File
@@ -1,4 +1,4 @@
import faker from 'faker';
import { faker } from '@faker-js/faker';
import { emailToABVariant } from './A-B-tester';
describe('client/src is-email-variation-a', () => {
-3
View File
@@ -31,6 +31,3 @@ export const isLocationSuperBlock = (
): boolean => {
return /^\/learn\/[\w-]+\/$/.test(location?.pathname ?? '');
};
const pathParsers = { isLanding, isChallenge };
export default pathParsers;
-6
View File
@@ -60,12 +60,6 @@ exports.isCodeAllyPractice = challengeType => {
return challengeType === codeAllyPractice;
};
// turn challengeType to file ext
exports.pathsMap = {
[html]: 'html',
[js]: 'js',
[jsProject]: 'js'
};
// determine the component view for each challenge
exports.viewTypes = {
[html]: 'classic',
+2 -3
View File
@@ -6,7 +6,8 @@
"src/html.tsx",
"src/pages/*.tsx",
"src/templates/Challenges/**/{s,S}how.tsx",
"src/templates/Introduction/**/{intro,super-block-intro}.tsx"
"src/templates/Introduction/**/{intro,super-block-intro}.tsx",
"**/*.test.{js,ts,tsx}"
],
"projectFiles": [
"**/*.{js,ts,tsx}",
@@ -17,8 +18,6 @@
"!src/client/frame-runner.ts",
"!src/client/workers/**",
"!webpack-workers.js",
"!**/*.test.{js,ts,tsx}",
"!**/i18n/config-for-tests.ts",
"!**/__mocks__/**",
"!**/__fixtures/**",
"!**/node_modules/**",
+48 -20
View File
@@ -43,7 +43,6 @@
"@types/enzyme-adapter-react-16": "1.0.6",
"@types/eslint": "7.29.0",
"@types/estree": "0.0.52",
"@types/faker": "5.5.9",
"@types/inquirer": "8.2.5",
"@types/jest": "27.5.2",
"@types/jquery": "3.5.16",
@@ -87,7 +86,6 @@
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-testing-library": "4.12.4",
"execa": "5.1.1",
"faker": "5.5.3",
"husky": "8.0.3",
"jest": "27.5.1",
"js-yaml": "3.14.1",
@@ -462,6 +460,7 @@
"final-form": "4.20.7",
"gatsby": "3.15.0",
"gatsby-cli": "3.15.0",
"gatsby-link": "3.15.0",
"gatsby-plugin-advanced-sitemap": "2.1.0",
"gatsby-plugin-create-client-paths": "3.15.0",
"gatsby-plugin-manifest": "3.15.0",
@@ -492,6 +491,7 @@
"react-helmet": "6.1.0",
"react-hotkeys": "2.0.0",
"react-i18next": "11.18.6",
"react-instantsearch-core": "6.38.2",
"react-instantsearch-dom": "6.38.1",
"react-lazy-load": "3.1.14",
"react-monaco-editor": "0.40.0",
@@ -525,6 +525,7 @@
"@babel/types": "7.20.7",
"@codesee/babel-plugin-instrument": "0.470.0",
"@codesee/tracker": "0.470.0",
"@faker-js/faker": "7.6.0",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"autoprefixer": "10.4.13",
@@ -585,6 +586,21 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"client/node_modules/react-instantsearch-core": {
"version": "6.38.2",
"resolved": "https://registry.npmjs.org/react-instantsearch-core/-/react-instantsearch-core-6.38.2.tgz",
"integrity": "sha512-eX1FJQ7648mZgY+B79EghggjCHLLxiv/otQ7kgkXiHpU2XNfqEhweufqgwSEJH5gUgGUo4JsgHHWLoX56YvrDQ==",
"dependencies": {
"@babel/runtime": "^7.1.2",
"algoliasearch-helper": "^3.11.1",
"prop-types": "^15.6.2",
"react-fast-compare": "^3.0.0"
},
"peerDependencies": {
"algoliasearch": ">= 3.1 < 5",
"react": ">= 16.3.0 < 19"
}
},
"client/node_modules/react-monaco-editor": {
"version": "0.40.0",
"license": "MIT",
@@ -3181,6 +3197,16 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@faker-js/faker": {
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-7.6.0.tgz",
"integrity": "sha512-XK6BTq1NDMo9Xqw/YkYyGjSsg44fbNwYRx7QK2CuoQgyy+f1rrTDHoExVM5PsyXCtfl2vs2vVJ0MN0yN6LppRw==",
"dev": true,
"engines": {
"node": ">=14.0.0",
"npm": ">=6.0.0"
}
},
"node_modules/@fortawesome/fontawesome-common-types": {
"version": "6.2.1",
"hasInstallScript": true,
@@ -13874,11 +13900,6 @@
"@types/range-parser": "*"
}
},
"node_modules/@types/faker": {
"version": "5.5.9",
"dev": true,
"license": "MIT"
},
"node_modules/@types/get-port": {
"version": "3.2.0",
"license": "MIT"
@@ -25067,11 +25088,6 @@
"node": "> 0.1.90"
}
},
"node_modules/faker": {
"version": "5.5.3",
"dev": true,
"license": "MIT"
},
"node_modules/fast-copy": {
"version": "2.1.1",
"license": "MIT"
@@ -56029,6 +56045,12 @@
}
}
},
"@faker-js/faker": {
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-7.6.0.tgz",
"integrity": "sha512-XK6BTq1NDMo9Xqw/YkYyGjSsg44fbNwYRx7QK2CuoQgyy+f1rrTDHoExVM5PsyXCtfl2vs2vVJ0MN0yN6LppRw==",
"dev": true
},
"@fortawesome/fontawesome-common-types": {
"version": "6.2.1"
},
@@ -56423,6 +56445,7 @@
"@babel/types": "7.20.7",
"@codesee/babel-plugin-instrument": "0.470.0",
"@codesee/tracker": "0.470.0",
"@faker-js/faker": "7.6.0",
"@fortawesome/fontawesome-svg-core": "6.2.1",
"@fortawesome/free-brands-svg-icons": "6.2.1",
"@fortawesome/free-solid-svg-icons": "6.2.1",
@@ -56461,6 +56484,7 @@
"final-form": "4.20.7",
"gatsby": "3.15.0",
"gatsby-cli": "3.15.0",
"gatsby-link": "3.15.0",
"gatsby-plugin-advanced-sitemap": "2.1.0",
"gatsby-plugin-create-client-paths": "3.15.0",
"gatsby-plugin-manifest": "3.15.0",
@@ -56494,6 +56518,7 @@
"react-helmet": "6.1.0",
"react-hotkeys": "2.0.0",
"react-i18next": "11.18.6",
"react-instantsearch-core": "6.38.2",
"react-instantsearch-dom": "6.38.1",
"react-lazy-load": "3.1.14",
"react-monaco-editor": "0.40.0",
@@ -56552,6 +56577,17 @@
"strict-uri-encode": "^2.0.0"
}
},
"react-instantsearch-core": {
"version": "6.38.2",
"resolved": "https://registry.npmjs.org/react-instantsearch-core/-/react-instantsearch-core-6.38.2.tgz",
"integrity": "sha512-eX1FJQ7648mZgY+B79EghggjCHLLxiv/otQ7kgkXiHpU2XNfqEhweufqgwSEJH5gUgGUo4JsgHHWLoX56YvrDQ==",
"requires": {
"@babel/runtime": "^7.1.2",
"algoliasearch-helper": "^3.11.1",
"prop-types": "^15.6.2",
"react-fast-compare": "^3.0.0"
}
},
"react-monaco-editor": {
"version": "0.40.0",
"requires": {
@@ -64270,10 +64306,6 @@
"@types/range-parser": "*"
}
},
"@types/faker": {
"version": "5.5.9",
"dev": true
},
"@types/get-port": {
"version": "3.2.0"
},
@@ -72021,10 +72053,6 @@
"eyes": {
"version": "0.1.8"
},
"faker": {
"version": "5.5.3",
"dev": true
},
"fast-copy": {
"version": "2.1.1"
},
-2
View File
@@ -130,7 +130,6 @@
"@types/enzyme-adapter-react-16": "1.0.6",
"@types/eslint": "7.29.0",
"@types/estree": "0.0.52",
"@types/faker": "5.5.9",
"@types/inquirer": "8.2.5",
"@types/jest": "27.5.2",
"@types/jquery": "3.5.16",
@@ -174,7 +173,6 @@
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-testing-library": "4.12.4",
"execa": "5.1.1",
"faker": "5.5.3",
"husky": "8.0.3",
"jest": "27.5.1",
"js-yaml": "3.14.1",
+2 -2
View File
@@ -1,9 +1,9 @@
import { writeFileSync } from 'fs';
import fetch from 'node-fetch';
import yaml from 'js-yaml';
import { trendingSchemaValidator } from '../../../client/i18n/schema/trendingSchema';
import envData from '../../../config/env.json';
import { trendingSchemaValidator } from './schema/trending-schema';
const { clientLocale } = envData;
const createCdnUrl = (lang: string) =>
@@ -63,6 +63,8 @@ const schema = Joi.object().keys({
article29link: Joi.string().uri({ scheme: 'https' }).required()
});
export const trendingSchemaValidator = trendingObj => {
export const trendingSchemaValidator = (
trendingObj: Record<string, string>
) => {
return schema.validate(trendingObj);
};