From 8daa06a3b88033a935b55738579a1be29b6c6dcb Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Wed, 5 Oct 2022 11:08:56 +0700 Subject: [PATCH] Fixed various linting issues - these changes were needed ahead of the upcoming bump to react-scripts, which bumps eslint to v8, and therefore we can update eslint-plugin-ghost, which introduces some new linting rules --- ghost/portal/src/components/pages/AccountPlanPage.js | 2 +- ghost/portal/src/components/pages/SignupPage.js | 2 +- ghost/portal/src/tests/SignupFlow.test.js | 4 +++- ghost/portal/src/tests/UpgradeFlow.test.js | 12 +++++++++--- ghost/portal/src/utils/fixtures-generator.js | 2 ++ ghost/portal/src/utils/helpers.js | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ghost/portal/src/components/pages/AccountPlanPage.js b/ghost/portal/src/components/pages/AccountPlanPage.js index 416c2280fd..524efa111c 100644 --- a/ghost/portal/src/components/pages/AccountPlanPage.js +++ b/ghost/portal/src/components/pages/AccountPlanPage.js @@ -402,7 +402,7 @@ export default class AccountPlanPage extends React.Component { }); } } - } + }; onCancelSubscription({subscriptionId, cancelAtPeriodEnd}) { const {member} = this.context; diff --git a/ghost/portal/src/components/pages/SignupPage.js b/ghost/portal/src/components/pages/SignupPage.js index 9a0f480ac9..16d85390c7 100644 --- a/ghost/portal/src/components/pages/SignupPage.js +++ b/ghost/portal/src/components/pages/SignupPage.js @@ -336,7 +336,7 @@ class SignupPage extends React.Component { }; }); }, 5); - } + }; onKeyDown(e) { // Handles submit on Enter press diff --git a/ghost/portal/src/tests/SignupFlow.test.js b/ghost/portal/src/tests/SignupFlow.test.js index e124ec1f60..63bc413b06 100644 --- a/ghost/portal/src/tests/SignupFlow.test.js +++ b/ghost/portal/src/tests/SignupFlow.test.js @@ -678,7 +678,9 @@ describe('Signup', () => { }); // added fake timeout for react state delay in setting plan - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => { + setTimeout(r, 10); + }); fireEvent.click(chooseBtns[1]); await waitFor(() => expect(ghostApi.member.checkoutPlan).toHaveBeenCalledTimes(1)); }); diff --git a/ghost/portal/src/tests/UpgradeFlow.test.js b/ghost/portal/src/tests/UpgradeFlow.test.js index d6af1c9189..6459f0834c 100644 --- a/ghost/portal/src/tests/UpgradeFlow.test.js +++ b/ghost/portal/src/tests/UpgradeFlow.test.js @@ -205,7 +205,9 @@ describe('Logged-in free member', () => { const monthlyPlanContainer = await within(popupIframeDocument).findByText('Monthly'); fireEvent.click(monthlyPlanContainer); // added fake timeout for react state delay in setting plan - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => { + setTimeout(r, 10); + }); const submitButton = within(popupIframeDocument).queryByRole('button', {name: 'Continue'}); @@ -242,7 +244,9 @@ describe('Logged-in free member', () => { const yearlyPlanContainer = await within(popupIframeDocument).findByText('Yearly'); fireEvent.click(yearlyPlanContainer); // added fake timeout for react state delay in setting plan - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => { + setTimeout(r, 10); + }); const submitButton = within(popupIframeDocument).queryByRole('button', {name: 'Continue'}); @@ -364,7 +368,9 @@ describe('Logged-in free member', () => { await within(popupIframeDocument).findByText('Monthly'); // allow default checkbox switch to yearly - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => { + setTimeout(r, 10); + }); const chooseBtns = within(popupIframeDocument).queryAllByRole('button', {name: 'Choose'}); diff --git a/ghost/portal/src/utils/fixtures-generator.js b/ghost/portal/src/utils/fixtures-generator.js index a92809b0ac..a47a8f9e1f 100644 --- a/ghost/portal/src/utils/fixtures-generator.js +++ b/ghost/portal/src/utils/fixtures-generator.js @@ -1,3 +1,5 @@ +/* eslint-disable camelcase */ + export const sites = { singleProduct: getSiteData({ products: getProductsData({numOfProducts: 1}) diff --git a/ghost/portal/src/utils/helpers.js b/ghost/portal/src/utils/helpers.js index bb1740a177..3b24aa6e0d 100644 --- a/ghost/portal/src/utils/helpers.js +++ b/ghost/portal/src/utils/helpers.js @@ -649,7 +649,7 @@ export const getSupportAddress = ({site}) => { } if (supportAddress?.split('@')?.length > 1) { - const [recipient, domain] = supportAddress?.split('@'); + const [recipient, domain] = supportAddress.split('@'); const updatedDomain = domain?.replace(/^(www)\.(?=[^/]*\..{2,5})/, '') || ''; return `${recipient}@${updatedDomain}`; }