Skip to content

Commit 3246188

Browse files
authored
refactor: Clean up React lint issues (#1561)
1 parent 12e0848 commit 3246188

14 files changed

Lines changed: 56 additions & 49 deletions

File tree

src/api/gtfsService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export async function getAllRoutesList(operatorId: string, date: Date, signal?:
149149
dateFrom: date,
150150
dateTo: date,
151151
orderBy: 'route_long_name asc',
152-
limit: -1,
152+
limit: 15000,
153153
},
154154
{ signal },
155155
)

src/layout/header/LanguageToggleButton.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ import { Dropdown, type MenuProps } from 'antd'
33
import { useTranslation } from 'react-i18next'
44
import { useTheme } from '../ThemeContext'
55

6-
export const LanguageToggleButton = () => {
7-
const { setLanguage, currentLanguage } = useTheme()
8-
const { t } = useTranslation()
6+
const languages = [
7+
{ key: 'he', label: 'עברית' },
8+
{ key: 'en', label: 'English' },
9+
{ key: 'ru', label: 'Русский' },
10+
{ key: 'ar', label: 'العربية' },
11+
]
912

10-
const languages = [
11-
{ key: 'he', label: 'עברית' },
12-
{ key: 'en', label: 'English' },
13-
{ key: 'ru', label: 'Русский' },
14-
{ key: 'ar', label: 'العربية' },
15-
]
13+
const LangLabel = ({ label }: { label: string }) => (
14+
<div aria-label={label}>
15+
<span>{label}</span>
16+
</div>
17+
)
1618

17-
const LangLabel = ({ label }: { label: string }) => (
18-
<div aria-label={label}>
19-
<span>{label}</span>
20-
</div>
21-
)
19+
const languageOptions: MenuProps['items'] = languages.map(({ key, label }) => ({
20+
key,
21+
label: <LangLabel label={label} />,
22+
}))
2223

23-
const languageOptions: MenuProps['items'] = languages.map(({ key, label }) => ({
24-
key,
25-
label: <LangLabel label={label} />,
26-
}))
24+
export const LanguageToggleButton = () => {
25+
const { setLanguage, currentLanguage } = useTheme()
26+
const { t } = useTranslation()
2727

2828
const handleLanguageChange: MenuProps['onClick'] = ({ key }) => {
2929
setLanguage(key)

src/layout/sidebar/menu/Menu.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,16 @@ const MainMenu = ({ collapsed = false }: MainMenuProps) => {
103103

104104
const items = collapsed ? flatItems : groupedItems
105105

106-
const location = useLocation()
107-
const [current, setCurrent] = useState(getPathWithoutLang(location.pathname) || '/')
106+
const { pathname } = useLocation()
107+
const [current, setCurrent] = useState(getPathWithoutLang(pathname) || '/')
108108

109109
useEffect(() => {
110-
const nextPath = getPathWithoutLang(location.pathname) || '/'
110+
const nextPath = getPathWithoutLang(pathname) || '/'
111111

112112
if (current !== nextPath) {
113113
setCurrent(nextPath)
114114
}
115-
}, [location.pathname, current])
115+
}, [pathname, current])
116116

117117
const handleClick: MenuProps['onClick'] = ({ key }) => {
118118
setCurrent(key)

src/pages/about/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ const Contributors = () => {
190190
</Trans>
191191
</p>
192192
<ol className="contributions">
193-
{isLoading && <p>Loading...</p>}
194-
{isError && <p>Error...</p>}
193+
{isLoading && <p>Loading&hellip;</p>}
194+
{isError && <p>Error&hellip;</p>}
195195
{contributors &&
196196
contributors.map((author) => (
197197
<li key={author.id}>

src/pages/components/YoutubeModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; //TODO:
21
import { InfoCircleOutlined } from '@ant-design/icons'
32
import { Typography } from '@mui/material'
43
import { Modal } from 'antd'
@@ -36,7 +35,7 @@ const InfoYoutubeModal = ({ videoUrl, label, title }: InfoYoutubeModalProps) =>
3635
{title}
3736
</Typography>
3837
<div className="modal-iframe-container">
39-
<iframe allowFullScreen src={videoUrl} />
38+
<iframe allowFullScreen src={videoUrl} title={title} />
4039
</div>
4140
</Modal>
4241
</>

src/pages/components/map-related/MapContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function MapContent({ positions, plannedRouteStops, showNavigationButtons
128128
<Marker key={stop.key} position={[latitude, longitude]} icon={plannedRouteStopMarker} />
129129
)
130130
})}
131-
{positions.length && (
131+
{positions.length > 0 && (
132132
<Polyline
133133
pathOptions={{ color: actualRouteLineColor }}
134134
positions={positions.map((position) => position.loc)}

src/pages/components/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const bySeverityHandler = (a: HourlyData, b: HourlyData) => {
2222
}
2323

2424
export const sortByMode = (hourlyData: HourlyData[] = [], sortingMode: string) => {
25-
return [...hourlyData].sort(sortingMode === 'hour' ? byHourHandler : bySeverityHandler)
25+
return hourlyData.toSorted(sortingMode === 'hour' ? byHourHandler : bySeverityHandler)
2626
}
2727

2828
export const mapColorByExecution = (planned: number, actual: number) => {

src/pages/lineProfile/LineProfileDetails.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ export const LineProfileDetails = ({
4444
title={
4545
<Grid container alignItems="center" flexDirection="column">
4646
<Link to={'/operator?operatorId=' + operatorRef} style={{ lineHeight: 0 }}>
47-
<img src={`../operators-logos/${operatorRef}.svg`} height={60} />
47+
<img
48+
src={`../operators-logos/${operatorRef}.svg`}
49+
alt={`logo of operator ${agencyName}`}
50+
height={60}
51+
/>
4852
</Link>
4953
<Link to={'/operator?operatorId=' + operatorRef} style={{ lineHeight: 0 }}>
5054
<Typography variant="h6" marginBottom="21.5px">

src/pages/operator/OperatorInfo.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ export const OperatorInfo = ({ operatorId }: { operatorId?: string }) => {
3535
}
3636
/>
3737
</InfoTable>
38-
<img src={`../operators-logos/${operator?.ref}.svg`} height={96} />
38+
<img
39+
src={`../operators-logos/${operator?.ref}.svg`}
40+
alt={`logo of operator ${operator?.eng_name}`}
41+
height={96}
42+
/>
3943
</Stack>
4044
</Widget>
4145
)

src/pages/velocityHeatmap/components/VelocityHeatmapRectangles.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { SiriVelocityAggregationPydanticModel } from '@hasadna/open-bus-api-client'
2-
import React, { useContext } from 'react'
2+
import { useContext, useEffect } from 'react'
33
import { Popup, Rectangle } from 'react-leaflet'
44
import dayjs from 'src/dayjs'
55
import { SearchContext } from '../../../model/pageState'
@@ -33,6 +33,7 @@ function getRedOpacityColor(value: number, minV = 0, maxV = 1): string {
3333

3434
interface VelocityHeatmapRectanglesProps {
3535
visMode: VisMode
36+
setMinMax?: (min: number, max: number) => void
3637
}
3738

3839
const DEFAULT_BOUNDS = {
@@ -42,11 +43,10 @@ const DEFAULT_BOUNDS = {
4243
maxLon: 35.7,
4344
}
4445

45-
export const VelocityHeatmapRectangles: React.FC<
46-
VelocityHeatmapRectanglesProps & {
47-
setMinMax?: (min: number, max: number) => void
48-
}
49-
> = ({ visMode, setMinMax }) => {
46+
export const VelocityHeatmapRectangles = ({
47+
visMode,
48+
setMinMax,
49+
}: VelocityHeatmapRectanglesProps) => {
5050
const { search } = useContext(SearchContext)
5151
const zoom = useZoomLevel()
5252
const { data, loading, error, currZoom } = useVelocityAggregationData(
@@ -79,8 +79,8 @@ export const VelocityHeatmapRectangles: React.FC<
7979
}
8080
}
8181
// Pass min/max to parent for legend
82-
React.useEffect(() => {
83-
if (setMinMax) setMinMax(minV, maxV)
82+
useEffect(() => {
83+
setMinMax?.(minV, maxV)
8484
}, [minV, maxV, setMinMax])
8585

8686
return (

0 commit comments

Comments
 (0)