From 442e6c7ced61f32e375593af2ab73ec0012c9f40 Mon Sep 17 00:00:00 2001 From: "Peter A. Jonsson" Date: Thu, 27 Feb 2025 14:35:26 +0100 Subject: [PATCH 1/2] Fix lodash-es imports This package depends on lodash-es, so import everything from that dependency. --- lib/Map/Vector/Protomaps/ProtomapsGeojsonSource.ts | 2 +- lib/Models/Catalog/CatalogItems/ApiTableCatalogItem.ts | 2 +- lib/Models/Catalog/CatalogItems/GeoJsonCatalogItem.ts | 2 +- lib/ReactViews/Workbench/Controls/ViewingControls.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Map/Vector/Protomaps/ProtomapsGeojsonSource.ts b/lib/Map/Vector/Protomaps/ProtomapsGeojsonSource.ts index ae6f43ed325..b69b33902b0 100644 --- a/lib/Map/Vector/Protomaps/ProtomapsGeojsonSource.ts +++ b/lib/Map/Vector/Protomaps/ProtomapsGeojsonSource.ts @@ -4,7 +4,7 @@ import booleanIntersects from "@turf/boolean-intersects"; import circle from "@turf/circle"; import { Feature, featureCollection } from "@turf/helpers"; import geojsonvt from "geojson-vt"; -import { cloneDeep } from "lodash"; +import { cloneDeep } from "lodash-es"; import { makeObservable, observable, runInAction } from "mobx"; import { Bbox, diff --git a/lib/Models/Catalog/CatalogItems/ApiTableCatalogItem.ts b/lib/Models/Catalog/CatalogItems/ApiTableCatalogItem.ts index ddf310d99bd..1476c391123 100644 --- a/lib/Models/Catalog/CatalogItems/ApiTableCatalogItem.ts +++ b/lib/Models/Catalog/CatalogItems/ApiTableCatalogItem.ts @@ -1,5 +1,5 @@ import dateFormat from "dateformat"; -import { get as _get, map as _map } from "lodash"; +import { get as _get, map as _map } from "lodash-es"; import { computed, observable, runInAction, makeObservable } from "mobx"; import URI from "urijs"; import isDefined from "../../../Core/isDefined"; diff --git a/lib/Models/Catalog/CatalogItems/GeoJsonCatalogItem.ts b/lib/Models/Catalog/CatalogItems/GeoJsonCatalogItem.ts index caadf8f8bf4..752f9552181 100644 --- a/lib/Models/Catalog/CatalogItems/GeoJsonCatalogItem.ts +++ b/lib/Models/Catalog/CatalogItems/GeoJsonCatalogItem.ts @@ -1,6 +1,6 @@ import { featureCollection, FeatureCollection } from "@turf/helpers"; import i18next from "i18next"; -import { get as _get, set as _set } from "lodash"; +import { get as _get, set as _set } from "lodash-es"; import { computed, makeObservable, toJS } from "mobx"; import filterOutUndefined from "../../../Core/filterOutUndefined"; import { diff --git a/lib/ReactViews/Workbench/Controls/ViewingControls.tsx b/lib/ReactViews/Workbench/Controls/ViewingControls.tsx index 05cf56d496a..e3899e28603 100644 --- a/lib/ReactViews/Workbench/Controls/ViewingControls.tsx +++ b/lib/ReactViews/Workbench/Controls/ViewingControls.tsx @@ -1,4 +1,4 @@ -import { sortBy, uniqBy } from "lodash"; +import { sortBy, uniqBy } from "lodash-es"; import { action, computed, runInAction, makeObservable } from "mobx"; import { observer } from "mobx-react"; import React from "react"; From de7a0edc22fe62f05a66aebeed3e484976e9a780 Mon Sep 17 00:00:00 2001 From: "Peter A. Jonsson" Date: Wed, 5 Mar 2025 11:07:14 +0100 Subject: [PATCH 2/2] eslint: prohibit importing lodash This package uses lodash-es, so import that instead. --- .eslintrc.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index f5813fb00ab..6cce1c492d6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -66,6 +66,13 @@ module.exports = { "react/self-closing-comp": "error", "react/jsx-no-undef": ["error", { allowGlobals: true }], + "no-restricted-imports": [ + "error", + { + name: "lodash", + message: "Please use 'lodash-es' instead." + } + ], /*Possible Errors */ "no-console": "off", "no-inner-declarations": [1, "functions"],