Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Lint issues and updated Eslint rules #2163

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
Fix Lint issues
harshvitra committed Aug 20, 2024
commit 2b2e8444f7541173c662f5ba1d1cbe2ad5a19596
3 changes: 1 addition & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import 'mapbox-gl/dist/mapbox-gl.css';
import 'mapbox-gl-compare/dist/mapbox-gl-compare.css';
import React from 'react';
import TagManager from 'react-gtm-module';
import Router from 'next/router';
import Router, { useRouter } from 'next/router';
import App, { AppProps, AppContext, AppInitialProps } from 'next/app';
import { Auth0Provider } from '@auth0/auth0-react';
import '../src/features/projects/styles/MapPopup.scss';
@@ -16,7 +16,6 @@ import ThemeProvider from '../src/theme/themeContext';
import * as Sentry from '@sentry/node';
import { RewriteFrames } from '@sentry/integrations';
import getConfig from 'next/config';
import { useRouter } from 'next/router';
import { storeConfig } from '../src/utils/storeConfig';
import { browserNotCompatible } from '../src/utils/browsercheck';
import BrowserNotSupported from '../src/features/common/ErrorComponents/BrowserNotSupported';
3 changes: 1 addition & 2 deletions pages/sites/[slug]/[locale]/index.tsx
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import { ErrorHandlingContext } from '../../../../src/features/common/Layout/Err
import DirectGift, {
DirectGiftI,
} from '../../../../src/features/donations/components/DirectGift';
import { useLocale } from 'next-intl';
import { useLocale , AbstractIntlMessages } from 'next-intl';
import { handleError, APIError } from '@planet-sdk/common';
import { SetState } from '../../../../src/features/common/types/common';
import { MapProject } from '../../../../src/features/common/types/ProjectPropsContextInterface';
@@ -27,7 +27,6 @@ import {
GetStaticPropsResult,
} from 'next';
import { defaultTenant } from '../../../../tenant.config';
import { AbstractIntlMessages } from 'next-intl';
import getMessagesForPage from '../../../../src/utils/language/getMessagesForPage';

