Skip to content

Commit 79a17e7

Browse files
committed
Ran lint
1 parent 8544899 commit 79a17e7

8 files changed

Lines changed: 62 additions & 41 deletions

File tree

web-app/src/app/components/CoveredAreaMap.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
183183
);
184184
};
185185

186-
const mapDisplayError = boundingBox == undefined && geoJsonError;
187186
const latestAutodiscoveryUrl = getGbfsLatestVersionVisualizationUrl(
188187
feed as GBFSFeedType,
189188
);

web-app/src/app/components/GtfsVisualizationMap.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { type LatLngExpression } from 'leaflet';
1717
import type { FeatureCollection } from 'geojson';
1818
import { Box, useTheme } from '@mui/material';
1919
import { MapElement, MapRouteElement, MapStopElement } from './MapElement';
20+
import type { MapElementType } from './MapElement';
2021
import {
2122
reversedRouteTypesMapping,
2223
} from '../constants/RouteTypes';
@@ -81,7 +82,7 @@ export const GtfsVisualizationMap = ({
8182
const theme = useTheme();
8283
const [hoverInfo, setHoverInfo] = useState<string[]>([]);
8384
const [hoverData, setHoverData] = useState<string>('');
84-
const [mapElement, setMapElement] = useState<MapElement[]>([]);
85+
const [mapElements, setMapElements] = useState<MapElementType[]>([]);
8586
const [mapClickRouteData, setMapClickRouteData] = useState<Record<
8687
string,
8788
string
@@ -98,7 +99,7 @@ export const GtfsVisualizationMap = ({
9899

99100
// Create a map to store routeId to routeColor mapping
100101
const routeIdToColorMap: Record<string, string> = {};
101-
mapElement.forEach((el) => {
102+
mapElements.forEach((el) => {
102103
if (!el.isStop) {
103104
const routeElement: MapRouteElement = el as MapRouteElement;
104105
if (routeElement.routeId && routeElement.routeColor) {
@@ -179,7 +180,7 @@ export const GtfsVisualizationMap = ({
179180
const handleMouseMove = (event: maplibregl.MapLayerMouseEvent): void => {
180181
// Ensure that the mapRef is not null before trying to access the map
181182
const map = mapRef.current?.getMap();
182-
const mapElements: MapElement[] = [];
183+
const mapElements: MapElementType[] = [];
183184

184185
if (map != undefined) {
185186
// Get the features under the mouse pointer
@@ -225,7 +226,7 @@ export const GtfsVisualizationMap = ({
225226
};
226227
mapElements.push(mapElement);
227228
} else {
228-
const mapElement: MapElement = {
229+
const mapElement: MapRouteElement = {
229230
isStop: false,
230231
name: feature.properties.route_long_name,
231232
routeType: feature.properties.route_type,
@@ -237,8 +238,7 @@ export const GtfsVisualizationMap = ({
237238
}
238239
});
239240

240-
setMapElement(mapElements);
241-
241+
setMapElements(mapElements);
242242
const elementIds: string[] = [];
243243
features.forEach((feature) => {
244244
if (feature.properties.route_id != undefined) {
@@ -251,7 +251,7 @@ export const GtfsVisualizationMap = ({
251251
} else {
252252
setHoverInfo([]);
253253
setHoverData('');
254-
setMapElement([]);
254+
setMapElements([]);
255255
}
256256
}
257257
};
@@ -320,7 +320,7 @@ export const GtfsVisualizationMap = ({
320320
borderRadius: '5px',
321321
}}
322322
>
323-
<MapElement mapElements={mapElement}></MapElement>
323+
<MapElement mapElements={mapElements}></MapElement>
324324
<Map
325325
onClick={(event) => {
326326
handleMouseClick(event);

web-app/src/app/components/Map/MapDataPopup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ export const MapDataPopup = (
146146
</Typography>
147147

148148
{mapClickStopData.route_ids != null &&
149-
mapClickStopData.route_ids.replace(/[\[\]"\\]/g, ',').length >
149+
mapClickStopData.route_ids.replace(/[[\]"\\]/g, ',').length >
150150
0 && (
151151
<Typography variant='body2'>
152152
<span style={{ marginRight: '8px' }}>Route Ids</span>
153153
<b>
154-
{mapClickStopData.route_ids.replace(/[\[\]"\\]/g, ' ')}
154+
{mapClickStopData.route_ids.replace(/[[\]"\\]/g, ' ')}
155155
</b>
156156
</Typography>
157157
)}

web-app/src/app/components/MapElement.tsx

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ export interface MapStopElement extends BaseMapElement {
2424
stopId: string;
2525
}
2626

27-
export type MapElement = MapRouteElement | MapStopElement;
27+
export type MapElementType = MapRouteElement | MapStopElement;
2828

2929
export interface MapElementProps {
30-
mapElements: MapElement[];
30+
mapElements: MapElementType[];
3131
}
3232

3333
export const MapElement = (
3434
props: React.PropsWithChildren<MapElementProps>,
3535
): JSX.Element => {
3636
const theme = useTheme();
3737
const formatSet = new Set();
38-
const formattedElements: MapElement[] = [];
38+
const formattedElements: MapElementType[] = [];
3939

4040
props.mapElements.forEach((element) => {
4141
if (!formatSet.has(element.name)) {
@@ -50,12 +50,12 @@ export const MapElement = (
5050
routeColorText: string,
5151
): JSX.Element | null => {
5252
// The route type could be out of specs (e.g. google route types), so we may not have an icon.
53-
if (!routeTypeMetadata || !routeTypeMetadata.icon) {
54-
// Optionally render a default icon or return null
55-
return null;
53+
if (routeTypeMetadata?.icon == null) {
54+
// Optionally render a default icon or return null
55+
return null;
5656
}
5757
const { icon: Icon } = routeTypeMetadata;
58-
return <Icon style={{ color: routeColorText, fontSize: 20 }} />;
58+
return <Icon style={{ color: routeColorText, fontSize: 20 }} />;
5959
};
6060

6161
const renderRouteMapElement = (element: MapRouteElement): JSX.Element => {
@@ -65,17 +65,23 @@ export const MapElement = (
6565
display: 'flex',
6666
alignItems: 'center',
6767
gap: 1,
68-
color: element.routeTextColor
69-
? '#' + element.routeTextColor
70-
: '000000',
71-
background: element.routeColor ? '#' + element.routeColor : 'ffffff',
68+
color:
69+
element.routeTextColor !== ''
70+
? '#' + element.routeTextColor
71+
: '#000000',
72+
background:
73+
element.routeColor !== '' ? '#' + element.routeColor : '#ffffff',
7274
padding: '5px',
7375
borderRadius: '5px',
7476
}}
7577
>
7678
{renderRouteTypeIcon(
77-
routeTypesMapping[element.routeType?.toString() || '0'],
78-
element.routeTextColor ? '#' + element.routeTextColor : '#000000',
79+
routeTypesMapping[
80+
element.routeType != null ? element.routeType.toString() : '0'
81+
],
82+
element.routeTextColor !== ''
83+
? '#' + element.routeTextColor
84+
: '#000000',
7985
)}
8086

8187
<Typography gutterBottom sx={{ color: 'inherit', fontSize: 14, m: 0 }}>
@@ -85,7 +91,10 @@ export const MapElement = (
8591
);
8692
};
8793

88-
const renderStopMapElement = (element: MapStopElement, iconColor: string): JSX.Element => {
94+
const renderStopMapElement = (
95+
element: MapStopElement,
96+
iconColor: string,
97+
): JSX.Element => {
8998
return (
9099
<Box
91100
sx={{
@@ -97,7 +106,9 @@ export const MapElement = (
97106
}}
98107
>
99108
{renderRouteTypeIcon(
100-
locationTypesMapping[element.locationType?.toString() || '0'],
109+
locationTypesMapping[
110+
element.locationType != null ? element.locationType.toString() : '0'
111+
],
101112
iconColor,
102113
)}
103114

@@ -135,7 +146,12 @@ export const MapElement = (
135146
{element.isStop ? 'Stop' : 'Route'}
136147
</Typography>
137148
{element.isStop ? (
138-
<>{renderStopMapElement(element as MapStopElement, theme.palette.text.primary)}</>
149+
<>
150+
{renderStopMapElement(
151+
element as MapStopElement,
152+
theme.palette.text.primary,
153+
)}
154+
</>
139155
) : (
140156
<>{renderRouteMapElement(element as MapRouteElement)}</>
141157
)}

web-app/src/app/components/RouteSelector.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@mui/material';
1212

1313
interface RouteSelectorProps {
14-
routes: any[]; // Replace 'any' with a more specific type if available
14+
routes: Array<{ routeId: string; routeName: string; color?: string }>;
1515
selectedRouteIds?: string[];
1616
onSelectionChange?: (selectedRoutes: string[]) => void;
1717
}
@@ -20,7 +20,7 @@ export default function RouteSelector({
2020
routes,
2121
selectedRouteIds = [],
2222
onSelectionChange,
23-
}: RouteSelectorProps) {
23+
}: RouteSelectorProps): React.ReactElement {
2424
const [search, setSearch] = useState('');
2525
const [selectedRoutes, setSelectedRoutes] =
2626
useState<string[]>(selectedRouteIds);
@@ -38,7 +38,7 @@ export default function RouteSelector({
3838
setSelectedRoutes([...selectedRouteIds]);
3939
}, [selectedRouteIds]);
4040

41-
const handleToggle = (routeId: string) => {
41+
const handleToggle = (routeId: string): void => {
4242
setSelectedRoutes((prev) => {
4343
const newSelection = prev.includes(routeId)
4444
? prev.filter((id) => id !== routeId)
@@ -69,17 +69,21 @@ export default function RouteSelector({
6969
size='small'
7070
placeholder='Search routes...'
7171
value={search}
72-
onChange={(e) => setSearch(e.target.value)}
72+
onChange={(e) => {
73+
setSearch(e.target.value);
74+
}}
7375
/>
7476

7577
<List dense sx={{ maxHeight: 'none', overflow: 'auto', flex: 1 }}>
7678
{filteredRoutes
77-
.sort((a, b) => a.routeId - b.routeId)
79+
.sort((a, b) => a.routeId.localeCompare(b.routeId))
7880
.map((route) => (
7981
<ListItemButton
8082
key={route.routeId}
8183
sx={{ pl: 0 }}
82-
onClick={() => handleToggle(route.routeId)}
84+
onClick={() => {
85+
handleToggle(route.routeId);
86+
}}
8387
dense={true}
8488
>
8589
<ListItemIcon sx={{ minWidth: 34 }}>
@@ -97,7 +101,7 @@ export default function RouteSelector({
97101
sx={{
98102
width: 16,
99103
height: 16,
100-
backgroundColor: route.color || '#000',
104+
backgroundColor: route.color ?? '#000',
101105
borderRadius: '4px',
102106
mr: 1,
103107
border: '1px solid #999',

web-app/src/app/router/Router.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const AppRouter: React.FC = () => {
102102
/>
103103
<Route path='feeds/:feedId' element={<Feed />} />
104104
<Route path='feeds/:feedDataType/:feedId' element={<Feed />} />
105-
<Route path='feeds/:feedId/map' element={<FullMapView/>} />
105+
<Route path='feeds/:feedId/map' element={<FullMapView />} />
106106
<Route path='feeds/:feedDataType/:feedId/map' element={<FullMapView />} />
107107
<Route path='contribute' element={<FeedSubmission />} />
108108
<Route path='contribute/submitted' element={<FeedSubmitted />} />

web-app/src/app/screens/Feed/components/FullMapView.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
} from '../Map.styles';
2020
import {
2121
selectBoundingBoxFromLatestDataset,
22-
selectDatasetsLoadingStatus,
2322
selectLatestDatasetsData,
2423
} from '../../../store/selectors';
2524
import { useSelector } from 'react-redux';
@@ -29,7 +28,7 @@ import { useAppDispatch } from '../../../hooks';
2928

3029
export default function FullMapView(): React.ReactElement {
3130
const { t } = useTranslation('feeds');
32-
const { feedId, feedDataType } = useParams();
31+
const { feedId } = useParams();
3332
const theme = useTheme();
3433
const [filteredRoutes, setFilteredRoutes] = useState<string[]>([]);
3534
const [filteredRouteTypes, setFilteredRouteTypes] = useState<string[]>([]);
@@ -38,7 +37,6 @@ export default function FullMapView(): React.ReactElement {
3837
useState<boolean>(false);
3938
const latestDataset = useSelector(selectLatestDatasetsData);
4039
const boundingBox = useSelector(selectBoundingBoxFromLatestDataset);
41-
const datasetLoadingStatus = useSelector(selectDatasetsLoadingStatus);
4240
const dispatch = useAppDispatch();
4341

4442
const clearAllFilters = (): void => {
@@ -253,7 +251,9 @@ export default function FullMapView(): React.ReactElement {
253251
<Button
254252
variant='contained'
255253
fullWidth
256-
onClick={() => setShowMapControlMobile(!showMapControlMobile)}
254+
onClick={() => {
255+
setShowMapControlMobile(!showMapControlMobile);
256+
}}
257257
>
258258
Back To Map
259259
</Button>
@@ -300,7 +300,9 @@ export default function FullMapView(): React.ReactElement {
300300
}}
301301
size='small'
302302
aria-label='filter'
303-
onClick={() => setShowMapControlMobile(!showMapControlMobile)}
303+
onClick={() => {
304+
setShowMapControlMobile(!showMapControlMobile);
305+
}}
304306
>
305307
<FilterAltIcon />
306308
</Fab>

web-app/src/app/screens/Feed/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export default function Feed(): React.ReactElement {
342342
<Box sx={{ position: 'relative' }}>
343343
<Grid container item xs={12} spacing={3} alignItems={'end'}>
344344
<Button
345-
sx={{py: 0}}
345+
sx={{ py: 0 }}
346346
size='large'
347347
startIcon={<ChevronLeft />}
348348
color={'inherit'}

0 commit comments

Comments
 (0)