Skip to content

Commit dff2430

Browse files
committed
chore: linting fixes
1 parent 6428961 commit dff2430

38 files changed

Lines changed: 250 additions & 1698 deletions

frontend/.eslintrc.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"plugin:react/recommended",
55
"plugin:prettier/recommended",
66
"airbnb",
7-
"prettier",
8-
"wikimedia/client/es6"],
7+
"prettier"],
98
"plugins": ["react", "prettier", "eslint-plugin-react", "eslint-plugin-react-hooks"],
109
"parser": "@babel/eslint-parser",
1110
"parserOptions": {
@@ -34,11 +33,8 @@
3433
"arrow-parens": "off",
3534
"class-methods-use-this": "error",
3635
"import/prefer-default-export": "error",
37-
"react/require-default-props": "error",
36+
"react/require-default-props": ["error", { "functions": "defaultArguments" }],
3837
"comma-dangle": "off",
39-
"es-x/no-rest-spread-properties": "off",
40-
"es-x/no-trailing-function-commas": "off",
41-
"es-x/no-global-this": "off",
4238
"indent": ["error", 4],
4339
"implicit-arrow-linebreak": "off",
4440
"react/function-component-definition": [

frontend/package-lock.json

Lines changed: 7 additions & 1483 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"eslint": "^8.30.0",
4343
"eslint-config-airbnb": "^19.0.4",
4444
"eslint-config-prettier": "^8.10.0",
45-
"eslint-config-wikimedia": "^0.28.2",
4645
"eslint-plugin-import": "^2.27.5",
4746
"eslint-plugin-jsx-a11y": "^6.7.1",
4847
"eslint-plugin-prettier": "^4.2.1",
@@ -64,6 +63,7 @@
6463
"@emotion/styled": "^11.11.0",
6564
"@mui/icons-material": "^5.14.6",
6665
"@mui/material": "^5.14.6",
66+
"@react-leaflet/core": "^2.1.0",
6767
"axios": "^1.7.6",
6868
"browser-image-compression": "^2.0.2",
6969
"i18next": "^23.15.1",

frontend/src/components/Categories/CategoriesContext.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState, useContext, createContext, useMemo, useEffect, useCallback } from 'react';
2+
import PropTypes from 'prop-types';
23
import { httpService } from '../../services/http/httpService';
34

45
/**
@@ -67,6 +68,10 @@ export const CategoriesProvider = ({ children }) => {
6768
return <CategoriesContext.Provider value={value}>{children}</CategoriesContext.Provider>;
6869
};
6970

71+
CategoriesProvider.propTypes = {
72+
children: PropTypes.node.isRequired,
73+
};
74+
7075
/**
7176
* Custom hook to access categories context.
7277
* Must be used within a CategoriesProvider component.

frontend/src/components/FiltersForm/FiltersForm.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ const LoadingSkeleton = () => (
239239
</>
240240
);
241241

242-
export const FiltersForm = () => {
242+
const FiltersForm = () => {
243243
const { t } = useTranslation();
244244
const {
245245
categories: selectedFilters,
@@ -456,3 +456,5 @@ export const FiltersForm = () => {
456456
</form>
457457
);
458458
};
459+
460+
export default FiltersForm;

frontend/src/components/FiltersForm/FiltersTooltip.jsx

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,35 @@ const IconWrapper = styled.span`
2727
* @param {string} props.text - The help text to display in the tooltip
2828
* @returns {React.ReactElement} Info icon with attached MUI tooltip
2929
*/
30-
const FiltersTooltip = ({ text }) => {
31-
return (
32-
<Tooltip
33-
title={text}
34-
placement="top"
35-
arrow
36-
enterTouchDelay={0}
37-
leaveTouchDelay={3000}
38-
slotProps={{
39-
tooltip: {
40-
sx: {
41-
backgroundColor: 'rgba(50, 50, 50, 0.95)',
42-
fontSize: '12px',
43-
padding: '8px 12px',
44-
maxWidth: '250px',
45-
lineHeight: 1.4,
46-
},
30+
const FiltersTooltip = ({ text }) => (
31+
<Tooltip
32+
title={text}
33+
placement="top"
34+
arrow
35+
enterTouchDelay={0}
36+
leaveTouchDelay={3000}
37+
slotProps={{
38+
tooltip: {
39+
sx: {
40+
backgroundColor: 'rgba(50, 50, 50, 0.95)',
41+
fontSize: '12px',
42+
padding: '8px 12px',
43+
maxWidth: '250px',
44+
lineHeight: 1.4,
4745
},
48-
arrow: {
49-
sx: {
50-
color: 'rgba(50, 50, 50, 0.95)',
51-
},
46+
},
47+
arrow: {
48+
sx: {
49+
color: 'rgba(50, 50, 50, 0.95)',
5250
},
53-
}}
54-
>
55-
<IconWrapper aria-label={`Help: ${text}`}>
56-
<InfoOutlinedIcon sx={{ fontSize: 16 }} />
57-
</IconWrapper>
58-
</Tooltip>
59-
);
60-
};
51+
},
52+
}}
53+
>
54+
<IconWrapper aria-label={`Help: ${text}`}>
55+
<InfoOutlinedIcon sx={{ fontSize: 16 }} />
56+
</IconWrapper>
57+
</Tooltip>
58+
);
6159

6260
FiltersTooltip.propTypes = {
6361
text: PropTypes.string.isRequired,

frontend/src/components/Map/Map.jsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import ReactDOM from 'react-dom/client';
2-
import React, { useEffect } from 'react';
3-
import { httpService } from '../../services/http/httpService';
4-
import { FiltersForm } from '../FiltersForm/FiltersForm';
5-
import { MapComponent } from './MapComponent';
6-
import { useMapStore } from './store/map.store';
7-
import { CategoriesProvider } from '../Categories/CategoriesContext';
2+
import React from 'react';
83
import { createPortal } from 'react-dom';
9-
import { AppToaster } from '../common/AppToaster';
10-
import useDebounce from '../../utils/hooks/useDebounce';
4+
import FiltersForm from '../FiltersForm/FiltersForm';
5+
import MapComponent from './MapComponent';
6+
import { CategoriesProvider } from '../Categories/CategoriesContext';
7+
import AppToaster from '../common/AppToaster';
118

129
/**
1310
* Wrapper component that renders the map and filters form into their respective DOM placeholders.
@@ -41,10 +38,12 @@ const MapWrap = () => {
4138
*
4239
* @returns {void}
4340
*/
44-
export const MapContainer = () => {
41+
const MapContainer = () => {
4542
const appContainer = document.createElement('div');
4643
document.body.appendChild(appContainer);
4744

4845
const root = ReactDOM.createRoot(appContainer);
4946
root.render(<MapWrap />);
5047
};
48+
49+
export default MapContainer;

frontend/src/components/Map/MapComponent.jsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import React, { useState } from 'react';
22
import { MapContainer, TileLayer } from 'react-leaflet';
33
import Control from 'react-leaflet-custom-control';
4-
import { LocationControl } from './components/LocationControl';
5-
import { SuggestNewPointButton } from './components/SuggestNewPointButton';
6-
import { LocationPermissionBanner } from './components/LocationPermissionBanner';
4+
import LocationControl from './components/LocationControl';
5+
import SuggestNewPointButton from './components/SuggestNewPointButton';
6+
import LocationPermissionBanner from './components/LocationPermissionBanner';
77
import { mapConfig } from './map.config';
8-
import { CustomZoomControl } from './components/ZoomControl';
8+
import CustomZoomControl from './components/ZoomControl';
99
import MapAutocomplete from './components/MapAutocomplete';
1010
import ListViewButton from './components/ListView';
1111
import AccessibilityTable from './components/AccessibilityTable';
1212
import SaveMapConfiguration from './components/SaveMapConfiguration';
13-
import { Markers } from './components/Markers';
14-
import { MapLoadingOverlay } from './components/MapLoadingOverlay';
13+
import Markers from './components/Markers';
14+
import MapLoadingOverlay from './components/MapLoadingOverlay';
1515
import { LocationProvider, useLocation } from './context/LocationContext';
16-
import { GoToLocation } from './components/GoToLocation';
16+
import GoToLocation from './components/GoToLocation';
1717
import MapOverlays from '../../plugins/MapOverlays';
1818

1919
/**
@@ -83,10 +83,10 @@ const MapComponentInner = () => {
8383
*
8484
* @returns {React.ReactElement} MapContainer with markers and controls, or AccessibilityTable when list view is active
8585
*/
86-
export const MapComponent = () => {
87-
return (
88-
<LocationProvider>
89-
<MapComponentInner />
90-
</LocationProvider>
91-
);
92-
};
86+
const MapComponent = () => (
87+
<LocationProvider>
88+
<MapComponentInner />
89+
</LocationProvider>
90+
);
91+
92+
export default MapComponent;

frontend/src/components/Map/components/AccessibilityTable.jsx

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useMemo, useState } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import Table from '@mui/material/Table';
44
import TableBody from '@mui/material/TableBody';
@@ -44,61 +44,38 @@ const AccessibilityTable = ({ userPosition, setIsAccessibilityTableOpen }) => {
4444
}, [categories, userPosition]);
4545

4646
useEffect(() => {
47+
if (!data) {
48+
return;
49+
}
4750
try {
48-
const uniqueHeadersSet = new Set();
49-
if (!data) {
50-
return;
51-
}
52-
uniqueHeadersSet.add(t('title'));
53-
for (const place of data) {
54-
for (const item of place.data) {
51+
const uniqueHeadersSet = new Set([t('title')]);
52+
data.forEach(place => {
53+
place.data.forEach(item => {
5554
uniqueHeadersSet.add(item[0]);
56-
}
57-
}
58-
const uniqueNumberedKeys = {};
59-
for (const [index, key] of Array.from(uniqueHeadersSet).entries()) {
60-
uniqueNumberedKeys[key] = index;
61-
}
62-
const orderedKeysArray = Object.keys(uniqueNumberedKeys).sort(
63-
(a, b) => uniqueNumberedKeys[a] - uniqueNumberedKeys[b],
64-
);
55+
});
56+
});
57+
const orderedKeysArray = Array.from(uniqueHeadersSet);
6558
setHeaders(orderedKeysArray);
6659

67-
const rowsLocal = [];
68-
6960
const getArr = (placeItem, key) => {
7061
const item = placeItem.find(it => it[0] === key);
71-
if (!item) {
72-
return ['', '—'];
73-
}
74-
return item;
62+
return item || ['', '—'];
7563
};
7664

77-
for (const it of data) {
78-
const row = [];
79-
const place = it.data;
80-
row.push(it.title);
65+
const rowsLocal = data.map(it => {
66+
const row = [it.title];
8167
// Skip first element (title) and iterate over remaining keys
82-
for (const key of orderedKeysArray.slice(1)) {
83-
const values = getArr(place, key);
84-
if (values === undefined) {
85-
continue;
86-
}
87-
const value = values[1];
88-
if (Array.isArray(value)) {
89-
const str = value.join(', ');
90-
row.push(str);
91-
continue;
92-
}
93-
row.push(value);
94-
}
95-
rowsLocal.push(row);
96-
}
68+
orderedKeysArray.slice(1).forEach(key => {
69+
const [, value] = getArr(it.data, key);
70+
row.push(Array.isArray(value) ? value.join(', ') : value);
71+
});
72+
return row;
73+
});
9774
setRows(rowsLocal);
9875
} catch (error) {
9976
console.log('AccessibilityTable: ', error);
10077
}
101-
}, [data]);
78+
}, [data, t]);
10279

10380
return (
10481
<>
@@ -125,13 +102,13 @@ const AccessibilityTable = ({ userPosition, setIsAccessibilityTableOpen }) => {
125102
</TableRow>
126103
</TableHead>
127104
<TableBody>
128-
{rows.map((row, index) => (
105+
{rows.map(row => (
129106
<TableRow
130107
key={row.toString()}
131108
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
132109
>
133-
{row.map((cell, index) => (
134-
<TableCell key={`${cell.toString()}-${index}`} align="center">
110+
{row.map((cell, cellIndex) => (
111+
<TableCell key={headers[cellIndex]} align="center">
135112
{cell.type ? <FieldRenderer value={cell} /> : cell}
136113
</TableCell>
137114
))}

frontend/src/components/Map/components/GoToLocation.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useMapStore } from '../store/map.store';
1010
*
1111
* @returns {null} This component renders nothing
1212
*/
13-
export const GoToLocation = () => {
13+
const GoToLocation = () => {
1414
const map = useMap();
1515
const [hasNavigated, setHasNavigated] = useState(false);
1616
const setSelectedLocationId = useMapStore(state => state.setSelectedLocationId);
@@ -50,3 +50,5 @@ export const GoToLocation = () => {
5050

5151
return null;
5252
};
53+
54+
export default GoToLocation;

0 commit comments

Comments
 (0)