Skip to content

Commit a6899df

Browse files
Front warnings (#1903)
* script * automatic eslint
1 parent 31e3ec9 commit a6899df

File tree

162 files changed

+5223
-3968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+5223
-3968
lines changed

front/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@
9696
"test": "react-scripts test",
9797
"eject": "react-scripts eject",
9898
"docs": "jsdoc -c ./jsdoc.json",
99-
"lint-ts": "eslint --ext .ts,.tsx src"
99+
"lint-ts": "eslint --ext .ts,.tsx src",
100+
"fix-prettier": "prettier-eslint --write \"{,!(node_modules)/**/}*.{js,jsx}\""
100101
},
101102
"eslintConfig": {
102103
"extends": "react-app"
@@ -128,15 +129,16 @@
128129
"eslint": "^7.32.0",
129130
"eslint-config-airbnb": "19.0.4",
130131
"eslint-config-prettier": "^8.5.0",
131-
"eslint-plugin-prettier": "^4.2.0",
132132
"eslint-plugin-babel": "^5.3.0",
133133
"eslint-plugin-flowtype": "^7.0.0",
134134
"eslint-plugin-import": "^2.25.3",
135135
"eslint-plugin-jsx-a11y": "^6.5.1",
136-
"eslint-plugin-react": "^7.28.0",
136+
"eslint-plugin-prettier": "^4.2.1",
137+
"eslint-plugin-react": "^7.31.8",
137138
"eslint-plugin-react-hooks": "^4.3.0",
138139
"jsdoc": "^3.6.11",
139140
"prettier": "^2.7.1",
141+
"prettier-eslint-cli": "^7.1.0",
140142
"react-error-overlay": "6.0.9",
141143
"typescript": "~4.8.2"
142144
},

front/src/applications/carto/Map.js

+10-14
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ import osmBlankStyle from 'common/Map/Layers/osmBlankStyle';
3131
import { updateViewport } from 'reducers/map';
3232
import { useParams } from 'react-router-dom';
3333

