Skip to content

Commit

Permalink
The lint warnings from chaire-lib-common (other than "unexpected any"…
Browse files Browse the repository at this point in the history
…) have been removed.

311 warnings got removed (476 to 165).
  • Loading branch information
GabrielBruno24 authored and tahini committed Dec 17, 2024
1 parent 3108593 commit 55783a8
Show file tree
Hide file tree
Showing 18 changed files with 211 additions and 207 deletions.
2 changes: 2 additions & 0 deletions packages/chaire-lib-common/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
2 changes: 2 additions & 0 deletions packages/chaire-lib-common/src/api/TrRouting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* This file is licensed under the MIT License.
* License text available at https://opensource.org/licenses/MIT
*/
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
import * as TrRoutingTypes from './base';
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
import * as TrRoutingV2 from './trRoutingApiV2';

export * from './base';
Expand Down
8 changes: 4 additions & 4 deletions packages/chaire-lib-common/src/config/Preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class PreferencesClass extends ObjectWithHistory<PreferencesModelWithIdAn
}
}
this._eventEmitter.emit(prefChangeEvent, _valuesByPath);
} catch (error) {
} catch {
console.error('Error loading preferences from server');
}
return this._attributes;
Expand All @@ -237,14 +237,14 @@ export class PreferencesClass extends ObjectWithHistory<PreferencesModelWithIdAn
}
eventManager?.emit('preferences.updated');
this._eventEmitter.emit(prefChangeEvent, this._attributes);
} catch (error) {
} catch {
console.error('Error loading preferences from server');
}
return this._attributes;
}

// Not implemented for Preferences, we should never delete the preferences object.
public delete(socket: any): Promise<any> {
public delete(_socket: any): Promise<any> {

Check warning on line 247 in packages/chaire-lib-common/src/config/Preferences.ts

View workflow job for this annotation

GitHub Actions / code-lint

Unexpected any. Specify a different type

Check warning on line 247 in packages/chaire-lib-common/src/config/Preferences.ts

View workflow job for this annotation

GitHub Actions / code-lint

Unexpected any. Specify a different type
return new Promise((resolve) => {
resolve(null);
});
Expand Down Expand Up @@ -314,7 +314,7 @@ export class PreferencesClass extends ObjectWithHistory<PreferencesModelWithIdAn
_merge({}, this._default, this._projectDefault, preferencesFromServer)
) as PreferencesModelWithIdAndData;
this._eventEmitter.emit(prefChangeEvent, this._attributes);
} catch (error) {
} catch {
console.error('Error loading preferences from server');
}
return this._attributes;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { ObjectWithHistory } from '../../utils/objects/ObjectWithHistory';
import { GenericAttributes } from '../../utils/objects/GenericObject';
import serviceLocator from '../../utils/ServiceLocator';
import { _isBlank } from '../../utils/LodashExtensions';

