From 7fe46957943028a8d950d8f00f8e737b9d1f34d1 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Fri, 11 Feb 2022 19:28:13 +0100 Subject: [PATCH] refactor: ignore eslint less (#45082) * refactor: remove and fix some eslint disables * refactor: drop max-line disables --- client/gatsby-config.js | 2 -- client/src/__mocks__/gatsby.js | 1 - client/src/__mocks__/react-i18next.js | 2 -- client/src/client-only-routes/show-certification.tsx | 6 +----- .../client-only-routes/show-profile-or-four-oh-four.tsx | 6 ------ client/src/client/workers/sass-compile.ts | 1 - client/src/components/Donation/donate-completion.tsx | 1 - client/src/components/Donation/donate-form.tsx | 1 - client/src/components/Donation/donation-modal.tsx | 1 - client/src/components/Donation/paypal-button.tsx | 5 ----- client/src/components/Donation/stripe-card-form.tsx | 3 +-- client/src/components/app-mount-notifier.test.tsx | 8 +++----- client/src/components/formHelpers/form.tsx | 3 +-- client/src/declarations.d.ts | 1 - .../src/templates/Challenges/redux/code-storage-epic.js | 3 +-- .../templates/Challenges/utils/worker-executor.test.js | 5 ----- .../templates/Introduction/components/cert-challenge.tsx | 1 - .../__fixtures/curriculum-helpers-remove-white-space.ts | 2 -- 18 files changed, 7 insertions(+), 45 deletions(-) diff --git a/client/gatsby-config.js b/client/gatsby-config.js index 31ca65c273..ba8d6a9ff3 100644 --- a/client/gatsby-config.js +++ b/client/gatsby-config.js @@ -108,12 +108,10 @@ module.exports = { resolve: 'gatsby-plugin-manifest', options: { name: 'freeCodeCamp', - /* eslint-disable camelcase */ short_name: 'fCC', start_url: '/', theme_color: '#0a0a23', background_color: '#fff', - /* eslint-enable camelcase */ display: 'minimal-ui', icon: 'src/assets/images/square_puck.png' } diff --git a/client/src/__mocks__/gatsby.js b/client/src/__mocks__/gatsby.js index 491c137280..86532bb220 100644 --- a/client/src/__mocks__/gatsby.js +++ b/client/src/__mocks__/gatsby.js @@ -1,5 +1,4 @@ /* eslint-disable no-unused-vars */ -/* eslint-disable no-undef */ const React = require('react'); const gatsby = jest.requireActual('gatsby'); diff --git a/client/src/__mocks__/react-i18next.js b/client/src/__mocks__/react-i18next.js index 05fd1ffe90..be0857a798 100644 --- a/client/src/__mocks__/react-i18next.js +++ b/client/src/__mocks__/react-i18next.js @@ -1,5 +1,3 @@ -/* eslint-disable react/prop-types */ -/* eslint-disable react/display-name */ import React from 'react'; const reactI18next = jest.genMockFromModule('react-i18next'); diff --git a/client/src/client-only-routes/show-certification.tsx b/client/src/client-only-routes/show-certification.tsx index cab76980f8..08657ec8ec 100644 --- a/client/src/client-only-routes/show-certification.tsx +++ b/client/src/client-only-routes/show-certification.tsx @@ -386,8 +386,4 @@ const ShowCertification = (props: ShowCertificationProps): JSX.Element => { ShowCertification.displayName = 'ShowCertification'; -export default connect( - mapStateToProps, - mapDispatchToProps - // eslint-disable-next-line @typescript-eslint/no-explicit-any -)(ShowCertification as any); +export default connect(mapStateToProps, mapDispatchToProps)(ShowCertification); diff --git a/client/src/client-only-routes/show-profile-or-four-oh-four.tsx b/client/src/client-only-routes/show-profile-or-four-oh-four.tsx index 1bda0338f1..f11e8679dc 100644 --- a/client/src/client-only-routes/show-profile-or-four-oh-four.tsx +++ b/client/src/client-only-routes/show-profile-or-four-oh-four.tsx @@ -85,16 +85,10 @@ class ShowProfileOrFourOhFour extends Component { // We have a response from the API, and we have some state in the // store for /:maybeUser, we now handover rendering to the Profile component - // eslint-disable-next-line - // @ts-ignore TODO: sort out whether user.portfolio is an array or obj. lit. return ; } } -// eslint-disable-next-line -// @ts-ignore -ShowProfileOrFourOhFour.displayName = 'ShowProfileOrFourOhFour'; - export default connect( makeMapStateToProps, mapDispatchToProps diff --git a/client/src/client/workers/sass-compile.ts b/client/src/client/workers/sass-compile.ts index 181a20634b..d6a017941a 100644 --- a/client/src/client/workers/sass-compile.ts +++ b/client/src/client/workers/sass-compile.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/unambiguous */ // work around for SASS error in Edge // https://github.com/medialize/sass.js/issues/96#issuecomment-424386171 interface WorkerWithSass extends Worker { diff --git a/client/src/components/Donation/donate-completion.tsx b/client/src/components/Donation/donate-completion.tsx index 4886627741..dce3923ce5 100644 --- a/client/src/components/Donation/donate-completion.tsx +++ b/client/src/components/Donation/donate-completion.tsx @@ -20,7 +20,6 @@ function DonateCompletion({ isSignedIn, error = null }: DonateCompletionProps): JSX.Element { - /* eslint-disable no-nested-ternary */ const { t } = useTranslation(); const style = processing || redirecting ? 'info' : success ? 'success' : 'danger'; diff --git a/client/src/components/Donation/donate-form.tsx b/client/src/components/Donation/donate-form.tsx index e0baae0c0c..cba6ca6e15 100644 --- a/client/src/components/Donation/donate-form.tsx +++ b/client/src/components/Donation/donate-form.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/unbound-method */ import type { Token } from '@stripe/stripe-js'; import React, { Component } from 'react'; diff --git a/client/src/components/Donation/donation-modal.tsx b/client/src/components/Donation/donation-modal.tsx index 379c11422a..1829e7f435 100644 --- a/client/src/components/Donation/donation-modal.tsx +++ b/client/src/components/Donation/donation-modal.tsx @@ -108,7 +108,6 @@ function DonateModal({ const handleModalHide = () => { // If modal is open on a SuperBlock page if (isLocationSuperBlock(location)) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-call goToAnchor('claim-cert-block'); } }; diff --git a/client/src/components/Donation/paypal-button.tsx b/client/src/components/Donation/paypal-button.tsx index 3211e4a6a9..510dee766b 100644 --- a/client/src/components/Donation/paypal-button.tsx +++ b/client/src/components/Donation/paypal-button.tsx @@ -1,7 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable camelcase */ - import React, { Component, Ref } from 'react'; import { withTranslation } from 'react-i18next'; import { connect } from 'react-redux'; @@ -91,7 +87,6 @@ export class PaypalButton extends Component< static getDerivedStateFromProps(props: PaypalButtonProps): PaypalButtonState { const { donationAmount, donationDuration } = props; - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const configurationObj: { amount: number; duration: string; diff --git a/client/src/components/Donation/stripe-card-form.tsx b/client/src/components/Donation/stripe-card-form.tsx index bf517e7d2a..d171f78f3b 100644 --- a/client/src/components/Donation/stripe-card-form.tsx +++ b/client/src/components/Donation/stripe-card-form.tsx @@ -1,4 +1,3 @@ -/* eslint-disable no-undefined */ import { Button, Form } from '@freecodecamp/react-bootstrap'; import { CardNumberElement, @@ -133,7 +132,7 @@ const StripeCardForm = ({ ) => { if (stripe) { return stripe.confirmCardPayment(clientSecret, { - // eslint-disable-next-line camelcase, @typescript-eslint/naming-convention + // eslint-disable-next-line @typescript-eslint/naming-convention payment_method: paymentMethod }); } diff --git a/client/src/components/app-mount-notifier.test.tsx b/client/src/components/app-mount-notifier.test.tsx index d0a43f2f27..ad1645ef19 100644 --- a/client/src/components/app-mount-notifier.test.tsx +++ b/client/src/components/app-mount-notifier.test.tsx @@ -11,16 +11,14 @@ import AppMountNotifier from './app-mount-notifier'; jest.mock('react-ga'); jest.unmock('react-i18next'); -type Language = [string, string]; +type Language = keyof typeof i18nextCodes; +type LanguagePair = [string, string]; const store = createStore(); // Create a nested array for languages const languages = Object.keys(i18nextCodes).map( - /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unsafe-return */ - // @ts-ignore - // TODO: convert `all-langs.js` to TypeScript - (key): Language => [i18nextCodes[key], key] + (key): LanguagePair => [i18nextCodes[key as Language], key] ); describe('AppMountNotifier', () => { diff --git a/client/src/components/formHelpers/form.tsx b/client/src/components/formHelpers/form.tsx index f4373b51a0..a6cc00fcbf 100644 --- a/client/src/components/formHelpers/form.tsx +++ b/client/src/components/formHelpers/form.tsx @@ -24,7 +24,7 @@ type FormProps = { enableSubmit?: boolean; formFields: { name: string; label: string }[]; hideButton?: boolean; - id?: string; + id: string; initialValues?: Record; options: FormOptions; submit: (values: ValidatedValues, ...args: unknown[]) => void; @@ -49,7 +49,6 @@ function DynamicForm({ > {({ handleSubmit, pristine, error }) => (
{ expect(global.Worker).toBeCalledWith('/js/test.js'); }); -// eslint-disable-next-line max-len it('Worker executor should successfully execute two tasks in parallel', async () => { const terminateHandler = jest.fn(); mockWorker({ terminate: terminateHandler }); @@ -89,7 +88,6 @@ it('Worker executor should successfully execute two tasks in parallel', async () expect(global.Worker).toBeCalledTimes(2); }); -// eslint-disable-next-line max-len it('Worker executor should successfully execute 3 tasks in parallel and use two workers', async () => { mockWorker(); const testWorker = createWorker('test'); @@ -104,7 +102,6 @@ it('Worker executor should successfully execute 3 tasks in parallel and use two expect(global.Worker).toBeCalledTimes(2); }); -// eslint-disable-next-line max-len it('Worker executor should successfully execute 3 tasks, use 3 workers and terminate each worker', async () => { const terminateHandler = jest.fn(); mockWorker({ terminate: terminateHandler }); @@ -121,7 +118,6 @@ it('Worker executor should successfully execute 3 tasks, use 3 workers and termi expect(global.Worker).toBeCalledTimes(3); }); -// eslint-disable-next-line max-len it('Worker executor should successfully execute 3 tasks in parallel and use 3 workers', async () => { mockWorker(); const testWorker = createWorker('test', { maxWorkers: 3 }); @@ -136,7 +132,6 @@ it('Worker executor should successfully execute 3 tasks in parallel and use 3 wo expect(global.Worker).toBeCalledTimes(3); }); -// eslint-disable-next-line max-len it('Worker executor should successfully execute 3 tasks and use 1 worker', async () => { mockWorker(); const testWorker = createWorker('test', { maxWorkers: 1 }); diff --git a/client/src/templates/Introduction/components/cert-challenge.tsx b/client/src/templates/Introduction/components/cert-challenge.tsx index 97ed8582f4..7a8d1f2f73 100644 --- a/client/src/templates/Introduction/components/cert-challenge.tsx +++ b/client/src/templates/Introduction/components/cert-challenge.tsx @@ -54,7 +54,6 @@ const mapStateToProps = (state: unknown) => { fetchState: CertChallengeProps['fetchState'], isSignedIn ) => ({ - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment currentCerts, fetchState, isSignedIn diff --git a/client/src/utils/__fixtures/curriculum-helpers-remove-white-space.ts b/client/src/utils/__fixtures/curriculum-helpers-remove-white-space.ts index 841279da24..1a5316047c 100644 --- a/client/src/utils/__fixtures/curriculum-helpers-remove-white-space.ts +++ b/client/src/utils/__fixtures/curriculum-helpers-remove-white-space.ts @@ -3,10 +3,8 @@ This string sentence has various white spaces characters: \t* This line starts with a tab character. \t* This line has several preceding white space characters.`; -/* eslint-disable max-len */ const stringWithWhiteSpaceCharsRemoved = 'Thisstringsentencehasvariouswhitespacescharacters:*Thislinestartswithatabcharacter.*Thislinehasseveralprecedingwhitespacecharacters.'; -/* esline-enable max-len */ const testValues = { stringWithWhiteSpaceChars,