Skip to content

Commit

Permalink
The lint warnings from transition-frontend (other than "unexpected an…
Browse files Browse the repository at this point in the history
…y") have been removed.

112 warnings got removed (223 to 111).
  • Loading branch information
GabrielBruno24 committed Dec 19, 2024
1 parent 7fab3e2 commit 727075c
Show file tree
Hide file tree
Showing 56 changed files with 100 additions and 144 deletions.
2 changes: 2 additions & 0 deletions packages/transition-frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* License text available at https://opensource.org/licenses/MIT
*/
/* eslint-disable n/no-unpublished-require */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-require-imports */
const baseConfig = require('../../tests/jest.config.base');

module.exports = {
Expand Down
3 changes: 1 addition & 2 deletions packages/transition-frontend/src/app-transition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import React from 'react';
import { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';
import { I18nextProvider } from 'react-i18next';
import { BrowserRouter, Router } from 'react-router';
import { BrowserRouter } from 'react-router';

import i18n from 'chaire-lib-frontend/lib/config/i18n.config';
import TransitionRouter from './components/routers/TransitionRouter';
import MainMap from './components/map/TransitionMainMap';
import configureStore from 'chaire-lib-frontend/lib/store/configureStore';
import { login, logout } from 'chaire-lib-frontend/lib/actions/Auth';
import { LoadingPage } from 'chaire-lib-frontend/lib/components/pages';
import config from 'chaire-lib-frontend/lib/config/project.config';
import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator';
import Path from 'transition-common/lib/services/path/Path';
import { LayoutSectionProps } from 'chaire-lib-frontend/lib/services/dashboard/DashboardContribution';

const BottomPanel: React.FunctionComponent<LayoutSectionProps> = (props: LayoutSectionProps) => {
const BottomPanel: React.FunctionComponent<LayoutSectionProps> = (_props: LayoutSectionProps) => {
const [path, setPath] = React.useState<{ path: Path | undefined }>({
path: serviceLocator.selectedObjectsManager.get('path')
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class Dashboard extends React.Component<DashboardProps, DashboardState> {
}
};

onPreferencesChange = (updates: any) => {
onPreferencesChange = (_updates: any) => {
const infoPanelPosition = Preferences.get('infoPanelPosition');
this.setState({ infoPanelPosition });
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ interface TransitionFSPanelState {
selectedSchedule?: Schedule;
}

const FullSizePanel: React.FunctionComponent<LayoutSectionProps> = (props: LayoutSectionProps) => {
const FullSizePanel: React.FunctionComponent<LayoutSectionProps> = (_props: LayoutSectionProps) => {
const [state, setState] = React.useState<TransitionFSPanelState>({
selectedLine: serviceLocator.selectedObjectsManager.get('line'),
selectedSchedule: serviceLocator.selectedObjectsManager.get('schedule')
});

React.useEffect(() => {
const onSelectedLineUpdate = () =>
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
setState(({ selectedLine, ...rest }) => ({
...rest,
selectedLine: serviceLocator.selectedObjectsManager.get('line')
}));
const onSelectedScheduleUpdate = () =>
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
setState(({ selectedSchedule, ...rest }) => ({
...rest,
selectedSchedule: serviceLocator.selectedObjectsManager.get('schedule')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Toolbar extends React.Component<LayoutSectionProps & WithTranslation, Tran
serviceLocator.layerManager._enabledLayers.forEach((layerName) => {
layersVisibility[layerName] = serviceLocator.layerManager.layerIsVisible(layerName);
});
this.setState((oldState) => {
this.setState((_oldState) => {
return {
layersVisibility
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import { withTranslation, WithTranslation } from 'react-i18next';
import Loader from 'react-spinners/BeatLoader';

import { faUpload } from '@fortawesome/free-solid-svg-icons/faUpload';
import _get from 'lodash/get';
import _cloneDeep from 'lodash/cloneDeep';
import _toString from 'lodash/toString';
import { parseCsvFile } from 'chaire-lib-common/lib/utils/files/CsvFile';
import slugify from 'slugify';

import InputString from 'chaire-lib-frontend/lib/components/input/InputString';
import InputWrapper from 'chaire-lib-frontend/lib/components/input/InputWrapper';
Expand Down Expand Up @@ -132,7 +129,7 @@ class AccessibilityMapBatchForm extends ChangeEventsForm<
// ** File upload

// upload csv file to server:
const uploadIds = this.props.fileUploader.upload(this.props.fileImportRef.current, {
this.props.fileUploader.upload(this.props.fileImportRef.current, {
uploadTo: 'imports',
data: {
objects: 'csv',
Expand All @@ -142,7 +139,7 @@ class AccessibilityMapBatchForm extends ChangeEventsForm<

this.state.object.updateRoutingPrefs();

this.setState((oldState) => {
this.setState((_oldState) => {
return {
csvUploadedToServer: true
};
Expand Down Expand Up @@ -203,8 +200,6 @@ class AccessibilityMapBatchForm extends ChangeEventsForm<
!_isBlank(accessMapRouting.attributes.timeFormat) &&
!_isBlank(accessMapRouting.attributes.timeAttributeDepartureOrArrival);

const slugifiedCalculationName = slugify(accessMapRouting.attributes.calculationName || '');

const errors = this.state.errors;
const warnings = this.state.warnings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator';
import DownloadsUtils from 'chaire-lib-frontend/lib/services/DownloadsService';
import { ChangeEventsForm, ChangeEventsState } from 'chaire-lib-frontend/lib/components/forms/ChangeEventsForm';
import LoadingPage from 'chaire-lib-frontend/lib/components/pages/LoadingPage';
import { _toInteger, _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions';
import { _toInteger } from 'chaire-lib-common/lib/utils/LodashExtensions';
import {
secondsSinceMidnightToTimeStr,
secondsToMinutes,
Expand Down Expand Up @@ -135,7 +135,7 @@ class AccessibilityMapForm extends ChangeEventsForm<AccessibilityMapFormProps, T
return;
}
this.polygonCalculated(currentResult);
} catch (error) {
} catch {
this.setState({
routingErrors: ['main:errors:ErrorCalculatingAccessibilityMap']
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import React, { JSX } from 'react';
import { withTranslation, WithTranslation } from 'react-i18next';

import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions';
export interface AccessibilityMapStatsComponentProps extends WithTranslation {
accessibilityPolygons: GeoJSON.FeatureCollection;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import React from 'react';
import { withTranslation, WithTranslation } from 'react-i18next';
import MathJax from 'react-mathjax';
import _get from 'lodash/get';
import { faPlus } from '@fortawesome/free-solid-svg-icons/faPlus';

import Button from 'chaire-lib-frontend/lib/components/input/Button';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Collapsible from 'react-collapsible';
import { faFileUpload } from '@fortawesome/free-solid-svg-icons/faFileUpload';

import Button from 'chaire-lib-frontend/lib/components/input/Button';
import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions';
import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator';
import CollectionDownloadButtons from 'chaire-lib-frontend/lib/components/pageParts/CollectionDownloadButtons';
import CollectionSaveToCacheButtons from '../../parts/CollectionSaveToCacheButtons';
Expand Down Expand Up @@ -64,36 +63,43 @@ const AgencyPanel: React.FunctionComponent<AgencyPanelProps> = (props: AgencyPan

React.useEffect(() => {
const onAgencyCollectionUpdate = () =>
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
setState(({ agencyCollection, ...rest }) => ({
...rest,
agencyCollection: serviceLocator.collectionManager.get('agencies')
}));
const onSelectedAgencyUpdate = () =>
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
setState(({ selectedAgency, ...rest }) => ({
...rest,
selectedAgency: serviceLocator.selectedObjectsManager.get('agency')
}));
const onLineCollectionUpdate = () =>
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
setState(({ lineCollection, ...rest }) => ({
...rest,
lineCollection: serviceLocator.collectionManager.get('lines')
}));
const onSelectedLineUpdate = () =>
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
setState(({ selectedLine, ...rest }) => ({
...rest,
selectedLine: serviceLocator.selectedObjectsManager.get('line')
}));
const onPathCollectionUpdate = () =>
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
setState(({ pathCollection, ...rest }) => ({
...rest,
pathCollection: serviceLocator.collectionManager.get('paths')
}));
const onSelectedPathUpdate = () =>
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
setState(({ selectedPath, ...rest }) => ({
...rest,
selectedPath: serviceLocator.selectedObjectsManager.get('path')
}));
const onSelectedScheduleUpdate = () =>
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
setState(({ selectedSchedule, ...rest }) => ({
...rest,
selectedSchedule: serviceLocator.selectedObjectsManager.get('schedule')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
import React from 'react';
import { withTranslation, WithTranslation } from 'react-i18next';
import _get from 'lodash/get';
import { faPlus } from '@fortawesome/free-solid-svg-icons/faPlus';
import { faRedoAlt } from '@fortawesome/free-solid-svg-icons/faRedoAlt';
import Button from 'chaire-lib-frontend/lib/components/input/Button';
Expand Down Expand Up @@ -56,7 +55,7 @@ const BatchCalculationList: React.FunctionComponent<BatchCalculationListProps> =
icon={faPlus}
iconClass="_icon"
label={props.t('transit:batchCalculation:New')}
onClick={(e) => props.onNewAnalysis()}
onClick={() => props.onNewAnalysis()}
/>
</div>
{errors.length > 0 && <FormErrors errors={errors} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import React from 'react';

import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator';
import BatchCalculationList from './BatchCalculationList';
import ScenarioCollection from 'transition-common/lib/services/scenario/ScenarioCollection';
import BatchCalculationForm from './BatchCalculationForm';
import { BatchCalculationParameters } from 'transition-common/lib/services/batchCalculation/types';
import { TransitBatchRoutingDemandAttributes } from 'transition-common/lib/services/transitDemand/types';
Expand All @@ -18,9 +17,11 @@ export interface CalculationPanelPanelProps {
}

const CalculationPanel: React.FunctionComponent<CalculationPanelPanelProps> = (props: CalculationPanelPanelProps) => {
const [scenarioCollection, setScenarioCollection] = React.useState<ScenarioCollection | undefined>(
serviceLocator.collectionManager.get('scenarios')
);
// TODO: scenarioCollection is never read. Implement a use for it, or remove the hook and onScenarioCollectionUpdate() entirely.
// const [scenarioCollection, setScenarioCollection] = React.useState<ScenarioCollection | undefined>(
// serviceLocator.collectionManager.get('scenarios')
// );

const [isNewAnalysis, setIsNewAnalysis] = React.useState(false);
const [initialValues, setInitialValues] = React.useState<
| {
Expand All @@ -32,7 +33,7 @@ const CalculationPanel: React.FunctionComponent<CalculationPanelPanelProps> = (p
>(undefined);

const onScenarioCollectionUpdate = () => {
setScenarioCollection(serviceLocator.collectionManager.get('scenarios'));
//setScenarioCollection(serviceLocator.collectionManager.get('scenarios'));
};

const onNewAnalysis = (parameters?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* This file is licensed under the MIT License.
* License text available at https://opensource.org/licenses/MIT
*/
import React, { JSX } from 'react';
import React from 'react';
import { faFileDownload } from '@fortawesome/free-solid-svg-icons/faFileDownload';
import { faTasks } from '@fortawesome/free-solid-svg-icons/faTasks';
import _get from 'lodash/get';
import { withTranslation, WithTranslation } from 'react-i18next';
import slugify from 'slugify';
import { v4 as uuidV4 } from 'uuid';
Expand All @@ -19,7 +18,6 @@ import FormErrors from 'chaire-lib-frontend/lib/components/pageParts/FormErrors'
import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator';
import GtfsExporter from 'transition-common/lib/services/gtfs/GtfsExporter';
import { ChangeEventsForm, ChangeEventsState } from 'chaire-lib-frontend/lib/components/forms/ChangeEventsForm';
import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions';
import { GtfsConstants, GtfsExportStatus } from 'transition-common/lib/api/gtfs';

class GtfsExportForm extends ChangeEventsForm<WithTranslation, ChangeEventsState<GtfsExporter>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* License text available at https://opensource.org/licenses/MIT
*/
import React from 'react';
import { withTranslation, WithTranslation } from 'react-i18next';

import { AgencyImportData } from 'transition-common/lib/services/gtfs/GtfsImportTypes';
import { InputCheckbox } from 'chaire-lib-frontend/lib/components/input/InputCheckbox';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import React from 'react';
import { faUpload } from '@fortawesome/free-solid-svg-icons/faUpload';
import { faFileImport } from '@fortawesome/free-solid-svg-icons/faFileImport';
import _get from 'lodash/get';
import Loader from 'react-spinners/BeatLoader';
import SocketIOFileClient from 'socket.io-file-client';
import { withTranslation, WithTranslation } from 'react-i18next';
Expand Down Expand Up @@ -248,8 +247,9 @@ class GtfsImportForm extends React.Component<GtfsImportProps, GtfsImportState> {
}
};

importGtfsData = (e) => {
importGtfsData = (_e) => {
const validator = this.state.validator;
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
const { periodsGroupShortname, ...rest } = this.state.availableImportData;
// import
if (this.state.operationInProgress) {
Expand Down Expand Up @@ -336,7 +336,7 @@ class GtfsImportForm extends React.Component<GtfsImportProps, GtfsImportState> {
id={`formFieldTransitGtfsImporterFile${validatorId}`}
accept=".zip"
inputRef={this._fileImportRef}
onChange={(e) => {
onChange={() => {
this.setState({
validator: new GtfsValidator({}),
uploadError: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import React from 'react';
import { withTranslation, WithTranslation } from 'react-i18next';
import Collapsible from 'react-collapsible';
import { faPlus } from '@fortawesome/free-solid-svg-icons/faPlus';
import _get from 'lodash/get';

import InputString from 'chaire-lib-frontend/lib/components/input/InputString';
import InputText from 'chaire-lib-frontend/lib/components/input/InputText';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import InputColor from 'chaire-lib-frontend/lib/components/input/InputColor';
import InputWrapper from 'chaire-lib-frontend/lib/components/input/InputWrapper';
import { InputCheckboxBoolean } from 'chaire-lib-frontend/lib/components/input/InputCheckbox';
import Button from 'chaire-lib-frontend/lib/components/input/Button';
import { _isBlank, _toInteger } from 'chaire-lib-common/lib/utils/LodashExtensions';
import { _toInteger } from 'chaire-lib-common/lib/utils/LodashExtensions';
import FormErrors from 'chaire-lib-frontend/lib/components/pageParts/FormErrors';
import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator';
import ConfirmModal from 'chaire-lib-frontend/lib/components/modal/ConfirmModal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { withTranslation, WithTranslation } from 'react-i18next';
import _cloneDeep from 'lodash/cloneDeep';
import _toString from 'lodash/toString';
import { featureCollection as turfFeatureCollection } from '@turf/turf';
import _uniq from 'lodash/uniq';

import InputString from 'chaire-lib-frontend/lib/components/input/InputString';
import InputText from 'chaire-lib-frontend/lib/components/input/InputText';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { faFileUpload } from '@fortawesome/free-solid-svg-icons/faFileUpload';
import { faCheck } from '@fortawesome/free-solid-svg-icons/faCheck';

import Button from 'chaire-lib-frontend/lib/components/input/Button';
import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions';
import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator';
import CollectionDownloadButtons from 'chaire-lib-frontend/lib/components/pageParts/CollectionDownloadButtons';
import ConfirmModal from 'chaire-lib-frontend/lib/components/modal/ConfirmModal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@ import React from 'react';
import _uniq from 'lodash/uniq';
import { withTranslation, WithTranslation } from 'react-i18next';

import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions';
import { roundToDecimals } from 'chaire-lib-common/lib/utils/MathUtils';
import Node from 'transition-common/lib/services/nodes/Node';
import Line from 'transition-common/lib/services/line/Line';
import Path from 'transition-common/lib/services/path/Path';
import PathCollection from 'transition-common/lib/services/path/PathCollection';
import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator';

const SimpleRow: React.FunctionComponent<{ header: string; value?: string | number; isHeader?: boolean }> = ({
header,
value = '',
isHeader = false
}) => {
return (
<tr>
<th className={isHeader ? '_header' : ''}>{header}</th>
<td>{value}</td>
</tr>
);
};
// This component is currently unused.
// const SimpleRow: React.FunctionComponent<{ header: string; value?: string | number; isHeader?: boolean }> = ({
// header,
// value = '',
// isHeader = false
// }) => {
// return (
// <tr>
// <th className={isHeader ? '_header' : ''}>{header}</th>
// <td>{value}</td>
// </tr>
// );
// };

const SingleColumn: React.FunctionComponent<{ header: string; values?: string[] | number[]; isHeader?: boolean }> = ({
header,
Expand Down
Loading

0 comments on commit 727075c

Please sign in to comment.