export const dataSourceTypesArray = [
'none',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const getOverlappingIndices = (
) {
overlappingIndices.push(index);
}
} catch (e) {
} catch {
// Unsupported geometry in overlap or within, just ignore instead of checking all types
}
} else if (comparisonMethod(toCompare.geometry, feature.geometry)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* This file is licensed under the MIT License.
* License text available at https://opensource.org/licenses/MIT
*/
import OsmElement from './OsmElement';

export default class OsmBuilding {}
export default class OsmBuilding {
//TODO: Implement this class, or delete it.
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 Preferences from '../../config/Preferences';
import { Route } from './RoutingService';
import { RoutingOrTransitMode, RoutingMode } from '../../config/routingModes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* This file is licensed under the MIT License.
* License text available at https://opensource.org/licenses/MIT
*/
import { _isBlank } from '../../utils/LodashExtensions';
import { RoutingMode } from '../../config/routingModes';
import { TransitRoutingResult, TransitRoutingResultData } from './TransitRoutingResult';
import { RoutingResult, UnimodalRoutingResult, UnimodalRoutingResultData } from './RoutingResult';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class TransitRoutingResult implements RoutingResult {

const walkingSegmentsGeojson: GeoJSON.Feature<GeoJSON.Geometry, StepGeojsonProperties>[] = [];
const routingResults = await Promise.allSettled(walkingSegmentsRoutingPromises);
routingResults.forEach((walkingRoutingResult, routingIndex) => {
routingResults.forEach((walkingRoutingResult, _routingIndex) => {
if (walkingRoutingResult.status === 'rejected') {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class ZoneCollection extends GenericObjectCollection<Zone> implements Progressab
this._eventManager.emitProgress(`${ZoneCollection.displayName}${progressEventName}`, completeRatio);
}

newObject(attribs: Partial<GenericAttributes>, isNew = false, collectionManager?: CollectionManager): Zone {
//TODO: Add functionality to the _collectionManager argument, or remove it.
newObject(attribs: Partial<GenericAttributes>, isNew = false, _collectionManager?: CollectionManager): Zone {
return new Zone(attribs, isNew);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
default as osmGeojsonService
} from './data/osmGeojsonService';
import { getEntrancesForBuilding, findOsmData, FeatureEntrancesOptions } from './data/osmRawDataService';
import { _toInteger } from '../../utils/LodashExtensions';
import {
splitOverlappingFeatures,
getOverlappingIndices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ZoneGeojsonProperties,
default as osmGeojsonService
} from './data/osmGeojsonService';
import { getOsmNodesFor, getEntrancesForBuilding } from './data/osmRawDataService';
import { getEntrancesForBuilding } from './data/osmRawDataService';
import { _toInteger } from '../../utils/LodashExtensions';
import { queryResidentialZones, queryZonesWithResidences } from '../../config/osm/osmFlatsLanduseTags';
import { findOverlappingFeatures } from '../../services/geodata/FindOverlappingFeatures';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@
* This file is licensed under the MIT License.
* License text available at https://opensource.org/licenses/MIT
*/
import _uniq from 'lodash/uniq';
import _uniqBy from 'lodash/uniqBy';
import _flatten from 'lodash/flatten';
import GenericDataImportTask from './genericDataImportTask';
import GeoJSON from 'geojson';
import { DataGeojson, DataFileGeojson } from './data/dataGeojson';
import { DataFileGeojson } from './data/dataGeojson';
import { SingleGeoFeature } from '../../services/geodata/GeoJSONUtils';
import { PromptGeojsonPolygonService } from '../../services/prompt/promptGeojsonService';
import { PointOfInterest } from './data/osmGeojsonService';
import {
landUseCodesByOsmTag,
tripGenerationFunctionsByLandUseCode
} from '../../config/osm/osmMappingTagsToTripGenerationHandbookLandUse';
import { poiWeightCategories, poiIgnoredQueries } from '../../config/osm/osmPoiCategories';
import { _isBlank } from '../../utils/LodashExtensions';

Expand All @@ -27,28 +20,29 @@ const poiIgnoredTags = poiIgnoredQueries.map((query) => {
// TODO: make sure we do not have duplicate (like sport center as a node and as a building, wighted twice)
// TODO: deal with access=private on buildings and/or POIs (should we include them or not, and if so, which?)

const getLanduseCodesFromProperty = (properties: { [key: string]: any }): number[] => {
const propertiesToMatch = Object.keys(properties).filter((prop) => landUseCodesByOsmTag[prop] !== undefined);
const possibleLandUseCodes = _uniq(
_flatten(
propertiesToMatch.map((prop) => {
const propValue = properties[prop];
const matchProp = landUseCodesByOsmTag[prop];
const matchValue = matchProp[propValue];
if (matchValue !== undefined) {
return matchValue;
}
return matchProp['_default'];
})
)
);
const landUseCodes = possibleLandUseCodes.filter((val) => val !== undefined && val !== null);
// TODO Validate if there are many possible categories?
// TODO: deal with Walmart, Costco, Canadian Tire + others with separate POIs inside the main building:
// garden center, supermarket, department store, pharmacy, tire store, car repair, fast food, etc.
// TODO: deal with building:part to separate floor area of large buildings when available
return landUseCodes as number[];
};
// TODO: This function is only used in code that was commented in this file. If this code is eventually uncommented, re-enable, otherwise delete it.
// const getLanduseCodesFromProperty = (properties: { [key: string]: any }): number[] => {
// const propertiesToMatch = Object.keys(properties).filter((prop) => landUseCodesByOsmTag[prop] !== undefined);
// const possibleLandUseCodes = _uniq(
// _flatten(
// propertiesToMatch.map((prop) => {
// const propValue = properties[prop];
// const matchProp = landUseCodesByOsmTag[prop];
// const matchValue = matchProp[propValue];
// if (matchValue !== undefined) {
// return matchValue;
// }
// return matchProp['_default'];
// })
// )
// );
// const landUseCodes = possibleLandUseCodes.filter((val) => val !== undefined && val !== null);
// // TODO Validate if there are many possible categories?
// // TODO: deal with Walmart, Costco, Canadian Tire + others with separate POIs inside the main building:
// // garden center, supermarket, department store, pharmacy, tire store, car repair, fast food, etc.
// // TODO: deal with building:part to separate floor area of large buildings when available
// return landUseCodes as number[];
// };

export default class assignWeightToPOIs extends GenericDataImportTask {
private _warnings: string[] = [];
Expand Down Expand Up @@ -315,7 +309,6 @@ export default class assignWeightToPOIs extends GenericDataImportTask {

private async categorizePOIs(poiDataSource: DataFileGeojson): Promise<PointOfInterest[]> {
const allPois = (poiDataSource.queryOr([{}]) || []).filter((poi) => {
let ignoredMatched = false;
for (let i = 0, count = poiIgnoredTags.length; i < count; i++) {
const tags = poiIgnoredTags[i] || {};
let allTagsMatch = true;
Expand All @@ -325,7 +318,6 @@ export default class assignWeightToPOIs extends GenericDataImportTask {
}
}
if (allTagsMatch) {
ignoredMatched = true;
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,17 @@ const isIndustrialArea = function (properties: { [name: string]: any }): boolean
* Get the building or POI (node) category
* @param properties The properties of the feature for which to check for the category
*/
const getCategory = function (properties: { [name: string]: any }): string | null {
const getCategory = function (_properties: { [name: string]: any }): string | null {
// TODO: Make this function do something, or delete it.
return null;
};

/**
* Get the building or POI (node) detailed category
* @param properties The properties of the feature for which to check for the category
*/
const getCategoryDetailed = function (properties: { [name: string]: any }): string | null {
const getCategoryDetailed = function (_properties: { [name: string]: any }): string | null {
// TODO: Make this function do something, or delete it.
return null;
};

Expand Down Expand Up @@ -310,6 +312,14 @@ const getGeojsonsFromRawData = (
export default {
isRetirementHome,
isPark,
isPlayground,
isSportPitch,
isSchool,
isCollege,
isUniversity,
isCommercialBuilding,
isIndustrialBuilding,
isReligiousArea,
isResidentialArea,
isCommercialArea,
isIndustrialArea,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import GenericDataImportTask from './genericDataImportTask';
import { DataFileOsmRaw } from './data/dataOsmRaw';
import { DataFileGeojson } from './data/dataGeojson';
import { _toInteger } from '../../utils/LodashExtensions';
import OsmDataPreparationResidential from './OsmDataPreparationResidential';
import OsmDataPreparationNonResidential from './OsmDataPreparationNonResidential';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import EventManagerImpl, { EventManager } from '../../../services/events/EventManager';
import serviceLocator from '../../../utils/ServiceLocator';

/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
const eventMngr = new EventManagerImpl();

const mockEmit: jest.MockedFunction<(event: string | Event, ...args: any[]) => void> = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion packages/chaire-lib-common/src/utils/LodashExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const _makeStringUnique = (str: string, otherStrings: string[]): string => {
};

const _isEmail = (maybeEmail: string): boolean => {
return /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
maybeEmail
);
};
Expand Down

0 comments on commit 55783a8

Please sign in to comment.