From a0d1ef730b1bb6fd0bcf3b56da025a2ae6f8b893 Mon Sep 17 00:00:00 2001 From: Gabriel Bruno Date: Mon, 16 Dec 2024 14:25:26 -0500 Subject: [PATCH] The lint warnings from transition-common (other than "unexpected any") have been removed. 65 warnings got removed (143 to 78) --- .../evolutionaryAlgorithm/EvolutionaryAlgorithm.ts | 2 +- .../src/services/simulation/SimulationExecution.ts | 2 +- .../__tests__/SimulationAlgorithmDescriptorStub.ts | 2 +- packages/transition-common/jest.config.js | 2 ++ .../TransitAccessibilityMapResult.ts | 1 - .../TransitAccessibilityMapRouting.ts | 3 +-- .../transition-common/src/services/agency/Agency.ts | 3 +-- .../src/services/agency/AgencyCollection.ts | 2 -- .../src/services/agency/AgencyDuplicator.ts | 3 --- .../src/services/gtfs/GtfsExporter.ts | 3 --- .../transition-common/src/services/line/Line.ts | 3 ++- .../src/services/line/LineDuplicator.ts | 2 -- .../transition-common/src/services/nodes/Node.ts | 13 ++++++------- .../src/services/nodes/NodeCollection.ts | 7 +++---- .../src/services/nodes/NodeGeographyUtils.ts | 2 +- .../src/services/odTrip/BaseOdTripCollection.ts | 3 ++- .../transition-common/src/services/path/Path.ts | 8 ++++---- .../src/services/path/PathCollection.ts | 6 ------ .../src/services/path/PathGeographyUtils.ts | 2 +- .../transition-common/src/services/places/Place.ts | 2 +- .../src/services/schedules/Schedule.ts | 3 +-- .../src/services/schedules/ScheduleDuplicator.ts | 2 -- .../src/services/service/Service.ts | 1 - .../src/services/service/ServiceCollection.ts | 2 -- .../src/services/service/ServiceDuplicator.ts | 2 -- .../src/services/simulation/Simulation.ts | 7 ++----- .../src/services/simulation/SimulationAlgorithm.ts | 5 +++-- .../src/services/simulation/SimulationRun.ts | 1 - .../simulation/__tests__/SimulationAlgorithmStub.ts | 2 +- .../transitDemand/TransitOdDemandFromCsv.ts | 2 -- .../src/services/transitRouting/TransitRouting.ts | 1 - .../services/transitRouting/TransitRoutingResult.ts | 2 -- .../dataImport/importPlacesAndResidences.task.ts | 4 +--- .../dataImport/importResidentialData.ts | 2 +- 34 files changed, 36 insertions(+), 71 deletions(-) diff --git a/packages/transition-backend/src/services/evolutionaryAlgorithm/EvolutionaryAlgorithm.ts b/packages/transition-backend/src/services/evolutionaryAlgorithm/EvolutionaryAlgorithm.ts index 80f3b8636..489e504d0 100644 --- a/packages/transition-backend/src/services/evolutionaryAlgorithm/EvolutionaryAlgorithm.ts +++ b/packages/transition-backend/src/services/evolutionaryAlgorithm/EvolutionaryAlgorithm.ts @@ -33,7 +33,7 @@ export const evolutionaryAlgorithmFactory: SimulationAlgorithmFactory new EvolutionaryAlgorithm(options, simulationRun); -export class EvolutionaryAlgorithm implements SimulationAlgorithm { +export class EvolutionaryAlgorithm implements SimulationAlgorithm { private currentIteration = 1; constructor( diff --git a/packages/transition-backend/src/services/simulation/SimulationExecution.ts b/packages/transition-backend/src/services/simulation/SimulationExecution.ts index eca9200d1..321d3e8aa 100644 --- a/packages/transition-backend/src/services/simulation/SimulationExecution.ts +++ b/packages/transition-backend/src/services/simulation/SimulationExecution.ts @@ -25,7 +25,7 @@ import config from 'chaire-lib-backend/lib/config/server.config'; * @interface SimulationAlgorithm * @template T The type of options */ -export type SimulationAlgorithmFactory = (options: T, simulationRun: SimulationRun) => SimulationAlgorithm; +export type SimulationAlgorithmFactory = (options: T, simulationRun: SimulationRun) => SimulationAlgorithm; const ALGORITHMS_FACTORY: { [key: string]: SimulationAlgorithmFactory } = {}; export const registerAlgorithmFactory = (name: string, algorithmFactory: SimulationAlgorithmFactory): void => { diff --git a/packages/transition-backend/src/services/simulation/__tests__/SimulationAlgorithmDescriptorStub.ts b/packages/transition-backend/src/services/simulation/__tests__/SimulationAlgorithmDescriptorStub.ts index 2ae442c40..8edb95d8d 100644 --- a/packages/transition-backend/src/services/simulation/__tests__/SimulationAlgorithmDescriptorStub.ts +++ b/packages/transition-backend/src/services/simulation/__tests__/SimulationAlgorithmDescriptorStub.ts @@ -12,7 +12,7 @@ interface AlgorithmStubOptions { booleanOption?: boolean; } -export class SimulationAlgorithmStub implements SimulationAlgorithm { +export class SimulationAlgorithmStub implements SimulationAlgorithm { constructor(private options: AlgorithmStubOptions) { diff --git a/packages/transition-common/jest.config.js b/packages/transition-common/jest.config.js index 21ed8ceec..c7f4afee7 100644 --- a/packages/transition-common/jest.config.js +++ b/packages/transition-common/jest.config.js @@ -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 = { diff --git a/packages/transition-common/src/services/accessibilityMap/TransitAccessibilityMapResult.ts b/packages/transition-common/src/services/accessibilityMap/TransitAccessibilityMapResult.ts index a3f725cae..3e5cd40a9 100644 --- a/packages/transition-common/src/services/accessibilityMap/TransitAccessibilityMapResult.ts +++ b/packages/transition-common/src/services/accessibilityMap/TransitAccessibilityMapResult.ts @@ -15,7 +15,6 @@ import { PlaceDetailedCategory } from 'chaire-lib-common/lib/config/osm/osmMappingDetailedCategoryToCategory'; import NodeCollection from '../nodes/NodeCollection'; -import { placesInWalkingTravelTimeRadiusSeconds } from '../nodes/NodeGeographyUtils'; import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; export interface TransitAccessibilityMapResult { diff --git a/packages/transition-common/src/services/accessibilityMap/TransitAccessibilityMapRouting.ts b/packages/transition-common/src/services/accessibilityMap/TransitAccessibilityMapRouting.ts index 4cc5926e2..3bc519a77 100644 --- a/packages/transition-common/src/services/accessibilityMap/TransitAccessibilityMapRouting.ts +++ b/packages/transition-common/src/services/accessibilityMap/TransitAccessibilityMapRouting.ts @@ -4,7 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _get from 'lodash/get'; import _cloneDeep from 'lodash/cloneDeep'; import { featureCollection as turfFeatureCollection, point as turfPoint } from '@turf/turf'; @@ -13,7 +12,7 @@ import { GenericAttributes } from 'chaire-lib-common/lib/utils/objects/GenericOb import { ObjectWithHistory } from 'chaire-lib-common/lib/utils/objects/ObjectWithHistory'; import Preferences from 'chaire-lib-common/lib/config/Preferences'; import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator'; -import { _toInteger, _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; +import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; import { validateTrQueryAttributes } from '../transitRouting/TransitRoutingQueryAttributes'; import { TransitQueryAttributes } from 'chaire-lib-common/lib/services/routing/types'; diff --git a/packages/transition-common/src/services/agency/Agency.ts b/packages/transition-common/src/services/agency/Agency.ts index 5f21bb949..e6da33de4 100644 --- a/packages/transition-common/src/services/agency/Agency.ts +++ b/packages/transition-common/src/services/agency/Agency.ts @@ -4,7 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _cloneDeep from 'lodash/cloneDeep'; import { Agency as GtfsAgency } from 'gtfs-types'; import * as Status from 'chaire-lib-common/lib/utils/Status'; @@ -303,7 +302,7 @@ export class Agency extends ObjectWithHistory implements Savea const firstLine = this.getLines()[0]; const customCachePath = firstLine ? firstLine.getData('customCachePath', null) : undefined; - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { socket.emit('transitLine.deleteMultipleCache', lineIds, customCachePath, (linesCacheDeleteResponse) => { if (!linesCacheDeleteResponse.error) { SaveUtils.delete(this, socket, 'transitAgency', this._collectionManager?.get('agencies')).then( diff --git a/packages/transition-common/src/services/agency/AgencyCollection.ts b/packages/transition-common/src/services/agency/AgencyCollection.ts index 31d31f073..4731118f6 100644 --- a/packages/transition-common/src/services/agency/AgencyCollection.ts +++ b/packages/transition-common/src/services/agency/AgencyCollection.ts @@ -4,8 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _get from 'lodash/get'; - import Agency from './Agency'; import CollectionCacheable from 'chaire-lib-common/lib/services/objects/CollectionCacheable'; import CollectionManager from 'chaire-lib-common/lib/utils/objects/CollectionManager'; diff --git a/packages/transition-common/src/services/agency/AgencyDuplicator.ts b/packages/transition-common/src/services/agency/AgencyDuplicator.ts index 1c6ea638b..8974f1787 100644 --- a/packages/transition-common/src/services/agency/AgencyDuplicator.ts +++ b/packages/transition-common/src/services/agency/AgencyDuplicator.ts @@ -4,9 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _cloneDeep from 'lodash/cloneDeep'; -import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; - import { Agency, AgencyAttributes } from './Agency'; import { duplicateService } from '../service/ServiceDuplicator'; import { duplicateLine } from '../line/LineDuplicator'; diff --git a/packages/transition-common/src/services/gtfs/GtfsExporter.ts b/packages/transition-common/src/services/gtfs/GtfsExporter.ts index af69686a5..9c03b09bc 100644 --- a/packages/transition-common/src/services/gtfs/GtfsExporter.ts +++ b/packages/transition-common/src/services/gtfs/GtfsExporter.ts @@ -4,9 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _get from 'lodash/get'; -import _cloneDeep from 'lodash/cloneDeep'; - import { GenericAttributes } from 'chaire-lib-common/lib/utils/objects/GenericObject'; import { ObjectWithHistory } from 'chaire-lib-common/lib/utils/objects/ObjectWithHistory'; import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator'; diff --git a/packages/transition-common/src/services/line/Line.ts b/packages/transition-common/src/services/line/Line.ts index f0c47f88d..de4a7e0d9 100644 --- a/packages/transition-common/src/services/line/Line.ts +++ b/packages/transition-common/src/services/line/Line.ts @@ -166,7 +166,8 @@ export class Line extends ObjectWithHistory implements Saveable */ } - async calculateDeadHeadTravelTimesBetweenPaths(socket) { + //TODO: Add functionality to the _socket argument, or remove it. + async calculateDeadHeadTravelTimesBetweenPaths(_socket) { this.refreshPaths(); const completePaths = this.getCompletePaths(); const deadHeadTravelTimesBetweenPathsByPathId = {}; diff --git a/packages/transition-common/src/services/line/LineDuplicator.ts b/packages/transition-common/src/services/line/LineDuplicator.ts index 9e6baed69..17b027034 100644 --- a/packages/transition-common/src/services/line/LineDuplicator.ts +++ b/packages/transition-common/src/services/line/LineDuplicator.ts @@ -4,8 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; - import { Line } from './Line'; import { Path as TransitPath } from '../path/Path'; import { duplicateService } from '../service/ServiceDuplicator'; diff --git a/packages/transition-common/src/services/nodes/Node.ts b/packages/transition-common/src/services/nodes/Node.ts index 1e1131d6b..1cc75cd02 100644 --- a/packages/transition-common/src/services/nodes/Node.ts +++ b/packages/transition-common/src/services/nodes/Node.ts @@ -4,7 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _cloneDeep from 'lodash/cloneDeep'; import _get from 'lodash/get'; import _isEqual from 'lodash/isEqual'; import * as turf from '@turf/turf'; @@ -13,7 +12,6 @@ import * as GtfsTypes from 'gtfs-types'; import * as Status from 'chaire-lib-common/lib/utils/Status'; import { GenericPlace, GenericPlaceAttributes } from 'chaire-lib-common/lib/utils/objects/GenericPlace'; import Preferences from 'chaire-lib-common/lib/config/Preferences'; -import TrError from 'chaire-lib-common/lib/utils/TrError'; import SaveUtils from 'chaire-lib-common/lib/services/objects/SaveUtils'; import Saveable from 'chaire-lib-common/lib/utils/objects/Saveable'; import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; @@ -219,7 +217,8 @@ export class Node extends GenericPlace implements Saveable { return routingRadiusInPixels; } - calculateOdTripsWeight(dataSourceId) { + //TODO: Implement this function, or remove it. + calculateOdTripsWeight(_dataSourceId) { // Nothing to do. Why? } @@ -275,9 +274,9 @@ export class Node extends GenericPlace implements Saveable { } async getIsochroneGeojson( - socket, - mode = 'walking', - durationsMinutes = [5, 10, 15, 20] + _socket, + _mode = 'walking', + _durationsMinutes = [5, 10, 15, 20] ): Promise<{ [key: string]: any }> { return {}; /* TODO Disabled since valhalla is broken @@ -463,7 +462,7 @@ export class Node extends GenericPlace implements Saveable { } async delete(socket: EventEmitter): Promise> { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { SaveUtils.delete(this, socket, 'transitNode', this._collectionManager?.get('nodes')).then( (response: Status.Status<{ id: string | undefined }>) => { if ( diff --git a/packages/transition-common/src/services/nodes/NodeCollection.ts b/packages/transition-common/src/services/nodes/NodeCollection.ts index 6449580ce..3d15a5cc8 100644 --- a/packages/transition-common/src/services/nodes/NodeCollection.ts +++ b/packages/transition-common/src/services/nodes/NodeCollection.ts @@ -4,7 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _get from 'lodash/get'; import snakeCase from 'lodash/snakeCase'; import camelCase from 'lodash/camelCase'; @@ -67,7 +66,7 @@ export class NodeCollection extends GenericPlaceCollection } updateOdTripsWeights(socket, dataSourceId): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { socket.emit('nodes.calculateOdTripsWeights', dataSourceId, () => { resolve(); }); @@ -75,7 +74,7 @@ export class NodeCollection extends GenericPlaceCollection } updateOdTripsAccessibleNodes(socket, dataSourceId): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { socket.emit('odTrips.updateAccessibleNodes', dataSourceId, () => { resolve(); }); @@ -88,7 +87,7 @@ export class NodeCollection extends GenericPlaceCollection setNetworkTravelTimesForBirdDistanceAccessibleNodes(object, geojson, prefix, mode: RoutingMode = 'walking') { // geojson: origin or destination geojson - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { if (_isBlank(geojson) && typeof object.toGeojson === 'function') { geojson = object.toGeojson(); } diff --git a/packages/transition-common/src/services/nodes/NodeGeographyUtils.ts b/packages/transition-common/src/services/nodes/NodeGeographyUtils.ts index 7d1f5a97e..02ea9f111 100644 --- a/packages/transition-common/src/services/nodes/NodeGeographyUtils.ts +++ b/packages/transition-common/src/services/nodes/NodeGeographyUtils.ts @@ -187,7 +187,7 @@ export const proposeNames = async ( let radiusAroundMeters = 100; const nodeGeojson = node.toGeojson(); while (intersectionNames !== undefined && intersectionNames.length < 2 && radiusAroundMeters <= maxRadiusMeters) { - intersectionNames = await new Promise((resolve, reject) => { + intersectionNames = await new Promise((resolve, _reject) => { socket.emit( 'osm.streetsAroundPoint', nodeGeojson, diff --git a/packages/transition-common/src/services/odTrip/BaseOdTripCollection.ts b/packages/transition-common/src/services/odTrip/BaseOdTripCollection.ts index 9c4a129cb..27ef04e3a 100644 --- a/packages/transition-common/src/services/odTrip/BaseOdTripCollection.ts +++ b/packages/transition-common/src/services/odTrip/BaseOdTripCollection.ts @@ -57,7 +57,8 @@ class BaseOdTripCollection extends GenericObjectCollection implement }); } - newObject(attribs: Partial, isNew = false, collectionManager?: CollectionManager): BaseOdTrip { + //TODO: Add functionality to the _collectionManager argument, or remove it. + newObject(attribs: Partial, isNew = false, _collectionManager?: CollectionManager): BaseOdTrip { return new BaseOdTrip(attribs, isNew); } diff --git a/packages/transition-common/src/services/path/Path.ts b/packages/transition-common/src/services/path/Path.ts index 337bc57d2..43db26784 100644 --- a/packages/transition-common/src/services/path/Path.ts +++ b/packages/transition-common/src/services/path/Path.ts @@ -1364,7 +1364,7 @@ export class Path extends MapObject implemen } delete(socket): Promise> { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { const line: any = this.getLine(); SaveUtils.delete(this, socket, 'transitPath', this._collectionManager?.get('paths')).then( (response: Status.Status<{ id: string | undefined }>) => { @@ -1375,7 +1375,7 @@ export class Path extends MapObject implemen }); line.refreshPaths(); line.refreshStats(); - line.save(socket).then((lineSaveResponse) => { + line.save(socket).then((_lineSaveResponse) => { resolve(response); }); } else { @@ -1392,7 +1392,7 @@ export class Path extends MapObject implemen public async save(socket: EventEmitter) { if (this.hasChanged() || this.isNew()) { this.refreshStats(); - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { const line: any = this.getLine(); this.attributes.mode = this.getMode(); // force add mode since it could have been removed when updating SaveUtils.save(this, socket, 'transitPath', this._collectionManager?.get('paths')).then( @@ -1409,7 +1409,7 @@ export class Path extends MapObject implemen // TODO Use an update callback line.refreshPaths(); line.refreshStats(); - line.save(socket).then((lineSaveResponse) => { + line.save(socket).then((_lineSaveResponse) => { resolve(response); }); } else { diff --git a/packages/transition-common/src/services/path/PathCollection.ts b/packages/transition-common/src/services/path/PathCollection.ts index 69f5ba069..b77bd2909 100644 --- a/packages/transition-common/src/services/path/PathCollection.ts +++ b/packages/transition-common/src/services/path/PathCollection.ts @@ -4,18 +4,12 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _get from 'lodash/get'; -import geobuf from 'geobuf'; -import Pbf from 'pbf'; - import { Path, PathAttributes } from './Path'; import CollectionCacheable from 'chaire-lib-common/lib/services/objects/CollectionCacheable'; import CollectionLoadable from 'chaire-lib-common/lib/services/objects/CollectionLoadable'; import GenericMapObjectCollection from 'chaire-lib-common/lib/utils/objects/GenericMapObjectCollection'; import Progressable from 'chaire-lib-common/lib/utils/objects/Progressable'; import { EventManager } from 'chaire-lib-common/lib/services/events/EventManager'; -import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; -import TrError from 'chaire-lib-common/lib/utils/TrError'; /** * A collection of transit paths diff --git a/packages/transition-common/src/services/path/PathGeographyUtils.ts b/packages/transition-common/src/services/path/PathGeographyUtils.ts index 8a6e200d5..b1b04df9b 100644 --- a/packages/transition-common/src/services/path/PathGeographyUtils.ts +++ b/packages/transition-common/src/services/path/PathGeographyUtils.ts @@ -161,7 +161,7 @@ class PathGeographyUtils { let routingSegmentGeojson: FeatureCollection = this.initializePointGeojsonCollection(); let lastRoutingType = routingEngine; - nodesAndWaypointsGeojsons.features.forEach((geojson, geojsonIndex) => { + nodesAndWaypointsGeojsons.features.forEach((geojson, _geojsonIndex) => { const nodeRoutingType = routingEngine === 'manual' ? 'manual' : geojson.properties?.type || lastRoutingType; if (nodeRoutingType !== lastRoutingType && routingSegmentGeojson.features.length > 0) { diff --git a/packages/transition-common/src/services/places/Place.ts b/packages/transition-common/src/services/places/Place.ts index 41b799ef3..86d152e60 100644 --- a/packages/transition-common/src/services/places/Place.ts +++ b/packages/transition-common/src/services/places/Place.ts @@ -56,7 +56,7 @@ export class Place extends GenericPlace implements Saveable { } async delete(socket: EventEmitter): Promise> { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { SaveUtils.delete(this, socket, 'Place', this._collectionManager?.get('places')).then( (response: Status.Status<{ id: string | undefined }>) => { if ( diff --git a/packages/transition-common/src/services/schedules/Schedule.ts b/packages/transition-common/src/services/schedules/Schedule.ts index 760ca97de..883867e93 100644 --- a/packages/transition-common/src/services/schedules/Schedule.ts +++ b/packages/transition-common/src/services/schedules/Schedule.ts @@ -138,7 +138,6 @@ class Schedule extends ObjectWithHistory implements Saveable // todo const period = this.getPeriod(periodShortname); if (period) { - const minInterval = Infinity; const trips = period.trips; if (trips && trips.length > 0) { for (let i = 0, count = trips.length; i < count - 1; i++) { @@ -366,7 +365,7 @@ class Schedule extends ObjectWithHistory implements Saveable unitReadyAt: unit.isReadyAtTimeSeconds }; return trip; - } catch (error) { + } catch { throw `The path ${path.getId()} for line ${path.getLine()?.getAttributes().shortname} (${ path.attributes.line_id }) is not valid. Please recalculate routing for this path`; diff --git a/packages/transition-common/src/services/schedules/ScheduleDuplicator.ts b/packages/transition-common/src/services/schedules/ScheduleDuplicator.ts index c9638820b..37e4e6e74 100644 --- a/packages/transition-common/src/services/schedules/ScheduleDuplicator.ts +++ b/packages/transition-common/src/services/schedules/ScheduleDuplicator.ts @@ -4,9 +4,7 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _cloneDeep from 'lodash/cloneDeep'; import { v4 as uuidV4 } from 'uuid'; -import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; import Schedule from './Schedule'; diff --git a/packages/transition-common/src/services/service/Service.ts b/packages/transition-common/src/services/service/Service.ts index 6a42fba9b..fdf37ba45 100644 --- a/packages/transition-common/src/services/service/Service.ts +++ b/packages/transition-common/src/services/service/Service.ts @@ -15,7 +15,6 @@ import SaveUtils from 'chaire-lib-common/lib/services/objects/SaveUtils'; import Saveable from 'chaire-lib-common/lib/utils/objects/Saveable'; import { GenericAttributes } from 'chaire-lib-common/lib/utils/objects/GenericObject'; import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator'; -import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; import Line from '../line/Line'; export const serviceDays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; diff --git a/packages/transition-common/src/services/service/ServiceCollection.ts b/packages/transition-common/src/services/service/ServiceCollection.ts index be02825db..8b8c25473 100644 --- a/packages/transition-common/src/services/service/ServiceCollection.ts +++ b/packages/transition-common/src/services/service/ServiceCollection.ts @@ -4,8 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _get from 'lodash/get'; - import Service from './Service'; import CollectionCacheable from 'chaire-lib-common/lib/services/objects/CollectionCacheable'; import CollectionManager from 'chaire-lib-common/lib/utils/objects/CollectionManager'; diff --git a/packages/transition-common/src/services/service/ServiceDuplicator.ts b/packages/transition-common/src/services/service/ServiceDuplicator.ts index 12d4174b9..b6e510a5e 100644 --- a/packages/transition-common/src/services/service/ServiceDuplicator.ts +++ b/packages/transition-common/src/services/service/ServiceDuplicator.ts @@ -4,8 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _cloneDeep from 'lodash/cloneDeep'; - import Service from './Service'; import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; import ServiceCollection from './ServiceCollection'; diff --git a/packages/transition-common/src/services/simulation/Simulation.ts b/packages/transition-common/src/services/simulation/Simulation.ts index f20b9c602..c056b6d8a 100644 --- a/packages/transition-common/src/services/simulation/Simulation.ts +++ b/packages/transition-common/src/services/simulation/Simulation.ts @@ -12,7 +12,6 @@ import CollectionManager from 'chaire-lib-common/lib/utils/objects/CollectionMan import { ObjectWithHistory } from 'chaire-lib-common/lib/utils/objects/ObjectWithHistory'; import SaveUtils from 'chaire-lib-common/lib/services/objects/SaveUtils'; import Saveable from 'chaire-lib-common/lib/utils/objects/Saveable'; -import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; import { GenericAttributes } from 'chaire-lib-common/lib/utils/objects/GenericObject'; import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator'; import { validateTrBaseAttributes } from '../transitRouting/TransitRoutingQueryAttributes'; @@ -172,12 +171,10 @@ class Simulation extends ObjectWithHistory implements Save if (shortname) { return slugify(`${shortname}${showId ? '_' + this.id : ''}`, { replacement: '_', - remove: /[/^*=;:#$%?&\|\[\]{}\+~.\(\)'"!\\@]/g + remove: /[/^*=;:#$%?&|[\]{}+~.()'"!\\@]/g }); // regex for valid filenames } - return showId - ? slugify(this.id, { replacement: '_', remove: /[/^*=;:#$%?&\|\[\]{}\+~.\(\)'"!\\@]/g }) - : undefined; // regex for valid filenames + return showId ? slugify(this.id, { replacement: '_', remove: /[/^*=;:#$%?&|[\]{}+~.()'"!\\@]/g }) : undefined; // regex for valid filenames } getAlgorithmDescriptor(): SimulationAlgorithmDescriptor | undefined { diff --git a/packages/transition-common/src/services/simulation/SimulationAlgorithm.ts b/packages/transition-common/src/services/simulation/SimulationAlgorithm.ts index c55e1bdf0..3a287a258 100644 --- a/packages/transition-common/src/services/simulation/SimulationAlgorithm.ts +++ b/packages/transition-common/src/services/simulation/SimulationAlgorithm.ts @@ -14,9 +14,10 @@ import ServiceCollection from '../service/ServiceCollection'; * * @export * @interface SimulationAlgorithm - * @template T The type of options */ -export interface SimulationAlgorithm { +// This interface used to have a type variable that was documented as "The type of options". +// This was completely unused so it was removed, but a comment is left here in case we ever want to implement it again. +export interface SimulationAlgorithm { run: ( socket: EventEmitter, collections: { lines: LineCollection; agencies: AgencyCollection; services: ServiceCollection } diff --git a/packages/transition-common/src/services/simulation/SimulationRun.ts b/packages/transition-common/src/services/simulation/SimulationRun.ts index c87e45813..b6d410c62 100644 --- a/packages/transition-common/src/services/simulation/SimulationRun.ts +++ b/packages/transition-common/src/services/simulation/SimulationRun.ts @@ -10,7 +10,6 @@ import { EventEmitter } from 'events'; import SaveUtils from 'chaire-lib-common/lib/services/objects/SaveUtils'; import Saveable from 'chaire-lib-common/lib/utils/objects/Saveable'; -import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; import { GenericAttributes, GenericObject } from 'chaire-lib-common/lib/utils/objects/GenericObject'; import { AlgorithmConfiguration } from './Simulation'; import { SimulationParameters } from './SimulationParameters'; diff --git a/packages/transition-common/src/services/simulation/__tests__/SimulationAlgorithmStub.ts b/packages/transition-common/src/services/simulation/__tests__/SimulationAlgorithmStub.ts index 34a5c430c..80f9970ea 100644 --- a/packages/transition-common/src/services/simulation/__tests__/SimulationAlgorithmStub.ts +++ b/packages/transition-common/src/services/simulation/__tests__/SimulationAlgorithmStub.ts @@ -12,7 +12,7 @@ interface AlgorithmStubOptions { booleanOption?: boolean; } -export class SimulationAlgorithmStub implements SimulationAlgorithm { +export class SimulationAlgorithmStub implements SimulationAlgorithm { constructor(private options: AlgorithmStubOptions) { diff --git a/packages/transition-common/src/services/transitDemand/TransitOdDemandFromCsv.ts b/packages/transition-common/src/services/transitDemand/TransitOdDemandFromCsv.ts index 0d8abfb84..fa9b50ea5 100644 --- a/packages/transition-common/src/services/transitDemand/TransitOdDemandFromCsv.ts +++ b/packages/transition-common/src/services/transitDemand/TransitOdDemandFromCsv.ts @@ -4,8 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _cloneDeep from 'lodash/cloneDeep'; - import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator'; import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; import DataSourceCollection from 'chaire-lib-common/lib/services/dataSource/DataSourceCollection'; diff --git a/packages/transition-common/src/services/transitRouting/TransitRouting.ts b/packages/transition-common/src/services/transitRouting/TransitRouting.ts index 5a2ed6f73..eeafaa299 100644 --- a/packages/transition-common/src/services/transitRouting/TransitRouting.ts +++ b/packages/transition-common/src/services/transitRouting/TransitRouting.ts @@ -4,7 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _get from 'lodash/get'; import _cloneDeep from 'lodash/cloneDeep'; import GeoJSON from 'geojson'; diff --git a/packages/transition-common/src/services/transitRouting/TransitRoutingResult.ts b/packages/transition-common/src/services/transitRouting/TransitRoutingResult.ts index 48ed0c2f0..d3c356159 100644 --- a/packages/transition-common/src/services/transitRouting/TransitRoutingResult.ts +++ b/packages/transition-common/src/services/transitRouting/TransitRoutingResult.ts @@ -4,8 +4,6 @@ * This file is licensed under the MIT License. * License text available at https://opensource.org/licenses/MIT */ -import _get from 'lodash/get'; - import { TrRoutingV2 } from 'chaire-lib-common/lib/api/TrRouting'; import PathCollection from '../path/PathCollection'; import { SegmentToGeoJSON, StepGeojsonProperties } from 'chaire-lib-common/lib/services/routing/TransitRoutingResult'; diff --git a/packages/transition-common/src/tasks/populationSynthesis/dataImport/importPlacesAndResidences.task.ts b/packages/transition-common/src/tasks/populationSynthesis/dataImport/importPlacesAndResidences.task.ts index 6eaccdbfc..c9c463b5f 100644 --- a/packages/transition-common/src/tasks/populationSynthesis/dataImport/importPlacesAndResidences.task.ts +++ b/packages/transition-common/src/tasks/populationSynthesis/dataImport/importPlacesAndResidences.task.ts @@ -5,7 +5,6 @@ * License text available at https://opensource.org/licenses/MIT */ /** This file is probably deprecated. It was written initially, but was later replaced by the files in chaire-lib-common/lib/tasks/dataImport */ -import { validate as uuidValidate, v4 as uuidV4 } from 'uuid'; import inquirer from 'inquirer'; import inquirerFileTreeSelection from 'inquirer-file-tree-selection-prompt'; @@ -31,7 +30,7 @@ async function getOsmData(preAnswers, fileManager) { console.error('Invalid geojson polygon to fetch osm data in file', preAnswers.polygonGeojson); return { osmRawData, osmGeojsonData }; } - } catch (error) { + } catch { console.error( 'Error reading geojson polygon file. Verify that the file contains a geojson Polygon or a feature collection with the first feature as a polygon', preAnswers.polygonGeojson @@ -53,7 +52,6 @@ async function getOsmData(preAnswers, fileManager) { } async function run(fileManager: any) { - const dataSources = []; //serviceLocator.collectionManager.get('dataSources').getFeatures(); console.log('running'); //choose data source shortname and name: diff --git a/packages/transition-common/src/tasks/populationSynthesis/dataImport/importResidentialData.ts b/packages/transition-common/src/tasks/populationSynthesis/dataImport/importResidentialData.ts index a3dfff28f..0abb9751d 100644 --- a/packages/transition-common/src/tasks/populationSynthesis/dataImport/importResidentialData.ts +++ b/packages/transition-common/src/tasks/populationSynthesis/dataImport/importResidentialData.ts @@ -329,7 +329,7 @@ export class ResidentialDataImporter { residentialBuildingsGeojson = overlappingBuildings.notOverlapping; // First create homes from the OSM residential buildings, removing their corresponding entry in the land role - const { residences, remainingLandRole, mismatchCount } = await this.createHomesFromOsmBuildings( + const { residences, remainingLandRole } = await this.createHomesFromOsmBuildings( dataSourceName, overlappingBuildings.overlapping, landRoleSplit.overlapping