diff --git a/client/src/client-only-routes/show-project-links.tsx b/client/src/client-only-routes/show-project-links.tsx index b927bf8c0c..7139917541 100644 --- a/client/src/client-only-routes/show-project-links.tsx +++ b/client/src/client-only-routes/show-project-links.tsx @@ -116,14 +116,10 @@ const ShowProjectLinks = (props: ShowProjectLinksProps): JSX.Element => { { title: 'Data Visualization' }, { title: 'Back End Development and APIs' }, { title: 'Legacy Information Security and Quality Assurance' } - ]; + ] as const; return legacyCerts.map((cert, ind) => { - /* eslint-disable @typescript-eslint/no-unsafe-assignment */ - /* eslint-disable @typescript-eslint/no-unsafe-call */ - /* eslint-disable @typescript-eslint/no-unsafe-return */ - /* eslint-disable @typescript-eslint/no-unsafe-member-access */ - // @ts-expect-error Error expected until projectMap is typed - const mapToUse = projectMap[cert.title] || legacyProjectMap[cert.title]; + const mapToUse = (projectMap[cert.title] || + legacyProjectMap[cert.title]) as { certSlug: string }[]; const { certSlug } = first(mapToUse) as { certSlug: string }; const certLocation = `/certification/${username}/${certSlug}`; return ( @@ -141,17 +137,19 @@ const ShowProjectLinks = (props: ShowProjectLinksProps): JSX.Element => { }); } // @ts-expect-error Error expected until projectMap is typed - return (projectMap[certName] || legacyProjectMap[certName]).map( - // @ts-expect-error Error expected until projectMap is typed - ({ link, title, id }) => ( -
  • - - {t(`certification.project.title.${title as string}`, title)} - - : {getProjectSolution(id, title)} -
  • - ) - ); + const project = (projectMap[certName] || legacyProjectMap[certName]) as { + link: string; + title: string; + id: string; + }[]; + return project.map(({ link, title, id }) => ( +
  • + + {t(`certification.project.title.${title}`, title)} + + : {getProjectSolution(id, title)} +
  • + )); /* eslint-enable @typescript-eslint/no-unsafe-assignment */ /* eslint-enable @typescript-eslint/no-unsafe-call */ /* eslint-enable @typescript-eslint/no-unsafe-return */ diff --git a/client/src/components/formHelpers/form-fields.tsx b/client/src/components/formHelpers/form-fields.tsx index 32b3e5ca29..4b43881894 100644 --- a/client/src/components/formHelpers/form-fields.tsx +++ b/client/src/components/formHelpers/form-fields.tsx @@ -101,7 +101,12 @@ function FormFields(props: FormFieldsProps): JSX.Element { type={type} value={value as string} /> - {nullOrWarning(value, !pristine && error, isURL, name)} + {nullOrWarning( + value as string, + !pristine && error, + isURL, + name + )} ); diff --git a/client/src/components/profile/components/heat-map.tsx b/client/src/components/profile/components/heat-map.tsx index 382c545927..858d089ec5 100644 --- a/client/src/components/profile/components/heat-map.tsx +++ b/client/src/components/profile/components/heat-map.tsx @@ -17,6 +17,7 @@ import './heatmap.css'; // @ts-ignore import envData from '../../../../../config/env.json'; import { langCodes } from '../../../../../config/i18n/all-langs'; +import { User } from '../../../redux/prop-types'; import FullWidthRow from '../../helpers/full-width-row'; import Spacer from '../../helpers/spacer'; @@ -29,8 +30,7 @@ const { clientLocale } = envData; const localeCode = langCodes[clientLocale]; interface HeatMapProps { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - calendar: any; + calendar: User['calendar']; } interface PageData { @@ -186,7 +186,6 @@ class HeatMapInner extends Component { const HeatMap = (props: HeatMapProps): JSX.Element => { const { t } = useTranslation(); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const { calendar } = props; /** @@ -195,8 +194,9 @@ const HeatMap = (props: HeatMapProps): JSX.Element => { */ // create array of timestamps and turn into milliseconds - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const timestamps = Object.keys(calendar).map((stamp: any) => stamp * 1000); + const timestamps = Object.keys(calendar).map( + stamp => Number.parseInt(stamp, 10) * 1000 + ); const startOfTimestamps = startOfDay(new Date(timestamps[0])); let endOfCalendar = startOfDay(Date.now()); let startOfCalendar; diff --git a/client/src/components/search/searchBar/search-hits.tsx b/client/src/components/search/searchBar/search-hits.tsx index 56854e52d6..3ed927d6db 100644 --- a/client/src/components/search/searchBar/search-hits.tsx +++ b/client/src/components/search/searchBar/search-hits.tsx @@ -57,6 +57,7 @@ const CustomHits = connectHits( ]; const allHits = hits.slice(0, 8).concat(footer); useEffect(() => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument handleHits(allHits); }); diff --git a/client/src/redux/prop-types.ts b/client/src/redux/prop-types.ts index e2ca341838..e6a46dfb7d 100644 --- a/client/src/redux/prop-types.ts +++ b/client/src/redux/prop-types.ts @@ -220,7 +220,7 @@ export type CertTest = { }; export type User = { - calendar: unknown; + calendar: Record; about: string; acceptedPrivacyTerms: boolean; completedChallenges: CompletedChallenge[]; diff --git a/client/src/templates/Challenges/classic/desktop-layout.tsx b/client/src/templates/Challenges/classic/desktop-layout.tsx index b8112ec351..a303c1f86c 100644 --- a/client/src/templates/Challenges/classic/desktop-layout.tsx +++ b/client/src/templates/Challenges/classic/desktop-layout.tsx @@ -64,7 +64,7 @@ const DesktopLayout = (props: DesktopLayoutProps): JSX.Element => { const getChallengeFile = () => { const { challengeFiles } = props; - return first(sortChallengeFiles(challengeFiles)) as ChallengeFile | null; + return first(sortChallengeFiles(challengeFiles) as ChallengeFile[]); }; const { diff --git a/client/src/templates/Challenges/components/completion-modal-body.tsx b/client/src/templates/Challenges/components/completion-modal-body.tsx index 7352263609..3b943a4613 100644 --- a/client/src/templates/Challenges/components/completion-modal-body.tsx +++ b/client/src/templates/Challenges/components/completion-modal-body.tsx @@ -13,7 +13,7 @@ interface CompletionModalBodyProps { interface CompletionModalBodyState { // This type was driving me nuts - seems like `NodeJS.Timeout | null;` should work // eslint-disable-next-line @typescript-eslint/no-explicit-any - progressInterval: any; + progressInterval: number | null; shownPercent: number; } @@ -45,7 +45,7 @@ export class CompletionModalBody extends PureComponent< const amountPerInterval = completedPercent / intervalsToFinish; let percent = 0; - const myInterval = setInterval(() => { + const myInterval = window.setInterval(() => { percent += amountPerInterval; if (percent > completedPercent) percent = completedPercent; @@ -65,7 +65,8 @@ export class CompletionModalBody extends PureComponent< } componentWillUnmount(): void { - clearInterval(this.state.progressInterval); + if (this.state.progressInterval !== null) + clearInterval(this.state.progressInterval); } render(): JSX.Element { diff --git a/tools/challenge-helper-scripts/create-project.ts b/tools/challenge-helper-scripts/create-project.ts index 0eb484f5e2..2e7a9059e5 100644 --- a/tools/challenge-helper-scripts/create-project.ts +++ b/tools/challenge-helper-scripts/create-project.ts @@ -35,6 +35,14 @@ type Meta = { challengeOrder: string[][]; }; +interface CreateProjectArgs { + superBlock: SuperBlocks; + block: string; + helpCategory: string; + order: number; + title?: string; +} + async function createProject( superBlock: SuperBlocks, block: string, @@ -264,8 +272,9 @@ prompt([ } } ]) - .then(({ superBlock, block, title, helpCategory, order }) => - createProject(superBlock, block, helpCategory, order, title) + .then( + ({ superBlock, block, title, helpCategory, order }: CreateProjectArgs) => + createProject(superBlock, block, helpCategory, order, title) ) .then(() => console.log( diff --git a/tools/scripts/build/ensure-env.ts b/tools/scripts/build/ensure-env.ts index 7ad84643de..6da64c1610 100644 --- a/tools/scripts/build/ensure-env.ts +++ b/tools/scripts/build/ensure-env.ts @@ -59,7 +59,7 @@ if (FREECODECAMP_NODE_ENV !== 'development') { searchKeys, donationKeys ); - const receivedvariables = Object.keys(env); + const receivedvariables = Object.keys(env as Record); expectedVariables.sort(); receivedvariables.sort(); if (expectedVariables.length !== receivedvariables.length) {