34-
const Map = () => {
35-
const {
36-
viewport, mapSearchMarker, mapStyle, mapTrackSources, showOSM, layersSettings,
37-
} = useSelector((state) => state.map);
34+
function Map() {
35+
const { viewport, mapSearchMarker, mapStyle, mapTrackSources, showOSM, layersSettings } =
36+
useSelector((state) => state.map);
3837
const [idHover, setIdHover] = useState(undefined);
39-
const {
40-
urlLat, urlLon, urlZoom, urlBearing, urlPitch,
41-
} = useParams();
38+
const { urlLat, urlLon, urlZoom, urlBearing, urlPitch } = useParams();
4239
const { fullscreen } = useSelector((state) => state.main);
4340
const dispatch = useDispatch();
44-
const updateViewportChange = useCallback((value) => dispatch(updateViewport(value, '/carto')), [dispatch]);
41+
const updateViewportChange = useCallback(
42+
(value) => dispatch(updateViewport(value, '/carto')),
43+
[dispatch]
44+
);
4545

4646
const scaleControlStyle = {
4747
left: 20,
@@ -114,11 +114,7 @@ const Map = () => {
114114
className="attribution-control"
115115
customAttribution="©SNCF/DGEX Solutions"
116116
/>
117-
<ScaleControl
118-
maxWidth={100}
119-
unit="metric"
120-
style={scaleControlStyle}
121-
/>
117+
<ScaleControl maxWidth={100} unit="metric" style={scaleControlStyle} />
122118

123119
<Background colors={colors[mapStyle]} />
124120

@@ -165,6 +161,6 @@ const Map = () => {
165161
</ReactMapGL>
166162
</main>
167163
);
168-
};
164+
}
169165

170166
export default Map;

front/src/applications/carto/PopupInfosCustom.js

+14-15
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import PropTypes from 'prop-types';
33
import kmORm from 'common/distances';
44

55
export function PopupInfosCustomTitle(props) {
6-
const {
7-
nomVoie, codeLigne, longueur, pkSncfDe, pkSncfFi, libelle, pk,
8-
} = props;
6+
const { nomVoie, codeLigne, longueur, pkSncfDe, pkSncfFi, libelle, pk } = props;
97
const distance = kmORm(longueur);
108

119
let title = '';
@@ -25,33 +23,26 @@ export function PopupInfosCustomTitle(props) {
2523
</small>
2624
)}
2725
<small>
28-
{pkSncfDe !== ''
29-
&& (
26+
{pkSncfDe !== '' && (
3027
<>
3128
{pkSncfDe}
3229
<strong> / </strong>
3330
{pkSncfFi}
3431
</>
3532
)}
36-
{pk !== '' && (pk)}
33+
{pk !== '' && pk}
3734
</small>
3835
</>
3936
);
4037
}
4138
PopupInfosCustomTitle.propTypes = {
4239
nomVoie: PropTypes.string,
4340
codeLigne: PropTypes.string,
44-
longueur: PropTypes.oneOfType([
45-
PropTypes.string,
46-
PropTypes.number,
47-
]),
41+
longueur: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
4842
pkSncfDe: PropTypes.string,
4943
pkSncfFi: PropTypes.string,
5044
libelle: PropTypes.string,
51-
pk: PropTypes.oneOfType([
52-
PropTypes.string,
53-
PropTypes.number,
54-
]),
45+
pk: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
5546
};
5647
PopupInfosCustomTitle.defaultProps = {
5748
nomVoie: '',
@@ -65,7 +56,15 @@ PopupInfosCustomTitle.defaultProps = {
6556

6657
export function PopupInfosCustomContent(props) {
6758
const {
68-
codeTiv, idGaia, id, predCategory, predTime, hideId, eventType, failingResource, failureType,
59+
codeTiv,
60+
idGaia,
61+
id,
62+
predCategory,
63+
predTime,
64+
hideId,
65+
eventType,
66+
failingResource,
67+
failureType,
6968
} = props;
7069
return (
7170
<>

front/src/applications/osrd/About.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import React from 'react';
22

33
class AboutOSRD extends React.Component {
44
render() {
5-
return (
6-
<main className="mastcontainer">
7-
About OSRD !
8-
</main>
9-
);
5+
return <main className="mastcontainer">About OSRD !</main>;
106
}
117
}
128

front/src/applications/osrd/Home.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import 'applications/osrd/osrd.scss';
33
import { Route, Routes } from 'react-router-dom';
44
import { connect, useDispatch } from 'react-redux';
55

6-
import AboutOSRD from './About';
76
import MastNavItemSNCF from 'common/BootstrapSNCF/MastNavItemSNCF';
87
import MastNavSNCF from 'common/BootstrapSNCF/MastNavSNCF';
98
import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF';
109
import { Navigate } from 'react-router';
1110
import { NotificationsState } from 'common/Notifications.tsx';
12-
import OSRDSimulation from './views/OSRDSimulation/OSRDSimulation';
13-
import OSRDSimulationConfig from './views/OSDSimulationConfig';
1411
import PropTypes from 'prop-types';
1512
import React from 'react';
1613
import logo from 'assets/logo_osrd_seul_blanc.svg';
1714
import { withTranslation } from 'react-i18next';
15+
import OSRDSimulationConfig from './views/OSDSimulationConfig';
16+
import OSRDSimulation from './views/OSRDSimulation/OSRDSimulation';
17+
import AboutOSRD from './About';
1818

1919
class HomeOSRD extends React.Component {
2020
static propTypes = {
@@ -27,7 +27,7 @@ class HomeOSRD extends React.Component {
2727
return (
2828
<>
2929
<MastNavSNCF
30-
items={(
30+
items={
3131
<>
3232
<MastNavItemSNCF
3333
link="/osrd/settings"
@@ -40,15 +40,15 @@ class HomeOSRD extends React.Component {
4040
icon="icons-itinerary-train"
4141
/>
4242
</>
43-
)}
44-
itemsBottom={(
43+
}
44+
itemsBottom={
4545
<MastNavItemSNCF
4646
link="/osrd/contact"
4747
linkname={t('osrd.nav.contact')}
4848
icon="icons-support"
4949
bottom
5050
/>
51-
)}
51+
}
5252
/>
5353
<NavBarSNCF appName="OSRD" logo={logo} />
5454
<Routes>
@@ -58,12 +58,12 @@ class HomeOSRD extends React.Component {
5858

5959
<Route
6060
path=""
61-
element={(
61+
element={
6262
<Navigate
6363
to={osrdsimulation.redirectToGraph ? '/osrd/simulation' : '/osrd/settings'}
6464
replace
6565
/>
66-
)}
66+
}
6767
/>
6868
</Routes>
6969
<NotificationsState />

front/src/applications/osrd/components/AddTrainSchedule/formatConf.js

+36-24
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,57 @@ export default function formatConf(dispatch, setFailure, t, osrdconf, originTime
22
let error = false;
33
if (!osrdconf.origin) {
44
error = true;
5-
dispatch(setFailure({
6-
name: t('osrdconf:errorMessages.trainScheduleTitle'),
7-
message: t('osrdconf:errorMessages.noOrigin'),
8-
}));
5+
dispatch(
6+
setFailure({
7+
name: t('osrdconf:errorMessages.trainScheduleTitle'),
8+
message: t('osrdconf:errorMessages.noOrigin'),
9+
})
10+
);
911
}
1012
if (!osrdconf.originTime) {
1113
error = true;
12-
dispatch(setFailure({
13-
name: t('osrdconf:errorMessages.trainScheduleTitle'),
14-
message: t('osrdconf:errorMessages.noOriginTime'),
15-
}));
14+
dispatch(
15+
setFailure({
16+
name: t('osrdconf:errorMessages.trainScheduleTitle'),
17+
message: t('osrdconf:errorMessages.noOriginTime'),
18+
})
19+
);
1620
}
1721
if (!osrdconf.destination) {
1822
error = true;
19-
dispatch(setFailure({
20-
name: t('osrdconf:errorMessages.trainScheduleTitle'),
21-
message: t('osrdconf:errorMessages.noDestination'),
22-
}));
23+
dispatch(
24+
setFailure({
25+
name: t('osrdconf:errorMessages.trainScheduleTitle'),
26+
message: t('osrdconf:errorMessages.noDestination'),
27+
})
28+
);
2329
}
2430
if (!osrdconf.rollingStockID) {
2531
error = true;
26-
dispatch(setFailure({
27-
name: t('osrdconf:errorMessages.trainScheduleTitle'),
28-
message: t('osrdconf:errorMessages.noRollingStock'),
29-
}));
32+
dispatch(
33+
setFailure({
34+
name: t('osrdconf:errorMessages.trainScheduleTitle'),
35+
message: t('osrdconf:errorMessages.noRollingStock'),
36+
})
37+
);
3038
}
3139
if (!osrdconf.name) {
3240
error = true;
33-
dispatch(setFailure({
34-
name: t('osrdconf:errorMessages.trainScheduleTitle'),
35-
message: t('osrdconf:errorMessages.noName'),
36-
}));
41+
dispatch(
42+
setFailure({
43+
name: t('osrdconf:errorMessages.trainScheduleTitle'),
44+
message: t('osrdconf:errorMessages.noName'),
45+
})
46+
);
3747
}
3848
if (!osrdconf.timetableID) {
3949
error = true;
40-
dispatch(setFailure({
41-
name: t('osrdconf:errorMessages.trainScheduleTitle'),
42-
message: t('osrdconf:errorMessages.noTimetable'),
43-
}));
50+
dispatch(
51+
setFailure({
52+
name: t('osrdconf:errorMessages.trainScheduleTitle'),
53+
message: t('osrdconf:errorMessages.noTimetable'),
54+
})
55+
);
4456
}
4557

4658
if (!error) {

0 commit comments

Comments
 (0)