interface Props {
6 changes: 2 additions & 4 deletions src/features/common/Layout/MyForestContext.tsx
Original file line number Diff line number Diff line change
@@ -7,11 +7,9 @@ import {
useEffect,
} from 'react';
import { PointFeature } from 'supercluster';
import { TestPointProps } from '../types/map';
import { TestPointProps , ViewportProps } from '../types/map';
import { SetState } from '../types/common';
import { ContributionData } from '../types/myForest';
import { StatsResult } from '../types/myForest';
import { ViewportProps } from '../../common/types/map';
import { ContributionData , StatsResult } from '../types/myForest';

interface MyForestContextInterface {
conservationProjectGeoJson: PointFeature<TestPointProps>[];
4 changes: 2 additions & 2 deletions src/features/common/Layout/Navbar/getSubMenu.tsx
Original file line number Diff line number Diff line change
@@ -72,15 +72,15 @@ function GetSubMenuIcons({ title }: Props): ReactElement {

const VTOChallenge = () => {
return (
<div id="overviewButton" className={'link_icon'}>
<div id="overviewButton" className="link_icon">
<VTOChallengeIcon />
</div>
);
};

const Mangroves = () => {
return (
<div id="overviewButton" className={'link_icon'}>
<div id="overviewButton" className="link_icon">
<OceanforceChallengeIcon />
</div>
);
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ const NavigationItem = ({
href={isMobile && hasSubMenu ? router.asPath : navLinkOptions.onclick}
>
{navLinkOptions.title !== 'signIn' && (
<div className={`linkContainer`}>
<div className="linkContainer">
<p className={isActive ? 'activeItem' : ''}>
{t(navLinkOptions.title)}
</p>
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ const NavigationMenu = () => {
};

return headerItems.length > 0 ? (
<nav className={'menuItems'}>
<nav className="menuItems">
{headerItems
.filter(
(headerItem) => headerItem.visible && headerItem.headerKey !== 'shop'
10 changes: 5 additions & 5 deletions src/features/common/Layout/Navbar/microComponents/SubMenu.tsx
Original file line number Diff line number Diff line change
@@ -38,9 +38,9 @@ const SubMenu = ({ subMenu }: SubMenuProps) => {
key={subMenuItem.title}
href={subMenuItem.onclick}
>
<div className={'subMenuContainer'}>
<div className="subMenuContainer">
<GetSubMenuIcons title={subMenuItem.title} />
<div className={'menuText'}>
<div className="menuText">
{t(subMenuItem.title as SubmenuTitle)}
</div>
</div>
@@ -55,14 +55,14 @@ const SubMenu = ({ subMenu }: SubMenuProps) => {
return (
<a
key={subMenuItem.title}
className={'menuRow'}
className="menuRow"
href={`https://www.plant-for-the-planet.org/${getLanguagePath(
locale
)}/${path}`}
>
<div className={'subMenuContainer'}>
<div className="subMenuContainer">
<GetSubMenuIcons title={subMenuItem.title} />
<div className={'menuText'}>
<div className="menuText">
{t(subMenuItem.title as SubmenuTitle)}
</div>
</div>
3 changes: 1 addition & 2 deletions src/features/common/RedeemCode/EnterRedeemCode.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import TextField from '@mui/material/TextField';
import { useTranslations } from 'next-intl';
import { Controller, useForm } from 'react-hook-form';
import { ReactElement } from 'react';
import React, { ReactElement } from 'react';
import CancelIcon from '../../../../public/assets/images/icons/CancelIcon';
import styles from '../../../../src/features/common/RedeemCode/style/RedeemModal.module.scss';
import Button from '@mui/material/Button';
import React from 'react';
import { SetState } from '../types/common';

export interface EnterRedeemCodeProps {
6 changes: 2 additions & 4 deletions src/features/common/types/map.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import Supercluster from 'supercluster';
import { User, UserInfo } from '@planet-sdk/common';
import { MutableRefObject } from 'react';
import { UserPublicProfile } from '@planet-sdk/common';
import {
import { User, UserInfo , UserPublicProfile ,
TreeProjectClassification,
CountryCode,
CurrencyCode,
@@ -11,6 +8,7 @@ import {
Tpo,
UnitTypes,
} from '@planet-sdk/common';
import { MutableRefObject } from 'react';
import { Nullable } from '@planet-sdk/common/build/types/util';
import { ContributionProps } from '../../user/RegisterTrees/RegisterTrees/SingleContribution';
import { FlyToInterpolator } from 'react-map-gl';
3 changes: 1 addition & 2 deletions src/features/common/types/project.d.ts
Original file line number Diff line number Diff line change
@@ -14,12 +14,11 @@ import {
DefaultPaymentConfig,
Certificate,
} from '@planet-sdk/common';
import { FeatureCollection as GeoJson } from 'geojson';
import { FeatureCollection as GeoJson , Polygon } from 'geojson';
import { SetState } from './common';
import { ChangeEvent } from 'react';
import { ViewportFlyToInterpolator } from 'react-map-gl/src/utils/transition/viewport-fly-to-interpolator';
import { Nullable } from '@planet-sdk/common/build/types/util';
import { Polygon } from 'geojson';
import { Option } from '../../user/ManageProjects/components/ProjectSites';

export interface UploadImage extends Image {
2 changes: 1 addition & 1 deletion src/features/projects/components/ProjectSnippet.tsx
Original file line number Diff line number Diff line change
@@ -249,7 +249,7 @@ export default function ProjectSnippet({
)}
</div>

<div className={'projectCost'}>
<div className="projectCost">
{project.allowDonations && !disableDonations && (
<button
id={`ProjSnippetDonate_${project.id}`}
3 changes: 1 addition & 2 deletions src/features/projects/components/maps/PlantLocations.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { ReactElement } from 'react';
import { Layer, Marker } from 'react-map-gl';
import { Source } from 'react-map-gl';
import { Layer, Marker , Source } from 'react-map-gl';
import { useProjectProps } from '../../../common/Layout/ProjectPropsContext';
import styles from '../../styles/PlantLocation.module.scss';
import * as turf from '@turf/turf';
3 changes: 1 addition & 2 deletions src/features/projects/screens/Projects.tsx
Original file line number Diff line number Diff line change
@@ -15,8 +15,7 @@ import { SetState } from '../../common/types/common';
import { MapProject } from '../../common/types/ProjectPropsContextInterface';
import { getRequest } from '../../../utils/apiRequests/api';
import { ErrorHandlingContext } from '../../common/Layout/ErrorHandlingContext';
import { handleError, APIError } from '@planet-sdk/common';
import { Tenant } from '@planet-sdk/common';
import { handleError, APIError , Tenant } from '@planet-sdk/common';
import { useTenant } from '../../common/Layout/TenantContext';

interface Props {
3 changes: 1 addition & 2 deletions src/features/user/MFV2/CommunityContributions/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import styles from './communityContributions.module.scss';
import NoContributions from './NoContributions';
import { ProfileV2Props } from '../../../common/types/profile';
@@ -9,7 +9,6 @@ import { useTranslations } from 'next-intl';
import { useMyForestV2 } from '../../../common/Layout/MyForestContextV2';
import CommunityContributionsIcon from '../../../../../public/assets/images/icons/CommunityContributionsIcon';
import themeProperties from '../../../../theme/themeProperties';
import React from 'react';

type TabOptions = 'most-recent' | 'most-trees';
interface HeaderTabsProps {
6 changes: 2 additions & 4 deletions src/features/user/MFV2/ContributionsMap/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { useEffect, useState } from 'react';
import Map, { MapStyle } from 'react-map-gl-v7/maplibre';
import { useEffect, useState , useRef, MutableRefObject } from 'react';
import Map, { MapStyle , NavigationControl } from 'react-map-gl-v7/maplibre';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid shadowing the global "Map" property.

The variable Map shadows a global property. Consider renaming it to prevent confusion.

- import Map, { MapStyle , NavigationControl } from 'react-map-gl-v7/maplibre';
+ import MapComponent, { MapStyle, NavigationControl } from 'react-map-gl-v7/maplibre';

And update the usage within the file:

- <Map
+ <MapComponent
Tools
Biome

[error] 2-2: Do not shadow the global "Map" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

import getMapStyle from '../../../../utils/maps/getMapStyle';
import 'maplibre-gl/dist/maplibre-gl.css';
import { NavigationControl } from 'react-map-gl-v7/maplibre';
import MapCredits from './Common/MapCredits';
import Markers from './Markers';
import { useRef, MutableRefObject } from 'react';
import style from './Common/common.module.scss';
import ContributionStats from './Common/ContributionStats';
import { ProfilePageType } from '../../../common/types/myForestv2';
3 changes: 1 addition & 2 deletions src/features/user/MFV2/ForestProgress/TargetSwitch.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Switch } from '@mui/material';
import { styled } from '@mui/material';
import { Switch , styled } from '@mui/material';
import themeProperties from '../../../../theme/themeProperties';

interface TargetSwitchProps {
3 changes: 1 addition & 2 deletions src/features/user/MFV2/ForestProgress/TargetTextField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { styled } from '@mui/material';
import { TextField } from '@mui/material';
import { styled , TextField } from '@mui/material';

interface TextFieldProps {
focusColor: string;
3 changes: 1 addition & 2 deletions src/features/user/MFV2/ForestProgress/TargetsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Modal } from '@mui/material';
import styles from './ForestProgress.module.scss';
import { useContext, useEffect } from 'react';
import { useContext, useEffect , useState } from 'react';
import { useMyForestV2 } from '../../../common/Layout/MyForestContextV2';
import { putAuthenticatedRequest } from '../../../../utils/apiRequests/api';
import { useUserProps } from '../../../common/Layout/UserPropsContext';
@@ -11,7 +11,6 @@ import { SetState } from '../../../common/types/common';
import { useTranslations } from 'next-intl';
import CrossIcon from '../../../../../public/assets/images/icons/manageProjects/Cross';
import TargetFormInput from './TargetFormInput';
import { useState } from 'react';

interface TargetsModalProps {
open: boolean;
3 changes: 1 addition & 2 deletions src/features/user/MFV2/MyContributions/ProjectItemCard.tsx
Original file line number Diff line number Diff line change
@@ -7,8 +7,7 @@ import styles from './MyContributions.module.scss';
import {
MyForestProject,
ProfilePageType,
} from '../../../common/types/myForestv2';
import { MyContributionsSingleProject } from '../../../common/types/myForestv2';
MyContributionsSingleProject } from '../../../common/types/myForestv2';
import { useTranslations } from 'next-intl';
import { CountryCode } from '@planet-sdk/common';
import ItemImage from './ItemImage';
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';
import ProjectItemCard from '../../MyContributions/ProjectItemCard';
import { MyForestProject } from '../../../../common/types/myForestv2';
import { MyContributionsSingleProject } from '../../../../common/types/myForestv2';
import { MyForestProject , MyContributionsSingleProject } from '../../../../common/types/myForestv2';

const meta: Meta<typeof ProjectItemCard> = {
component: ProjectItemCard,
3 changes: 1 addition & 2 deletions src/features/user/ManageProjects/components/BasicDetails.tsx
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import React, {
useState,
} from 'react';
import { useForm, Controller } from 'react-hook-form';
import { Button, FormControlLabel, Switch, Tooltip } from '@mui/material';
import { Button, FormControlLabel, Switch, Tooltip , MenuItem, TextField } from '@mui/material';
import { useLocale, useTranslations } from 'next-intl';
import styles from './../StepForm.module.scss';
import MapGL, {
@@ -16,7 +16,6 @@ import MapGL, {
FlyToInterpolator,
} from 'react-map-gl';
import * as d3 from 'd3-ease';
import { MenuItem, TextField } from '@mui/material';
import InfoIcon from './../../../../../public/assets/images/icons/manageProjects/Info';
import {
postAuthenticatedRequest,
Original file line number Diff line number Diff line change
@@ -5,13 +5,11 @@ import { ErrorHandlingContext } from '../../../../common/Layout/ErrorHandlingCon
import { handleError, APIError } from '@planet-sdk/common';
import { trpc } from '../../../../../utils/trpc';
import { Purpose } from '../../../../../utils/constants/myForest';
import { ContributionData } from '../../../../common/types/myForest';
import { StatsResult } from '../../../../common/types/myForest';
import { MyContributionsProps } from '../../../../common/types/map';
import { ContributionData , StatsResult } from '../../../../common/types/myForest';
import { MyContributionsProps , TestPointProps } from '../../../../common/types/map';
import ContributionStats from '../ContributionStats';
import { SetState } from '../../../../common/types/common';
import { PointFeature } from 'supercluster';
import { TestPointProps } from '../../../../common/types/map';
import { MyForestMapLoader } from '../../../../common/ContentLoaders/UserProfile/UserProfile';
import { useMyForest } from '../../../../common/Layout/MyForestContext';
import { useUserProps } from '../../../../common/Layout/UserPropsContext';
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { useLocale, useTranslations } from 'next-intl';
import { useState } from 'react';
import { useState , ReactElement } from 'react';
import Button from '@mui/material/Button';
import myForestStyles from '../../../styles/MyForest.module.scss';
import TreeCounter from '../../../../../common/TreeCounter/TreeCounter';
import { EditTargetSvg } from '../../../../../../../public/assets/images/ProfilePageIcons';
import AddTargetModal from './AddTargetModal';
import ContributedProjectList from './ContributedProjectList';
import { ReactElement } from 'react';
import { TreeContributedProjectListProps } from '../../../../../common/types/myForest';
import { useMyForest } from '../../../../../common/Layout/MyForestContext';
import { useRouter } from 'next/router';
Original file line number Diff line number Diff line change
@@ -4,9 +4,8 @@ import formatDate from '../../../../../../utils/countryCurrency/getFormattedDate
import { Cluster, ClusterMarker } from '../../../../../common/types/map';
import { useMyForest } from '../../../../../common/Layout/MyForestContext';
import { _getClusterGeojson } from '../../../../../../utils/superclusterConfigV1';
import { useContext, useEffect } from 'react';
import { useContext, useEffect , MutableRefObject } from 'react';
import { PopUpDonationIcon } from '../../../../../../../public/assets/images/ProfilePageIcons';
import { MutableRefObject } from 'react';
import getImageUrl from '../../../../../../utils/getImageURL';
import { Button } from '@mui/material';
import format from 'date-fns/format';
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { TreePlantedClusterMarker } from './ClusterMarker';
import SingleMarker from './SingleMarker';
import { useState, useEffect, ReactElement } from 'react';
import React from 'react';
import React, { useState, useEffect, ReactElement } from 'react';
import {
Cluster,
ClusterMarkerProps,
3 changes: 1 addition & 2 deletions src/features/user/RegisterTrees/RegisterTreesWidget.tsx
Original file line number Diff line number Diff line change
@@ -30,8 +30,7 @@ import themeProperties from '../../../theme/themeProperties';
import StyledForm from '../../common/Layout/StyledForm';
import InlineFormDisplayGroup from '../../common/Layout/Forms/InlineFormDisplayGroup';
import { useTenant } from '../../common/Layout/TenantContext';
import { ViewportProps } from '../../common/types/map';
import {
import { ViewportProps ,
RegisterTreesFormProps,
RegisterTreeGeometry,
ProjectGeoJsonProps,
3 changes: 1 addition & 2 deletions src/features/user/Widget/DonationLink/DonationLinkForm.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ReactElement, useState, useEffect } from 'react';
import React, { ReactElement, useState, useEffect } from 'react';
import { useTranslations } from 'next-intl';
import { Button, Switch, TextField } from '@mui/material';
import AutoCompleteCountry from '../../../common/InputTypes/AutoCompleteCountry';
import { useUserProps } from '../../../common/Layout/UserPropsContext';
import InlineFormDisplayGroup from '../../../common/Layout/Forms/InlineFormDisplayGroup';
import supportedLanguages from '../../../../utils/language/supportedLanguages.json';
import React from 'react';
import ProjectSelectAutocomplete from '../../BulkCodes/components/ProjectSelectAutocomplete';
import { useTenant } from '../../../common/Layout/TenantContext';
import styles from '../../../../../src/features/user/Widget/DonationLink/DonationLinkForm.module.scss';
3 changes: 1 addition & 2 deletions src/temp/Explore/MapLayerOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useState, ChangeEvent } from 'react';
import style from '../Explore/Explore.module.scss';
import { MapLayerToggle } from './ExploreProject';
import { MapLayerToggle , YearRangeSlider } from './ExploreProject';
import InfoIcon from '../icons/InfoIcon';
import { StyledSwitch } from './CustomSwitch';
import { YearRangeSlider } from './ExploreProject';
import { useTranslations } from 'next-intl';
import themeProperties from '../../theme/themeProperties';

3 changes: 1 addition & 2 deletions src/temp/ProjectListControls/ProjectListControlForMobile.tsx
Original file line number Diff line number Diff line change
@@ -4,9 +4,8 @@ import ProjectListTabForMobile from './ProjectListTabForMobile';
import { SearchAndFilter } from './ProjectSearchAndFilter';
import ViewModeTabs from './ViewModeTabs';
import ClassificationDropDown from './ClassificationDropDown';
import { ProjectListControlsProps } from '.';
import { ProjectListControlsProps , Classification } from '.';
import ActiveSearchField from './ActiveSearchField';
import { Classification } from '.';

const ProjectListControlForMobile = ({
availableFilters,
3 changes: 1 addition & 2 deletions src/temp/stories/ProjectListControls.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ProjectListControls from '../ProjectListControls';
import ProjectListControls, { Classification } from '../ProjectListControls';
import type { Meta, StoryObj } from '@storybook/react';
import { Classification } from '../ProjectListControls';

const meta: Meta<typeof ProjectListControls> = {
title: 'Projects/Landing/ProjectListControls',
Loading