From 48311a4a7d5e776ba0c92d32ae55dff3a29c73ac Mon Sep 17 00:00:00 2001 From: Harsh Vitra Date: Mon, 29 Jul 2024 15:56:22 +0530 Subject: [PATCH 1/8] Fixed Lint issues and updated Eslint rules --- .eslintrc.js | 82 ++++++++++++++----- pages/_app.tsx | 4 +- .../sites/[slug]/[locale]/profile/history.tsx | 2 +- .../[slug]/[locale]/profile/payouts/index.tsx | 2 +- .../[locale]/profile/planetcash/index.tsx | 2 +- .../[locale]/profile/planetcash/new.tsx | 2 +- .../profile/planetcash/transactions.tsx | 2 +- .../[slug]/[locale]/profile/recurrency.tsx | 12 +-- src/features/common/CarouselSlider/index.tsx | 2 +- .../Projects/AccessDeniedLoader.tsx | 2 +- .../common/InputTypes/AutoCompleteCountry.tsx | 4 +- .../common/Layout/CookiePolicy/index.tsx | 2 +- .../common/Layout/CustomModal/index.tsx | 6 +- .../common/Layout/ErrorPopup/index.tsx | 4 +- .../Footer/SelectLanguageAndCountry.tsx | 4 +- src/features/common/Layout/Footer/index.tsx | 20 ++--- .../common/Layout/Navbar/getNavBarIcon.tsx | 10 +-- .../common/Layout/Navbar/getSubMenu.tsx | 14 ++-- src/features/common/Layout/Navbar/index.tsx | 36 ++++---- .../common/Layout/RedeemPopup/index.tsx | 2 +- .../common/Layout/TabbedView/index.tsx | 2 +- .../common/Layout/UserLayout/UserLayout.tsx | 6 +- src/features/common/Layout/index.tsx | 2 +- .../common/TreeCounter/TreeCounter.tsx | 2 +- .../common/VerifyEmail/VerifyEmail.tsx | 4 +- src/features/common/types/map.d.ts | 14 +--- src/features/common/types/project.d.ts | 2 +- .../donations/components/DirectGift.tsx | 2 +- .../PlantLocation/PlantLocationDetails.tsx | 2 +- .../projects/components/PopupProject.tsx | 38 ++++----- .../projects/components/ProjectSnippet.tsx | 40 ++++----- .../projects/components/TopProjectBadge.tsx | 6 +- .../projects/components/VerifiedBadge.tsx | 2 +- .../projects/components/maps/Credits.tsx | 14 ++-- .../projects/components/maps/Explore.tsx | 2 +- .../projects/components/maps/Markers.tsx | 2 +- .../components/maps/PlantLocations.tsx | 10 +-- .../projects/components/projects/Header.tsx | 18 ++-- .../components/projects/SearchBar.tsx | 10 +-- src/features/projects/screens/Projects.tsx | 10 +-- .../projects/screens/SingleProjectDetails.tsx | 32 ++++---- src/features/user/Account/CancelModal.tsx | 12 +-- src/features/user/Account/EditModal.tsx | 6 +- src/features/user/Account/History.tsx | 6 +- src/features/user/Account/PauseModal.tsx | 10 +-- src/features/user/Account/ReactivateModal.tsx | 2 +- .../user/BulkCodes/forms/IssueCodesForm.tsx | 4 +- src/features/user/CompleteSignup/index.tsx | 12 +-- .../NoContributions.tsx | 2 +- .../Popup/PopupImageSection.tsx | 2 +- .../user/MFV2/ForestProgress/TargetsModal.tsx | 8 +- .../user/MFV2/ForestProgress/index.tsx | 6 +- .../MFV2/ProfileCard/ProfileActions/index.tsx | 12 +-- .../components/BasicDetails.tsx | 6 +- .../components/ProjectCertificates.tsx | 4 +- .../components/ProjectMedia.tsx | 6 +- .../components/ProjectSelection.tsx | 8 +- .../components/ProjectSites.tsx | 10 +-- .../components/ProjectSpending.tsx | 4 +- .../ContributionStats/ConservationButton.tsx | 2 +- .../ContributionStats/RestoredButton.tsx | 2 +- .../components/MyContributions/index.tsx | 2 +- .../microComponents/AddTargetModal.tsx | 6 +- .../PlantedTreesContributions.tsx | 2 +- .../microComponents/ProjectImage.tsx | 4 +- .../MyForestMap/microComponents/PopUp.tsx | 2 +- .../microComponents/SharePlatforms.tsx | 2 +- .../RegisterTrees/SingleContribution.tsx | 2 +- .../RegisterTrees/UploadImages.tsx | 4 +- .../RegisterTrees/RegisterTreesWidget.tsx | 4 +- .../user/Settings/ApiKey/ApiKeyForm.tsx | 2 +- .../DeleteProfile/DeleteProfileForm.tsx | 2 +- .../Settings/EditProfile/EditProfileForm.tsx | 6 +- .../components/SpeciesPlanted/index.tsx | 2 +- .../Import/components/PlantingLocation.tsx | 2 +- .../TreeMapper/MySpecies/MySpeciesForm.tsx | 4 +- .../TreeMapper/components/PlantLocation.tsx | 2 +- src/features/user/TreeMapper/index.tsx | 2 +- .../Widget/DonationLink/DonationLinkForm.tsx | 6 +- src/features/user/Widget/EmbedModal.tsx | 4 +- src/temp/Explore/ExploreProject.tsx | 8 +- src/temp/Explore/MapLayerOptions.tsx | 6 +- src/temp/FirePopup/index.tsx | 4 +- src/temp/ImagesSlider/index.tsx | 2 +- src/temp/ProjectBadge/ProjectBadge.tsx | 8 +- .../ProjectListTabForMobile.tsx | 2 +- .../ProjectListTabLargeScreen.tsx | 2 +- .../ProjectSearchAndFilter.tsx | 2 +- src/temp/ProjectSiteDropdown/index.tsx | 4 +- .../projectDetails/SingleMapTab.stories.tsx | 4 +- src/tenants/common/LeaderBoard/index.tsx | 2 +- .../planet/LeaderBoard/components/Score.tsx | 6 +- .../planet/LeaderBoard/components/Stats.tsx | 8 +- .../LeaderBoard/components/StatsInfoModal.tsx | 2 +- .../planet/LeaderBoard/components/Stories.tsx | 8 +- .../planet/LeaderBoard/components/Video.tsx | 4 +- .../Home/components/LeaderBoardSection.tsx | 4 +- .../salesforce/Home/components/Social.tsx | 4 +- src/utils/LayerManagerUtils.js | 8 +- src/utils/browsercheck.ts | 4 +- .../getCurrencySymbolByCode.ts | 2 +- 101 files changed, 374 insertions(+), 338 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8b7de5ece6..3ef462a1fc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,7 +4,14 @@ module.exports = { browser: true, es2020: true, }, - extends: ['eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react/recommended', 'plugin:storybook/recommended'], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react/recommended', + 'plugin:storybook/recommended', + 'plugin:import/recommended' // Add this line to include recommended rules from eslint-plugin-import + ], parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { @@ -13,55 +20,92 @@ module.exports = { ecmaVersion: 11, sourceType: 'module', }, - plugins: ['react', '@typescript-eslint', '@emotion', 'cypress'], + plugins: ['react', '@typescript-eslint', '@emotion', 'cypress', 'import'], // Add 'import' here rules: { + // General JavaScript/TypeScript + 'no-console': 'warn', + 'no-debugger': 'error', + 'prefer-const': 'warn', + 'no-var': 'error', + 'consistent-return': 'warn', + 'eqeqeq': ['error', 'always'], + '@typescript-eslint/explicit-module-boundary-types': 'warn', + '@typescript-eslint/explicit-function-return-type': 'warn', + + // React Best Practices + 'react/jsx-key': 'error', + 'react/no-array-index-key': 'warn', + 'react/jsx-curly-brace-presence': ['warn', { props: 'never', children: 'never' }], + + // Code Quality + 'complexity': ['warn', { max: 10 }], + 'max-lines': ['warn', { max: 300, skipBlankLines: true, skipComments: true }], + 'max-params': ['warn', 4], + 'no-magic-numbers': ['warn', { ignore: [0, 1] }], + + // Security + 'no-eval': 'error', + 'no-new-func': 'error', + + // Existing Rules 'no-undef': 'warn', 'no-unsafe-optional-chaining': 'warn', 'no-use-before-define': 'off', '@typescript-eslint/no-use-before-define': 'warn', 'no-empty-pattern': 'warn', - // base rule disabled as it can report incorrect errors 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': [ - 'warn', // or "error" + 'warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_', }, ], - 'react/react-in-jsx-scope': 'off', - 'react/jsx-props-no-spreading': 'off', + 'react/jsx-props-no-spreading': 'warn', 'react/jsx-filename-extension': [ - 1, - { extensions: ['.js', '.jsx', '.tsx'] }, + 'warn', + { extensions: ['.js', '.jsx', '.tsx'] } ], 'react/no-unknown-property': [ - 2, + 'error', { ignore: ['jsx', 'global'], - }, + } + ], + 'react/jsx-indent': [ + 'warn', + 2 + ], + 'import/extensions': [ + 'warn', + 'always', + { + js: 'never', + jsx: 'never', + ts: 'never', + tsx: 'never', + } ], - 'react/jsx-indent': 'off', - 'import/extensions': 'off', - 'import/no-unresolved': 'off', + 'import/no-unresolved': 'warn', // should be error + 'import/named': 'warn', // should be error 'react/jsx-no-literals': 'off', - '@typescript-eslint/ban-types': 'off', - '@typescript-eslint/no-empty-interface': 'off', - '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/ban-types': 'warn', + '@typescript-eslint/no-empty-interface': 'warn', + '@typescript-eslint/no-empty-function': 'warn', 'react/display-name': 'off', 'react/no-find-dom-node': 'off', '@emotion/jsx-import': 'error', '@emotion/no-vanilla': 'error', '@emotion/import-from-emotion': 'error', '@emotion/styled-import': 'error', - '@typescript-eslint/no-var-requires': 0, - 'react/prop-types': 'off', + '@typescript-eslint/no-var-requires': 'warn', + 'react/prop-types': 'warn', 'cypress/no-assigning-return-values': 'error', 'cypress/no-unnecessary-waiting': 'error', 'cypress/assertion-before-screenshot': 'warn', - 'cypress/no-force': 'warn', + 'cypress/no-force': 'error', 'cypress/no-async-tests': 'error', 'cypress/no-pause': 'error', }, diff --git a/pages/_app.tsx b/pages/_app.tsx index 2b82bb6223..7054b037af 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -251,8 +251,8 @@ const PlanetWeb = ({ ? window.location.origin : '' } - audience={'urn:plant-for-the-planet'} - cacheLocation={'localstorage'} + audience="urn:plant-for-the-planet" + cacheLocation="localstorage" onRedirectCallback={onRedirectCallback} useRefreshTokens={true} > diff --git a/pages/sites/[slug]/[locale]/profile/history.tsx b/pages/sites/[slug]/[locale]/profile/history.tsx index e0761e225a..26216c42aa 100644 --- a/pages/sites/[slug]/[locale]/profile/history.tsx +++ b/pages/sites/[slug]/[locale]/profile/history.tsx @@ -147,7 +147,7 @@ function AccountHistory({ pageProps }: Props): ReactElement { return tenantConfig ? ( <> {progress > 0 && ( -
+
)} diff --git a/pages/sites/[slug]/[locale]/profile/payouts/index.tsx b/pages/sites/[slug]/[locale]/profile/payouts/index.tsx index a4471eac26..780b6c3eb2 100644 --- a/pages/sites/[slug]/[locale]/profile/payouts/index.tsx +++ b/pages/sites/[slug]/[locale]/profile/payouts/index.tsx @@ -45,7 +45,7 @@ export default function OverviewPage({ return tenantConfig ? ( <> {progress > 0 && ( -
+
)} diff --git a/pages/sites/[slug]/[locale]/profile/planetcash/index.tsx b/pages/sites/[slug]/[locale]/profile/planetcash/index.tsx index dc33744dfd..2c4cef0842 100644 --- a/pages/sites/[slug]/[locale]/profile/planetcash/index.tsx +++ b/pages/sites/[slug]/[locale]/profile/planetcash/index.tsx @@ -49,7 +49,7 @@ export default function PlanetCashPage({ return tenantConfig ? ( <> {progress > 0 && ( -
+
)} diff --git a/pages/sites/[slug]/[locale]/profile/planetcash/new.tsx b/pages/sites/[slug]/[locale]/profile/planetcash/new.tsx index 9550ca2812..8ae84005f7 100644 --- a/pages/sites/[slug]/[locale]/profile/planetcash/new.tsx +++ b/pages/sites/[slug]/[locale]/profile/planetcash/new.tsx @@ -50,7 +50,7 @@ export default function PlanetCashCreatePage({ return tenantConfig ? ( <> {progress > 0 && ( -
+
)} diff --git a/pages/sites/[slug]/[locale]/profile/planetcash/transactions.tsx b/pages/sites/[slug]/[locale]/profile/planetcash/transactions.tsx index 53216e0870..5a7dc73efb 100644 --- a/pages/sites/[slug]/[locale]/profile/planetcash/transactions.tsx +++ b/pages/sites/[slug]/[locale]/profile/planetcash/transactions.tsx @@ -50,7 +50,7 @@ export default function PlanetCashTransactionsPage({ return tenantConfig ? ( <> {progress > 0 && ( -
+
)} diff --git a/pages/sites/[slug]/[locale]/profile/recurrency.tsx b/pages/sites/[slug]/[locale]/profile/recurrency.tsx index 417c5e1567..c94a22d831 100644 --- a/pages/sites/[slug]/[locale]/profile/recurrency.tsx +++ b/pages/sites/[slug]/[locale]/profile/recurrency.tsx @@ -60,16 +60,16 @@ function RecurrentDonations({ ); if (recurrencies && Array.isArray(recurrencies)) { const activeRecurrencies = recurrencies?.filter( - (obj) => obj.status == 'active' || obj.status == 'trialing' + (obj) => obj.status === 'active' || obj.status === 'trialing' ); const pauseRecurrencies = recurrencies?.filter( - (obj) => obj.status == 'paused' + (obj) => obj.status === 'paused' ); const otherRecurrencies = recurrencies?.filter( (obj) => - obj.status != 'paused' && - obj.status != 'active' && - obj.status != 'trialing' + obj.status !== 'paused' && + obj.status !== 'active' && + obj.status !== 'trialing' ); setrecurrencies([ ...activeRecurrencies, @@ -99,7 +99,7 @@ function RecurrentDonations({ return tenantConfig ? ( <> {progress > 0 && ( -
+
)} diff --git a/src/features/common/CarouselSlider/index.tsx b/src/features/common/CarouselSlider/index.tsx index 1b896d145d..0b073c380d 100644 --- a/src/features/common/CarouselSlider/index.tsx +++ b/src/features/common/CarouselSlider/index.tsx @@ -116,7 +116,7 @@ const CarouselSlider = ({
diff --git a/src/features/common/ContentLoaders/Projects/AccessDeniedLoader.tsx b/src/features/common/ContentLoaders/Projects/AccessDeniedLoader.tsx index 5a223f80e1..5c96816942 100644 --- a/src/features/common/ContentLoaders/Projects/AccessDeniedLoader.tsx +++ b/src/features/common/ContentLoaders/Projects/AccessDeniedLoader.tsx @@ -4,7 +4,7 @@ import AccessDenied from '../../../../../public/assets/images/icons/manageProjec function AccessDeniedLoader(): ReactElement { return (
- +

You don’t have access to this page

); diff --git a/src/features/common/InputTypes/AutoCompleteCountry.tsx b/src/features/common/InputTypes/AutoCompleteCountry.tsx index 7b7e7264ba..cffe3c8686 100644 --- a/src/features/common/InputTypes/AutoCompleteCountry.tsx +++ b/src/features/common/InputTypes/AutoCompleteCountry.tsx @@ -102,7 +102,7 @@ export default function CountrySelect({ const displayedOption = (currency ? `(${currency}) ` : '') + t(countryCode.toLowerCase()) + - (!(name == 'editProfile' || countryCode === 'auto') + (!(name === 'editProfile' || countryCode === 'auto') ? ` ${countryCode}` : ''); return ( @@ -124,7 +124,7 @@ export default function CountrySelect({ {...params} label={label} color="primary" - name={'countrydropdown'} + name="countrydropdown" /> )} /> diff --git a/src/features/common/Layout/CookiePolicy/index.tsx b/src/features/common/Layout/CookiePolicy/index.tsx index ca058710eb..3d25f6bde6 100644 --- a/src/features/common/Layout/CookiePolicy/index.tsx +++ b/src/features/common/Layout/CookiePolicy/index.tsx @@ -44,7 +44,7 @@ export default function CookiePolicy() { return showCookieNotice ? (
{processErrorMessage(err.message)} diff --git a/src/features/common/Layout/Footer/SelectLanguageAndCountry.tsx b/src/features/common/Layout/Footer/SelectLanguageAndCountry.tsx index 4dccac58f7..17a3afad4f 100644 --- a/src/features/common/Layout/Footer/SelectLanguageAndCountry.tsx +++ b/src/features/common/Layout/Footer/SelectLanguageAndCountry.tsx @@ -230,7 +230,7 @@ export default function TransitionsModal({ {/* modal buttons */}
-
@@ -115,7 +115,7 @@ export default function ProjectSnippet({ `/${locale}/${project.slug}/${ embed === 'true' ? `${ - callbackUrl != undefined + callbackUrl !== undefined ? `?embed=true&callback=${callbackUrl}` : '?embed=true' }` @@ -129,7 +129,7 @@ export default function ProjectSnippet({ > {project.image && typeof project.image !== 'undefined' ? (
} -
-
-
+
+
+
{ecosystem !== null && ( -
+
{tManageProjects(`ecosystemTypes.${ecosystem}`)} {project.purpose === 'trees' && ' /'}
)} -
+
{project.purpose === 'trees' && project.classification && tDonate(project.classification)}
-

+

{truncateString(project.name, 54)} {project.purpose === 'trees' && project.isApproved && ( @@ -173,16 +173,16 @@ export default function ProjectSnippet({

-
+
-
-
-
-
+
+
+
+
{project.purpose === 'trees' && project.countPlanted > 0 && ( <> {localizedAbbreviatedNumber( @@ -205,10 +205,10 @@ export default function ProjectSnippet({
{!project.allowDonations ? (
- + ) : ( -
+
{getFormatedCurrency(locale, project.currency, project.unitCost)}{' '} {project.unitType === 'tree' && tDonate('perTree')} @@ -242,7 +242,7 @@ export default function ProjectSnippet({ )}
-
+
{project.allowDonations && (
{ embed === 'true' ? window.open(`/t/${project.tpo.slug}`, '_top') diff --git a/src/features/projects/components/TopProjectBadge.tsx b/src/features/projects/components/TopProjectBadge.tsx index a9adb87976..95a75542f3 100644 --- a/src/features/projects/components/TopProjectBadge.tsx +++ b/src/features/projects/components/TopProjectBadge.tsx @@ -21,9 +21,9 @@ const TopProjectBadge = ({ displayPopup }: Props): ReactElement => { const t = useTranslations('Common'); return ( <> -
-
- +
+
+
{t('topProject')}
diff --git a/src/features/projects/components/VerifiedBadge.tsx b/src/features/projects/components/VerifiedBadge.tsx index cbe879768b..c4cc028383 100644 --- a/src/features/projects/components/VerifiedBadge.tsx +++ b/src/features/projects/components/VerifiedBadge.tsx @@ -25,7 +25,7 @@ const VerifiedBadge = ({ displayPopup, project }: Props): ReactElement => { return ( <> {' '} - + {tCommon('shop')} @@ -69,7 +69,7 @@ export default function Credits({ setCurrencyCode }: Props): ReactElement { {tCommon('status')} @@ -78,7 +78,7 @@ export default function Credits({ setCurrencyCode }: Props): ReactElement { {tCommon('imprint')} @@ -87,7 +87,7 @@ export default function Credits({ setCurrencyCode }: Props): ReactElement { {tCommon('privacy')} @@ -96,7 +96,7 @@ export default function Credits({ setCurrencyCode }: Props): ReactElement { {tCommon('terms')} @@ -138,7 +138,7 @@ export default function Credits({ setCurrencyCode }: Props): ReactElement { {tCommon('contact')} diff --git a/src/features/projects/components/maps/Explore.tsx b/src/features/projects/components/maps/Explore.tsx index f9ec25bafd..afb3e6f582 100644 --- a/src/features/projects/components/maps/Explore.tsx +++ b/src/features/projects/components/maps/Explore.tsx @@ -171,7 +171,7 @@ export default function Explore(): ReactElement { `/${ embed === 'true' ? `${ - callbackUrl != undefined + callbackUrl !== undefined ? `?embed=true&callback=${callbackUrl}` : '?embed=true' }` diff --git a/src/features/projects/components/maps/Markers.tsx b/src/features/projects/components/maps/Markers.tsx index 740820a3c4..422420ea46 100644 --- a/src/features/projects/components/maps/Markers.tsx +++ b/src/features/projects/components/maps/Markers.tsx @@ -52,7 +52,7 @@ export default function Markers({ `/${locale}/${projectSlug}/${ embed === 'true' ? `${ - callbackUrl != undefined + callbackUrl !== undefined ? `?embed=true&callback=${callbackUrl}` : '?embed=true' }` diff --git a/src/features/projects/components/maps/PlantLocations.tsx b/src/features/projects/components/maps/PlantLocations.tsx index 97bed487c1..aba5017989 100644 --- a/src/features/projects/components/maps/PlantLocations.tsx +++ b/src/features/projects/components/maps/PlantLocations.tsx @@ -149,7 +149,7 @@ export default function PlantLocations(): ReactElement { return ( <> +
{showTopProjectsList ? ( -
-
setSelectedTab('top')}> +
+
setSelectedTab('top')}>
{selectedTab === 'top' ? ( -
+
) : null}
-
setSelectedTab('all')}> +
setSelectedTab('all')}>
{selectedTab === 'all' ? ( -
+
) : null}
) : ( -

{t('stopTalkingStartPlanting')}

+

{t('stopTalkingStartPlanting')}

)} -
+
); diff --git a/src/features/projects/screens/Projects.tsx b/src/features/projects/screens/Projects.tsx index b248c9128e..d4d133dc80 100644 --- a/src/features/projects/screens/Projects.tsx +++ b/src/features/projects/screens/Projects.tsx @@ -21,7 +21,7 @@ import { useTenant } from '../../common/Layout/TenantContext'; interface Props { projects: MapProject[]; - showProjects: Boolean; + showProjects: boolean; setShowProjects: Function; setsearchedProjects: SetState; } @@ -197,9 +197,9 @@ function ProjectsList({ const NoProjectFound = () => { return ( -
+
- +
{tDonate('noProjectsFound')}
@@ -248,7 +248,7 @@ function ProjectsList({ >
{isMobile && (!hideSidebar || showProjectList === 'true') && ( -
+
)} {searchMode ? ( {/* till here is header */} -
+
{trottledSearchValue !== '' ? ( searchProjectResults && searchProjectResults.length > 0 ? ( searchProjectResults.map((project) => ( diff --git a/src/features/projects/screens/SingleProjectDetails.tsx b/src/features/projects/screens/SingleProjectDetails.tsx index 33121dd6fb..f2b7ef4a1b 100644 --- a/src/features/projects/screens/SingleProjectDetails.tsx +++ b/src/features/projects/screens/SingleProjectDetails.tsx @@ -88,7 +88,7 @@ function SingleProjectDetails(): ReactElement { `/${project.slug}/${ isEmbed ? `${ - callbackUrl != undefined + callbackUrl !== undefined ? `?embed=true&callback=${callbackUrl}` : '?embed=true' }` @@ -149,18 +149,18 @@ function SingleProjectDetails(): ReactElement { }} > -
+
@@ -185,7 +185,7 @@ function SingleProjectDetails(): ReactElement { <> ) : ( )} -
+
) : ( -
+
{project.purpose === 'trees' && @@ -218,8 +218,8 @@ function SingleProjectDetails(): ReactElement { project.reviews.length > 0 && ( )} -
-
{tDonate('aboutProject')}
+
+
{tDonate('aboutProject')}
-
+
{project.videoUrl !== null && ReactPlayer.canPlay(project.videoUrl) ? ( ) : null} -
+
diff --git a/src/features/user/Account/CancelModal.tsx b/src/features/user/Account/CancelModal.tsx index d14f5d030b..e528d563aa 100644 --- a/src/features/user/Account/CancelModal.tsx +++ b/src/features/user/Account/CancelModal.tsx @@ -70,13 +70,13 @@ export const CancelModal = ({ setDisabled(true); const bodyToSend = { cancellationType: - option == 'cancelImmediately' + option === 'cancelImmediately' ? 'immediate' - : option == 'cancelOnPeriodEnd' + : option === 'cancelOnPeriodEnd' ? 'period-end' : 'custom-date', // immediate|period-end|custom-date cancellationDate: - option == 'cancelOnSelectedDate' + option === 'cancelOnSelectedDate' ? date?.toISOString().split('T')[0] : null, // if custom-date is cancellationType }; @@ -127,7 +127,7 @@ export const CancelModal = ({ tabIndex={0} className={styles.headerCloseIcon} > - +
@@ -156,7 +156,7 @@ export const CancelModal = ({ > } label={t('cancelImmediately')} /> @@ -169,7 +169,7 @@ export const CancelModal = ({ } label={t('cancelOnSelectedDate')} /> diff --git a/src/features/user/Account/EditModal.tsx b/src/features/user/Account/EditModal.tsx index e2db5104bf..a41fb22d79 100644 --- a/src/features/user/Account/EditModal.tsx +++ b/src/features/user/Account/EditModal.tsx @@ -111,7 +111,7 @@ export const EditModal = ({ frequency: data.frequency, }; if ( - new Date(data.currentPeriodEnd).toDateString() == + new Date(data.currentPeriodEnd).toDateString() === new Date(record.currentPeriodEnd).toDateString() || bodyToSend.nextBilling === null ) { @@ -120,7 +120,7 @@ export const EditModal = ({ if (data.frequency.toLowerCase() === record.frequency) { delete bodyToSend.frequency; } - if (data.amount == record.amount) { + if (data.amount === record.amount) { delete bodyToSend.centAmount; } @@ -182,7 +182,7 @@ export const EditModal = ({ tabIndex={0} className={styles.headerCloseIcon} > - +
diff --git a/src/features/user/Account/History.tsx b/src/features/user/Account/History.tsx index ba7f99186c..750a2ce68a 100644 --- a/src/features/user/Account/History.tsx +++ b/src/features/user/Account/History.tsx @@ -184,9 +184,9 @@ export default function History({ ) : paymentHistory && Array.isArray(paymentHistory?.items) && paymentHistory.items.length === 0 ? ( -
- -
+
+ +
) : ( paymentHistory && Array.isArray(paymentHistory?.items) && diff --git a/src/features/user/Account/PauseModal.tsx b/src/features/user/Account/PauseModal.tsx index 16c8c13c78..810944b220 100644 --- a/src/features/user/Account/PauseModal.tsx +++ b/src/features/user/Account/PauseModal.tsx @@ -78,11 +78,11 @@ export const PauseModal = ({ setDisabled(true); const bodyToSend = { pauseType: - option == 'pauseForMonth' || option == 'pauseUntilDate' + option === 'pauseForMonth' || option === 'pauseUntilDate' ? 'custom-date' : 'infinite', //custom-date | infinite pauseUntil: - option == 'pauseForMonth' || option == 'pauseUntilDate' + option === 'pauseForMonth' || option === 'pauseUntilDate' ? date?.toISOString().split('T')[0] : null, // only if pauseType='custom-date' }; @@ -134,7 +134,7 @@ export const PauseModal = ({ tabIndex={0} className={styles.headerCloseIcon} > - +
@@ -164,13 +164,13 @@ export const PauseModal = ({ />):[]} */} } label={t('pauseUntilResume')} /> } label={t('pauseUntilDate')} /> diff --git a/src/features/user/Account/ReactivateModal.tsx b/src/features/user/Account/ReactivateModal.tsx index e640ef8a44..2e2e17e52b 100644 --- a/src/features/user/Account/ReactivateModal.tsx +++ b/src/features/user/Account/ReactivateModal.tsx @@ -85,7 +85,7 @@ export const ReactivateModal = ({ tabIndex={0} className={styles.headerCloseIcon} > - +
diff --git a/src/features/user/BulkCodes/forms/IssueCodesForm.tsx b/src/features/user/BulkCodes/forms/IssueCodesForm.tsx index b3ea3844ab..c918fba104 100644 --- a/src/features/user/BulkCodes/forms/IssueCodesForm.tsx +++ b/src/features/user/BulkCodes/forms/IssueCodesForm.tsx @@ -239,7 +239,7 @@ const IssueCodesForm = (): ReactElement | null => { const shouldDisableSubmission = useMemo(() => { const hasSufficientFunds = - user?.planetCash != null && + user?.planetCash !== null && user.planetCash.balance + user.planetCash.creditLimit > 0; const hasEnteredRequiredData = localRecipients.length > 0 || @@ -316,7 +316,7 @@ const IssueCodesForm = (): ReactElement | null => { if (!isSubmitted) { return ( - +
0 && ( -
- {addressSugggestions.map((suggestion) => { +
+ {addressSugggestions.map((suggestion) => { return (
); })} -
+
) : null} @@ -583,14 +583,14 @@ export default function CompleteSignup(): ReactElement | null {
-
-
{'m²'}
+
m²
{restoredArea !== null && plantedTrees !== null && restoredArea > 0 && diff --git a/src/features/user/Profile/components/MyContributions/index.tsx b/src/features/user/Profile/components/MyContributions/index.tsx index e411438586..1681486320 100644 --- a/src/features/user/Profile/components/MyContributions/index.tsx +++ b/src/features/user/Profile/components/MyContributions/index.tsx @@ -63,7 +63,7 @@ export default function MyContributions({ ) { setIsConservedButtonActive(true); } else if ( - treePlantationContribution?.pages[0].data.length == + treePlantationContribution?.pages[0].data.length === conservationContribution?.pages[0].data.length ) { setIsTreePlantedButtonActive(true); diff --git a/src/features/user/Profile/components/MyContributions/microComponents/AddTargetModal.tsx b/src/features/user/Profile/components/MyContributions/microComponents/AddTargetModal.tsx index 74eb802c6b..97486985fb 100644 --- a/src/features/user/Profile/components/MyContributions/microComponents/AddTargetModal.tsx +++ b/src/features/user/Profile/components/MyContributions/microComponents/AddTargetModal.tsx @@ -114,7 +114,7 @@ export default function AddTargetModal({ />
{errors.target && ( - {t('targetErrorMessage')} + {t('targetErrorMessage')} )} {errors.target ? (
@@ -122,13 +122,13 @@ export default function AddTargetModal({
) : (
diff --git a/src/features/user/RegisterTrees/RegisterTrees/SingleContribution.tsx b/src/features/user/RegisterTrees/RegisterTrees/SingleContribution.tsx index 4cd9e78c8a..c49ada07c2 100644 --- a/src/features/user/RegisterTrees/RegisterTrees/SingleContribution.tsx +++ b/src/features/user/RegisterTrees/RegisterTrees/SingleContribution.tsx @@ -73,7 +73,7 @@ export default function SingleContribution({
{t((location as PlantLocationBase).captureStatus)} diff --git a/src/features/user/TreeMapper/index.tsx b/src/features/user/TreeMapper/index.tsx index 46fd1926a4..ec7c0afc21 100644 --- a/src/features/user/TreeMapper/index.tsx +++ b/src/features/user/TreeMapper/index.tsx @@ -175,7 +175,7 @@ function TreeMapper(): ReactElement { return (
{progress > 0 && ( -
+
)} diff --git a/src/features/user/Widget/DonationLink/DonationLinkForm.tsx b/src/features/user/Widget/DonationLink/DonationLinkForm.tsx index a9b3a51c1c..f2cff84bb4 100644 --- a/src/features/user/Widget/DonationLink/DonationLinkForm.tsx +++ b/src/features/user/Widget/DonationLink/DonationLinkForm.tsx @@ -68,14 +68,14 @@ const DonationLinkForm = ({ : process.env.NEXT_PUBLIC_DONATION_URL; const selectedLanguage = - Languages && Languages.langCode != 'auto' + Languages && Languages.langCode !== 'auto' ? `locale=${Languages.langCode}&` : ''; const selectedCountry = country !== 'auto' ? `country=${country}&` : ''; const url = `${link}?${selectedCountry}${selectedLanguage}${ - localProject == null ? '' : `to=${localProject.slug}&` + localProject === null ? '' : `to=${localProject.slug}&` }tenant=${tenantConfig?.id}${isSupport ? `&s=${user?.slug}` : ''} `; if (donationUrl.length > 0) setIsLinkUpdated(true); @@ -135,7 +135,7 @@ const DonationLinkForm = ({ diff --git a/src/features/user/Widget/EmbedModal.tsx b/src/features/user/Widget/EmbedModal.tsx index 70acb6969c..769743f252 100644 --- a/src/features/user/Widget/EmbedModal.tsx +++ b/src/features/user/Widget/EmbedModal.tsx @@ -114,7 +114,7 @@ export default function EmbedModal({ style={{ justifyContent: 'center' }} >
diff --git a/src/temp/ProjectSiteDropdown/index.tsx b/src/temp/ProjectSiteDropdown/index.tsx index e93f37e180..5ca40cd6ec 100644 --- a/src/temp/ProjectSiteDropdown/index.tsx +++ b/src/temp/ProjectSiteDropdown/index.tsx @@ -7,7 +7,7 @@ import { useTranslations } from 'next-intl'; interface SiteType { name: string; - area: Number; + area: number; } interface Props { siteList: SiteType[]; @@ -36,7 +36,7 @@ const ProjectSiteDropdown = ({ selectedOption, siteList, isOpen }: Props) => { >
{/* to be replaced */} - +