diff --git a/.eslintrc b/.eslintrc index 6c379ecd6d1..f0fa2e0df6a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -111,7 +111,7 @@ }, "overrides": [ { - "files": ["*.ts", "**/*.tsx"], + "files": ["**/*.ts", "**/*.tsx"], "rules": { // @TODO: revise these rules "@typescript-eslint/consistent-type-assertions": "error", @@ -121,13 +121,15 @@ { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", - "caughtErrorsIgnorePattern": "^_" + "caughtErrorsIgnorePattern": "^_", + "destructuredArrayIgnorePattern": "^_", + "ignoreRestSiblings": true } ], "@typescript-eslint/ban-ts-comment": "warn", "@typescript-eslint/no-loss-of-precision": "warn", "@typescript-eslint/no-unsafe-declaration-merging": "off", - "react-hooks/exhaustive-deps": "warn", + "react-hooks/exhaustive-deps": "off", "react/prop-types": "warn" } } diff --git a/CHANGES.md b/CHANGES.md index 85b52062487..a165d1313b3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ #### next release (8.7.7) +- Fix remaining lint warnings - [The next improvement] #### 8.7.6 - 2024-08-22 diff --git a/lib/Core/animation.ts b/lib/Core/animation.ts index 4a18f7e8322..fac0929bf78 100644 --- a/lib/Core/animation.ts +++ b/lib/Core/animation.ts @@ -2,19 +2,19 @@ * The purpose of this module is to provide a standard way to perform actions after an animations ends. * The advantage is that the code is more tightly coupled together and we don't have to guess when the animation ends. * There is also a timeout fallback that will reject the Promise if the animation end event is not fired in time. - * + * * Old code: * triggerSomeAnimation(); setTimeout(function() { somePostAction(); }, 200); - * - * New code: + * + * New code: animateEnd(this.elementRef.current).finally(somePostAction); triggerAnimation(); - * - * + * + * */ const ANIMATION_TIMEOUT = 500; @@ -33,10 +33,10 @@ const transitionEnd = (element: Element | null) => }); const animationTimeout = ( - timeoutID: ReturnType | undefined + _timeoutID: ReturnType | undefined ) => new Promise((_, reject) => { - timeoutID = setTimeout(() => { + _timeoutID = setTimeout(() => { reject("Animation timed out. Did you forget to animate the element?"); }, ANIMATION_TIMEOUT); }); diff --git a/lib/Core/autoUpdate.ts b/lib/Core/autoUpdate.ts index f98e137e830..27a9300312a 100644 --- a/lib/Core/autoUpdate.ts +++ b/lib/Core/autoUpdate.ts @@ -19,7 +19,7 @@ export default function autoUpdate(updater: (...args: any[]) => void) { updater.call(args.context, args.value); }); }, - (disposer, value) => { + (disposer, _value) => { console.log("cleanup"); if (disposer) { disposer(); diff --git a/lib/Core/createColorForIdTransformer.ts b/lib/Core/createColorForIdTransformer.ts index 8c94dd4486b..cd4d6850eeb 100644 --- a/lib/Core/createColorForIdTransformer.ts +++ b/lib/Core/createColorForIdTransformer.ts @@ -15,7 +15,7 @@ const usedColors: { [c: string]: number | undefined } = {}; */ function createColorForIdTransformer() { return createTransformer( - (id: string): string => { + (_id: string): string => { const nextColor = leastUsedColor(); useColor(nextColor); return nextColor; diff --git a/lib/Map/Cesium/CesiumRenderLoopPauser.ts b/lib/Map/Cesium/CesiumRenderLoopPauser.ts index 2b85a0f0fad..632bd19694e 100644 --- a/lib/Map/Cesium/CesiumRenderLoopPauser.ts +++ b/lib/Map/Cesium/CesiumRenderLoopPauser.ts @@ -2,7 +2,6 @@ import defined from "terriajs-cesium/Source/Core/defined"; import destroyObject from "terriajs-cesium/Source/Core/destroyObject"; import CesiumEvent from "terriajs-cesium/Source/Core/Event"; import getTimestamp from "terriajs-cesium/Source/Core/getTimestamp"; -import JulianDate from "terriajs-cesium/Source/Core/JulianDate"; import Matrix4 from "terriajs-cesium/Source/Core/Matrix4"; import TaskProcessor from "terriajs-cesium/Source/Core/TaskProcessor"; import CesiumWidget from "terriajs-cesium/Source/Widget/CesiumWidget"; @@ -285,7 +284,7 @@ export default class CesiumRenderLoopPauser { this.renderingIsPaused = false; } - private postRender(date: JulianDate) { + private postRender() { // We can safely stop rendering when: // - the camera position hasn't changed in over a second, // - there are no tiles waiting to load, and diff --git a/lib/Map/Leaflet/ImageryProviderLeafletTileLayer.ts b/lib/Map/Leaflet/ImageryProviderLeafletTileLayer.ts index 2927d091c29..8d1dea7c2dd 100644 --- a/lib/Map/Leaflet/ImageryProviderLeafletTileLayer.ts +++ b/lib/Map/Leaflet/ImageryProviderLeafletTileLayer.ts @@ -152,11 +152,11 @@ export default class ImageryProviderLeafletTileLayer extends L.TileLayer { // an error event. We want to first raise an error event that optionally returns a promise and // retries after the promise resolves. - const doRequest = (waitPromise?: any) => { + const _doRequest = (waitPromise?: any) => { if (waitPromise) { waitPromise .then(function () { - doRequest(); + _doRequest(); }) .catch((e: unknown) => { // The tile has failed irrecoverably, so invoke Leaflet's standard diff --git a/lib/Map/SizeMap/ConstantPointSizeMap.ts b/lib/Map/SizeMap/ConstantPointSizeMap.ts index 2257852902b..6a3638d5f8c 100644 --- a/lib/Map/SizeMap/ConstantPointSizeMap.ts +++ b/lib/Map/SizeMap/ConstantPointSizeMap.ts @@ -5,7 +5,7 @@ export default class ConstantPointSizeMap extends PointSizeMap { super(); } - mapValueToPointSize(value: string | number | null | undefined): number { + mapValueToPointSize(_value: string | number | null | undefined): number { return this.pointSize; } } diff --git a/lib/ModelMixins/GltfMixin.ts b/lib/ModelMixins/GltfMixin.ts index 7819882b6a7..267d4024836 100644 --- a/lib/ModelMixins/GltfMixin.ts +++ b/lib/ModelMixins/GltfMixin.ts @@ -89,8 +89,8 @@ function GltfMixin>(Base: T) { @computed private get cesiumHeightReference() { const heightReference: HeightReference = - // @ts-expect-error - HeightReference[this.heightReference] || HeightReference.NONE; + HeightReference[this.heightReference as keyof typeof HeightReference] || + HeightReference.NONE; return heightReference; } diff --git a/lib/ModelMixins/SearchProviders/WebFeatureServiceSearchProviderMixin.ts b/lib/ModelMixins/SearchProviders/WebFeatureServiceSearchProviderMixin.ts index 482740f1bfb..353e0e76def 100644 --- a/lib/ModelMixins/SearchProviders/WebFeatureServiceSearchProviderMixin.ts +++ b/lib/ModelMixins/SearchProviders/WebFeatureServiceSearchProviderMixin.ts @@ -178,7 +178,7 @@ function WebFeatureServiceSearchProviderMixin< results.results.push(...searchResults); }); }) - .catch((e) => { + .catch((_e) => { if (results.isCanceled) { // A new search has superseded this one, so ignore the result. return; diff --git a/lib/ModelMixins/TimeFilterMixin.ts b/lib/ModelMixins/TimeFilterMixin.ts index 8794caf278e..3c2717bd7d3 100644 --- a/lib/ModelMixins/TimeFilterMixin.ts +++ b/lib/ModelMixins/TimeFilterMixin.ts @@ -161,7 +161,7 @@ function TimeFilterMixin>(Base: T) { if (!MappableMixin.isMixedInto(this)) return []; return filterOutUndefined( this.mapItems.map( - // @ts-expect-error + // @ts-expect-error url attr (mapItem) => ImageryParts.is(mapItem) && mapItem.imageryProvider.url ) ); diff --git a/lib/Models/BoxDrawing.ts b/lib/Models/BoxDrawing.ts index 08b68e6b5d8..72e9c5b1b0d 100644 --- a/lib/Models/BoxDrawing.ts +++ b/lib/Models/BoxDrawing.ts @@ -207,11 +207,6 @@ const FACE_POINT_VECTORS = [ new Cartesian3(0.0, 0.0, 0.5) ]; -// The box has 8 corner points and 6 face points that act as scaling grips. -// Here we represent them as 7 vectors in local coordinates space. -// Each vector represents a point and its opposite points can be easily derived from it. -const SCALE_POINT_VECTORS = [...CORNER_POINT_VECTORS, ...FACE_POINT_VECTORS]; - /** * Checks whether the given entity is updatable (i.e repsonds to box parameter changes). */ @@ -1779,23 +1774,6 @@ export function screenToGlobePosition( return globePosition; } -/** - * Project the given point to the ellipsoid surface. - */ -function projectPointToSurface( - position: Cartesian3, - result: Cartesian3 -): Cartesian3 { - const cartographic = Cartographic.fromCartesian( - position, - undefined, - scratchCartographic - ); - cartographic.height = 0; - return Cartographic.toCartesian(cartographic, undefined, result); -} -const scratchCartographic = new Cartographic(); - function setPlaneDimensions( boxDimensions: Cartesian3, planeNormalAxis: Axis, diff --git a/lib/Models/Catalog/CatalogItems/OpenDataSoftCatalogItem.ts b/lib/Models/Catalog/CatalogItems/OpenDataSoftCatalogItem.ts index eb896ffdd8c..6951a5f0d61 100644 --- a/lib/Models/Catalog/CatalogItems/OpenDataSoftCatalogItem.ts +++ b/lib/Models/Catalog/CatalogItems/OpenDataSoftCatalogItem.ts @@ -394,7 +394,7 @@ export class OpenDataSoftDatasetStratum extends LoadableStratum( // Group all time intervals for each row group (each Point feature) // This calculates the start/stop dates for each row group const groupIntervals = this.catalogItem.activeTableStyle.rowGroups.map( - ([id, rows]) => { + ([_id, rows]) => { let start: JulianDate | undefined; let stop: JulianDate | undefined; diff --git a/lib/Models/Catalog/CatalogReferences/CatalogIndexReference.ts b/lib/Models/Catalog/CatalogReferences/CatalogIndexReference.ts index ba88d1a821b..d3921fb2d60 100644 --- a/lib/Models/Catalog/CatalogReferences/CatalogIndexReference.ts +++ b/lib/Models/Catalog/CatalogReferences/CatalogIndexReference.ts @@ -27,7 +27,7 @@ export default class CatalogIndexReference extends ReferenceMixin( } protected async forceLoadReference( - previousTarget: BaseModel | undefined + _previousTarget: BaseModel | undefined ): Promise { if (this.uniqueId === undefined) { return; diff --git a/lib/Models/Catalog/CatalogReferences/SplitItemReference.ts b/lib/Models/Catalog/CatalogReferences/SplitItemReference.ts index bc122e37e80..da3c672cfcb 100644 --- a/lib/Models/Catalog/CatalogReferences/SplitItemReference.ts +++ b/lib/Models/Catalog/CatalogReferences/SplitItemReference.ts @@ -24,7 +24,7 @@ export default class SplitItemReference extends ReferenceMixin( } protected async forceLoadReference( - previousTarget: BaseModel | undefined + _previousTarget: BaseModel | undefined ): Promise { if (this.splitSourceItemId === undefined || this.uniqueId === undefined) { throw new TerriaError({ diff --git a/lib/Models/Catalog/CatalogReferences/ThreddsItemReference.ts b/lib/Models/Catalog/CatalogReferences/ThreddsItemReference.ts index 08f0a71685c..34f86a1847d 100644 --- a/lib/Models/Catalog/CatalogReferences/ThreddsItemReference.ts +++ b/lib/Models/Catalog/CatalogReferences/ThreddsItemReference.ts @@ -28,7 +28,7 @@ export class ThreddsDatasetStratum extends LoadableStratum( super(); } - duplicateLoadableStratum(newModel: BaseModel): this { + duplicateLoadableStratum(_newModel: BaseModel): this { return new ThreddsDatasetStratum( this.threddsItemReference, this.threddsDataset @@ -109,7 +109,7 @@ export default class ThreddsItemReference extends UrlMixin( } async forceLoadReference( - previousTarget: BaseModel | undefined + _previousTarget: BaseModel | undefined ): Promise { this.setThreddsStrata(this); @@ -121,7 +121,7 @@ export default class ThreddsItemReference extends UrlMixin( ); if (model === undefined) return; this.setThreddsStrata(model); - previousTarget = model; + _previousTarget = model; return model; } } diff --git a/lib/Models/Catalog/CatalogReferences/UrlReference.ts b/lib/Models/Catalog/CatalogReferences/UrlReference.ts index f63c7388e3b..4fdf4c61340 100644 --- a/lib/Models/Catalog/CatalogReferences/UrlReference.ts +++ b/lib/Models/Catalog/CatalogReferences/UrlReference.ts @@ -33,7 +33,7 @@ export default class UrlReference extends UrlMixin( } protected forceLoadReference( - previousTarget: BaseModel | undefined + _previousTarget: BaseModel | undefined ): Promise { if (this.url === undefined || this.uniqueId === undefined) { return Promise.resolve(undefined); diff --git a/lib/Models/Catalog/Ckan/CkanDefaultFormatsStratum.ts b/lib/Models/Catalog/Ckan/CkanDefaultFormatsStratum.ts index af3ad40932c..6361cedf060 100644 --- a/lib/Models/Catalog/Ckan/CkanDefaultFormatsStratum.ts +++ b/lib/Models/Catalog/Ckan/CkanDefaultFormatsStratum.ts @@ -10,7 +10,7 @@ export default class CkanDefaultFormatsStratum extends LoadableStratum( ) { static stratumName = "ckanDefaultFormats"; - duplicateLoadableStratum(newModel: BaseModel): this { + duplicateLoadableStratum(_newModel: BaseModel): this { return new CkanDefaultFormatsStratum() as this; } diff --git a/lib/Models/Catalog/Ckan/CkanItemReference.ts b/lib/Models/Catalog/Ckan/CkanItemReference.ts index 567ba1e0c11..229a05a81c0 100644 --- a/lib/Models/Catalog/Ckan/CkanItemReference.ts +++ b/lib/Models/Catalog/Ckan/CkanItemReference.ts @@ -348,7 +348,7 @@ export default class CkanItemReference extends UrlMixin( } async forceLoadReference( - previousTarget: BaseModel | undefined + _previousTarget: BaseModel | undefined ): Promise { await this.setCkanStrata(this); @@ -388,7 +388,7 @@ export default class CkanItemReference extends UrlMixin( } if (model === undefined) return; - previousTarget = model; + _previousTarget = model; await this.setCkanStrata(model); model.setTrait(CommonStrata.definition, "name", this.name); diff --git a/lib/Models/Catalog/Esri/ArcGisCatalogGroup.ts b/lib/Models/Catalog/Esri/ArcGisCatalogGroup.ts index eae86593170..ab01c79185b 100644 --- a/lib/Models/Catalog/Esri/ArcGisCatalogGroup.ts +++ b/lib/Models/Catalog/Esri/ArcGisCatalogGroup.ts @@ -25,11 +25,6 @@ import ArcGisMapServerCatalogGroup, { MapServerStratum } from "./ArcGisMapServerCatalogGroup"; -interface DocumentInfo { - Title?: string; - Author?: string; -} - interface Service { name: string; type: string; diff --git a/lib/Models/Catalog/Esri/ArcGisPortalItemReference.ts b/lib/Models/Catalog/Esri/ArcGisPortalItemReference.ts index 0232f355aa9..2f156699b75 100644 --- a/lib/Models/Catalog/Esri/ArcGisPortalItemReference.ts +++ b/lib/Models/Catalog/Esri/ArcGisPortalItemReference.ts @@ -42,7 +42,7 @@ export class ArcGisPortalItemStratum extends LoadableStratum( makeObservable(this); } - duplicateLoadableStratum(newModel: BaseModel): this { + duplicateLoadableStratum(_newModel: BaseModel): this { return new ArcGisPortalItemStratum( this.arcgisPortalItemReference, this.arcgisPortalCatalogGroup @@ -309,7 +309,7 @@ export default class ArcGisPortalItemReference extends AccessControlMixin( } async forceLoadReference( - previousTarget: BaseModel | undefined + _previousTarget: BaseModel | undefined ): Promise { // So when we first crawl we'll get this far await this.setArcgisStrata(this); @@ -350,7 +350,7 @@ export default class ArcGisPortalItemReference extends AccessControlMixin( ); if (model === undefined) return; - previousTarget = model; + _previousTarget = model; await this.setArcgisStrata(model); const defintionStratum = this.strata.get(CommonStrata.definition); @@ -372,11 +372,6 @@ interface ArcGisItemInfo { error?: JsonObject; } -interface ArcGisItemWithFormat { - supportedFormat: PreparedSupportedFormat; - arcgisItem: ArcGisItem; -} - interface PreparedSupportedFormat { formatRegex: RegExp | undefined; urlRegex: RegExp | undefined; diff --git a/lib/Models/Definition/FlattenedFromTraits.ts b/lib/Models/Definition/FlattenedFromTraits.ts index 320cc1fde40..45b227e9f50 100644 --- a/lib/Models/Definition/FlattenedFromTraits.ts +++ b/lib/Models/Definition/FlattenedFromTraits.ts @@ -8,7 +8,7 @@ type SingleTrait = If< TTrait extends ModelTraits ? FlattenedFromTraits : never >; -type ArrayTrait = ReadonlyArray>; +type ArrayTrait<_TTrait, TElement> = ReadonlyArray>; /** * Transforms a {@link ModelTraits} class into a type usable as a flattened view of multiple strata. diff --git a/lib/Models/Definition/LoadableStratum.ts b/lib/Models/Definition/LoadableStratum.ts index d6cd1f5168f..b9f9c0a1943 100644 --- a/lib/Models/Definition/LoadableStratum.ts +++ b/lib/Models/Definition/LoadableStratum.ts @@ -24,7 +24,7 @@ export default function LoadableStratum< get: function () { return undefined; }, - set: function (value: any) { + set: function () { throw new DeveloperError( "Traits of a LoadableStratum may not be set." ); diff --git a/lib/Models/Definition/ModelPropertiesFromTraits.ts b/lib/Models/Definition/ModelPropertiesFromTraits.ts index a3d32bd7565..c6c28092c6b 100644 --- a/lib/Models/Definition/ModelPropertiesFromTraits.ts +++ b/lib/Models/Definition/ModelPropertiesFromTraits.ts @@ -8,7 +8,7 @@ type SingleTrait = If< TTrait, TTrait extends ModelTraits ? Model : never >; -type ArrayTrait = ReadonlyArray>; +type ArrayTrait<_TTrait, TElement> = ReadonlyArray>; /** * Transforms a {@link ModelTraits} class into a type representative of the traits properties exposed on diff --git a/lib/Models/Definition/StratumFromTraits.ts b/lib/Models/Definition/StratumFromTraits.ts index ca347f534ee..1b92787f473 100644 --- a/lib/Models/Definition/StratumFromTraits.ts +++ b/lib/Models/Definition/StratumFromTraits.ts @@ -8,7 +8,7 @@ type SingleTrait = If< TTrait extends ModelTraits ? StratumFromTraits : never >; -type ArrayTrait = Array>; +type ArrayTrait<_TTrait, TElement> = Array>; /** * Transforms a {@link ModelTraits} class into a type usable as a stratum. diff --git a/lib/Models/FunctionParameters/InfoParameter.ts b/lib/Models/FunctionParameters/InfoParameter.ts index 88fa15b9aaf..84a0a4ddfb0 100644 --- a/lib/Models/FunctionParameters/InfoParameter.ts +++ b/lib/Models/FunctionParameters/InfoParameter.ts @@ -51,7 +51,7 @@ export default class InfoParameter extends FunctionParameter { this._value = v; } - clearValue(strataId: string) { + clearValue(_strataId: string) { this._value = undefined; } } diff --git a/lib/Models/Leaflet.ts b/lib/Models/Leaflet.ts index 23f82ec5dc7..e249942f93f 100644 --- a/lib/Models/Leaflet.ts +++ b/lib/Models/Leaflet.ts @@ -63,7 +63,7 @@ import Terria from "./Terria"; // We want TS to look at the type declared in lib/ThirdParty/terriajs-cesium-extra/index.d.ts // and import doesn't allows us to do that, so instead we use require + type casting to ensure // we still maintain the type checking, without TS screaming with errors -const FeatureDetection: FeatureDetection = +const _FeatureDetection: FeatureDetection = require("terriajs-cesium/Source/Core/FeatureDetection").default; // This class is an observer. It probably won't contain any observables itself diff --git a/lib/Models/LocationMarkerUtils.ts b/lib/Models/LocationMarkerUtils.ts index d7eee1871ca..bbdaca02bcd 100644 --- a/lib/Models/LocationMarkerUtils.ts +++ b/lib/Models/LocationMarkerUtils.ts @@ -6,7 +6,7 @@ import Terria from "./Terria"; import LatLonHeight from "../Core/LatLonHeight"; import { toJS } from "mobx"; -// @ts-expect-error +// @ts-expect-error image import import markerIcon from "../../wwwroot/images/map-pin.png"; export const LOCATION_MARKER_DATA_SOURCE_NAME = diff --git a/lib/Models/NoViewer.ts b/lib/Models/NoViewer.ts index 6b546e1da86..a45ab3dea51 100644 --- a/lib/Models/NoViewer.ts +++ b/lib/Models/NoViewer.ts @@ -27,7 +27,7 @@ class NoViewer extends GlobeOrMap { doZoomTo( v: CameraView | Rectangle | MappableMixin.Instance, - t: any + _t: any ): Promise { if (v instanceof CameraView) { this._currentView = v; @@ -40,9 +40,9 @@ class NoViewer extends GlobeOrMap { notifyRepaintRequired() {} pickFromLocation( - latLngHeight: LatLonHeight, - providerCoords: ProviderCoordsMap, - existingFeatures: TerriaFeature[] + _latLngHeight: LatLonHeight, + _providerCoords: ProviderCoordsMap, + _existingFeatures: TerriaFeature[] ) {} getCurrentCameraView(): CameraView { @@ -56,8 +56,10 @@ class NoViewer extends GlobeOrMap { pauseMapInteraction() {} resumeMapInteraction() {} _addVectorTileHighlight( - imageryProvider: MapboxVectorTileImageryProvider | ProtomapsImageryProvider, - rectangle: Rectangle + _imageryProvider: + | MapboxVectorTileImageryProvider + | ProtomapsImageryProvider, + _rectangle: Rectangle ) { return () => {}; } diff --git a/lib/Models/SearchProviders/StubSearchProvider.ts b/lib/Models/SearchProviders/StubSearchProvider.ts index 6ba2399bff7..304a65ddb88 100644 --- a/lib/Models/SearchProviders/StubSearchProvider.ts +++ b/lib/Models/SearchProviders/StubSearchProvider.ts @@ -30,13 +30,13 @@ export default class StubSearchProvider extends SearchProviderMixin( return StubSearchProvider.type; } - protected logEvent(searchText: string) { + protected logEvent(_searchText: string) { return; } protected doSearch( - searchText: string, - results: SearchProviderResults + _searchText: string, + _results: SearchProviderResults ): Promise { return Promise.resolve(); } diff --git a/lib/ReactViews/Custom/ApiTableCustomComponent.ts b/lib/ReactViews/Custom/ApiTableCustomComponent.ts index 816648404f6..20e679d9211 100644 --- a/lib/ReactViews/Custom/ApiTableCustomComponent.ts +++ b/lib/ReactViews/Custom/ApiTableCustomComponent.ts @@ -26,7 +26,7 @@ export default class ApiTableChartCustomComponent extends ChartCustomComponent this.createItemReference( context.catalogItem as SensorObservationServiceCatalogItem @@ -43,7 +43,7 @@ export default class SOSChartCustomComponent extends ChartCustomComponent { state = { hasError: false }; - static getDerivedStateFromError(error: any) { + static getDerivedStateFromError(_error: Error) { return { hasError: true }; } - componentDidCatch(error: Error, errorInfo: ErrorInfo) { + componentDidCatch(error: Error, _errorInfo: ErrorInfo) { this.props.viewState.terria.raiseErrorToUser( error, this.props.terriaErrorOptions diff --git a/lib/ReactViews/FeatureInfo/FeatureInfoSection.tsx b/lib/ReactViews/FeatureInfo/FeatureInfoSection.tsx index 2b1a2bcf3ec..da5e71a2d5c 100644 --- a/lib/ReactViews/FeatureInfo/FeatureInfoSection.tsx +++ b/lib/ReactViews/FeatureInfo/FeatureInfoSection.tsx @@ -144,7 +144,7 @@ export class FeatureInfoSection extends React.Component { this.removeFeatureChangedSubscription?.(); this.removeFeatureChangedSubscription = feature.definitionChanged.addEventListener( - ((changedFeature: TerriaFeature) => { + ((_changedFeature: TerriaFeature) => { runInAction(() => { this.featureChangedCounter++; }); diff --git a/lib/ReactViews/FeatureInfo/mustacheExpressions.ts b/lib/ReactViews/FeatureInfo/mustacheExpressions.ts index cd48fb66418..43613ad0b88 100644 --- a/lib/ReactViews/FeatureInfo/mustacheExpressions.ts +++ b/lib/ReactViews/FeatureInfo/mustacheExpressions.ts @@ -87,7 +87,7 @@ export function mustacheRenderPartialByName( templateData: object ): MustacheFunction { return () => { - return mustacheJsonSubOptions((value, options) => { + return mustacheJsonSubOptions((value, _options) => { if (!isJsonString(value)) return `${value}`; if (partials && typeof partials[value] === "string") { return Mustache.render(partials[value], templateData); diff --git a/lib/ReactViews/Map/BottomBar/DistanceLegend.tsx b/lib/ReactViews/Map/BottomBar/DistanceLegend.tsx index e59651efb26..93940664e28 100644 --- a/lib/ReactViews/Map/BottomBar/DistanceLegend.tsx +++ b/lib/ReactViews/Map/BottomBar/DistanceLegend.tsx @@ -7,7 +7,6 @@ import { useTheme } from "styled-components"; import Cartesian2 from "terriajs-cesium/Source/Core/Cartesian2"; import EllipsoidGeodesic from "terriajs-cesium/Source/Core/EllipsoidGeodesic"; import CesiumEvent from "terriajs-cesium/Source/Core/Event"; -import getTimestamp from "terriajs-cesium/Source/Core/getTimestamp"; import Scene from "terriajs-cesium/Source/Scene/Scene"; import isDefined from "../../../Core/isDefined"; import Box from "../../../Styled/Box"; @@ -91,8 +90,6 @@ export const DistanceLegend: FC = observer( }; const updateDistanceLegendCesium = (scene: Scene) => { - const now = getTimestamp(); - // Find the distance between two pixels at the bottom center of the screen. const width = scene.canvas.clientWidth; const height = scene.canvas.clientHeight; @@ -160,7 +157,7 @@ export const DistanceLegend: FC = observer( .distanceTo(map.containerPointToLatLng([maxPixelWidth, halfHeight])); runInAction(() => (terria.mainViewer.scale = maxMeters / 100)); - // @ts-expect-error + // @ts-expect-error Accessing private method const meters = L.control.scale()._getRoundNum(maxMeters); const label = meters < 1000 ? meters + " m" : meters / 1000 + " km"; diff --git a/lib/ReactViews/Map/MapColumn.tsx b/lib/ReactViews/Map/MapColumn.tsx index 2701e89cc85..1d0f0f12fc1 100644 --- a/lib/ReactViews/Map/MapColumn.tsx +++ b/lib/ReactViews/Map/MapColumn.tsx @@ -16,7 +16,6 @@ import { TerriaViewerWrapper } from "./TerriaViewerWrapper"; import Toast from "./Toast"; interface IMapColumnProps { - customFeedbacks: any; animationDuration: number; customElements: any; } @@ -26,7 +25,7 @@ interface IMapColumnProps { * the timeline and charts. */ export const MapColumn: FC = observer( - ({ customFeedbacks, customElements, animationDuration }) => { + ({ customElements, animationDuration }) => { const viewState = useViewState(); const { t } = useTranslation(); diff --git a/lib/ReactViews/Map/MapNavigation/Items/Compass/Compass.tsx b/lib/ReactViews/Map/MapNavigation/Items/Compass/Compass.tsx index 96f250a0efd..262d236dd04 100644 --- a/lib/ReactViews/Map/MapNavigation/Items/Compass/Compass.tsx +++ b/lib/ReactViews/Map/MapNavigation/Items/Compass/Compass.tsx @@ -333,6 +333,8 @@ class Compass extends React.PureComponent { COMPASS_LOCAL_PROPERTY_KEY ); + console.log(showGuidance); + return ( { right: 55px; `} > +
+                !!!!!!!!
+              
{ // this.props.viewState.showHelpPanel(); diff --git a/lib/ReactViews/Map/MapNavigation/Items/ZoomControl.tsx b/lib/ReactViews/Map/MapNavigation/Items/ZoomControl.tsx index fa8e9386e74..4697d8c1736 100644 --- a/lib/ReactViews/Map/MapNavigation/Items/ZoomControl.tsx +++ b/lib/ReactViews/Map/MapNavigation/Items/ZoomControl.tsx @@ -180,7 +180,7 @@ class ZoomControlBase extends React.Component { } render() { - const { t, theme } = this.props; + const { t } = this.props; return (
    >(function ShareUrl( diff --git a/lib/ReactViews/Search/SearchResult.tsx b/lib/ReactViews/Search/SearchResult.tsx index fb2a6c3465d..17a35e4012c 100644 --- a/lib/ReactViews/Search/SearchResult.tsx +++ b/lib/ReactViews/Search/SearchResult.tsx @@ -28,7 +28,7 @@ interface SearchResultProps { clickAction(): void; isLastResult: boolean; locationSearchText: string; - icon: string; + icon: keyof typeof Icon.GLYPHS; } const SearchResult: React.FC = ( @@ -69,7 +69,6 @@ const SearchResult: React.FC = ( fillColor={isLightTheme && theme.textDarker} light={isDarkTheme} styledWidth={"16px"} - // @ts-expect-error glyph={Icon.GLYPHS[props.icon]} /> )} diff --git a/lib/ReactViews/SelectableDimensions/Button.tsx b/lib/ReactViews/SelectableDimensions/Button.tsx index 5657be1280a..e276c5eb8fb 100644 --- a/lib/ReactViews/SelectableDimensions/Button.tsx +++ b/lib/ReactViews/SelectableDimensions/Button.tsx @@ -11,7 +11,7 @@ import AnimatedSpinnerIcon from "../../Styled/AnimatedSpinnerIcon"; export const SelectableDimensionButton: React.FC<{ id: string; dim: SelectableDimensionButtonModel; -}> = ({ id, dim }) => { +}> = ({ dim }) => { const iconGlyph = dim.icon; const iconProps = { light: true, styledWidth: "16px", styledHeight: "16px" }; return ( diff --git a/lib/ReactViews/SelectableDimensions/Color.tsx b/lib/ReactViews/SelectableDimensions/Color.tsx index 9330d6d237b..5881305a380 100644 --- a/lib/ReactViews/SelectableDimensions/Color.tsx +++ b/lib/ReactViews/SelectableDimensions/Color.tsx @@ -23,7 +23,7 @@ const debounceSetColorDimensionValue = debounce( export const SelectableDimensionColor: React.FC<{ id: string; dim: SelectableDimensionColorModel; -}> = observer(({ id, dim }) => { +}> = observer(({ dim }) => { const [open, setIsOpen] = useState(false); const { t } = useTranslation(); return ( diff --git a/lib/ReactViews/SelectableDimensions/ColorSchemeOptionRenderer.tsx b/lib/ReactViews/SelectableDimensions/ColorSchemeOptionRenderer.tsx index 4b58fdee00b..a5929b48bc3 100644 --- a/lib/ReactViews/SelectableDimensions/ColorSchemeOptionRenderer.tsx +++ b/lib/ReactViews/SelectableDimensions/ColorSchemeOptionRenderer.tsx @@ -1,5 +1,5 @@ import { useTranslation } from "react-i18next"; -import { lab, rgb } from "d3-color"; +import { rgb } from "d3-color"; import * as d3Scale from "d3-scale-chromatic"; import React from "react"; import StandardCssColors from "../../Core/StandardCssColors"; diff --git a/lib/ReactViews/SelectableDimensions/Select.tsx b/lib/ReactViews/SelectableDimensions/Select.tsx index f5f4e7eb490..77c9b32e18c 100644 --- a/lib/ReactViews/SelectableDimensions/Select.tsx +++ b/lib/ReactViews/SelectableDimensions/Select.tsx @@ -15,7 +15,7 @@ import { export const SelectableDimensionEnum: React.FC<{ id: string; dim: SelectableDimensionEnumModel; -}> = observer(({ id, dim }) => { +}> = observer(({ dim }) => { const theme = useTheme(); const undefinedOption = { @@ -96,7 +96,7 @@ export const SelectableDimensionEnum: React.FC<{ export const SelectableDimensionEnumMulti: React.FC<{ id: string; dim: SelectableDimensionEnumMultiModel; -}> = observer(({ id, dim }) => { +}> = observer(({ dim }) => { const theme = useTheme(); const options = dim.options?.map((option) => ({ diff --git a/lib/ReactViews/StandardUserInterface/StandardUserInterface.tsx b/lib/ReactViews/StandardUserInterface/StandardUserInterface.tsx index 9575bcf01d2..9c9c90034bf 100644 --- a/lib/ReactViews/StandardUserInterface/StandardUserInterface.tsx +++ b/lib/ReactViews/StandardUserInterface/StandardUserInterface.tsx @@ -220,7 +220,6 @@ const StandardUserInterfaceBase: React.FC =
    diff --git a/lib/ReactViews/Story/StoryBuilder.tsx b/lib/ReactViews/Story/StoryBuilder.tsx index eb864c5c891..c79102e98a7 100644 --- a/lib/ReactViews/Story/StoryBuilder.tsx +++ b/lib/ReactViews/Story/StoryBuilder.tsx @@ -329,7 +329,7 @@ class StoryBuilder extends React.Component< }); } - renderStories(editingMode: boolean) { + renderStories(_editingMode: boolean) { const { t, i18n } = this.props; const stories = this.props.viewState.terria.stories || []; const storyName = this.state.storyToRemove diff --git a/lib/ReactViews/Tools/ClippingBox/RepositionClippingBox.tsx b/lib/ReactViews/Tools/ClippingBox/RepositionClippingBox.tsx index d67f5162bb7..78265bd6e1d 100644 --- a/lib/ReactViews/Tools/ClippingBox/RepositionClippingBox.tsx +++ b/lib/ReactViews/Tools/ClippingBox/RepositionClippingBox.tsx @@ -206,10 +206,6 @@ function setCursor(el: HTMLElement, cursorName: string) { el.style.cursor = cursorName; } -function truncate(text: string, length: number) { - return text.length <= length ? text : `${text.slice(0, length)}...`; -} - function pickGlobePosition( screenCoords: Cartesian2, scene: Scene, diff --git a/lib/ReactViews/Tools/DiffTool/DiffTool.tsx b/lib/ReactViews/Tools/DiffTool/DiffTool.tsx index e99e5c707e2..cddffb0d93e 100644 --- a/lib/ReactViews/Tools/DiffTool/DiffTool.tsx +++ b/lib/ReactViews/Tools/DiffTool/DiffTool.tsx @@ -885,6 +885,7 @@ const AreaFilterSelection = (props: { t: TFunction; location?: LatLonHeight; isPickingNewLocation: boolean; + theme?: any; }) => { const { t, location, isPickingNewLocation } = props; let locationText = "-"; diff --git a/lib/ReactViews/Tools/PedestrianMode/MovementControls.tsx b/lib/ReactViews/Tools/PedestrianMode/MovementControls.tsx index 97114e22fa9..c5743bdebab 100644 --- a/lib/ReactViews/Tools/PedestrianMode/MovementControls.tsx +++ b/lib/ReactViews/Tools/PedestrianMode/MovementControls.tsx @@ -75,10 +75,10 @@ const Title = styled(Box).attrs({ border-bottom: 1px solid #c0c0c0; `; -const MinimizeMaximizeButton = styled(Button).attrs((props) => ({ +const MinimizeMaximizeButton = styled(Button).attrs(({ maximized }) => ({ renderIcon: () => ( ) }))<{ maximized: boolean }>` diff --git a/lib/ReactViews/Tour/tour-helpers.ts b/lib/ReactViews/Tour/tour-helpers.ts index 8de3185b18a..253c3def15b 100644 --- a/lib/ReactViews/Tour/tour-helpers.ts +++ b/lib/ReactViews/Tour/tour-helpers.ts @@ -2,10 +2,7 @@ import { TourPoint } from "../../ReactViewModels/defaultTourPoints"; import isDefined from "../../Core/isDefined"; -import { - RelativePosition, - TOUR_WIDTH -} from "../../ReactViewModels/defaultTourPoints"; +import { RelativePosition } from "../../ReactViewModels/defaultTourPoints"; export { RelativePosition, TOUR_WIDTH diff --git a/lib/ReactViews/Workflow/WorkflowPanel.tsx b/lib/ReactViews/Workflow/WorkflowPanel.tsx index 6eff618dffa..a5ec57116cf 100644 --- a/lib/ReactViews/Workflow/WorkflowPanel.tsx +++ b/lib/ReactViews/Workflow/WorkflowPanel.tsx @@ -72,6 +72,7 @@ const WorkflowPanel: React.FC = observer((props) => { type ErrorBoundaryProps = { viewState: ViewState; + children: React.ReactNode; }; class ErrorBoundary extends React.Component { @@ -118,10 +119,6 @@ const TitleBar = styled.div` border-bottom: 1px solid ${(p) => p.theme.darkLighter}; `; -const FooterBar = styled(TitleBar)` - border: none; -`; - const Title = styled(Text).attrs({ textLight: true, bold: true diff --git a/lib/Styled/Box.tsx b/lib/Styled/Box.tsx index 0811606137f..95ceba56eeb 100644 --- a/lib/Styled/Box.tsx +++ b/lib/Styled/Box.tsx @@ -243,7 +243,7 @@ export const Box = styled.div` `; export const BoxSpan = styled(Box).attrs( - (props: { as?: React.ElementType | keyof JSX.IntrinsicElements }) => ({ + (_props: { as?: React.ElementType | keyof JSX.IntrinsicElements }) => ({ as: "span" }) )``; diff --git a/lib/Styled/Button.tsx b/lib/Styled/Button.tsx index d6a362424c4..948b8066cbe 100644 --- a/lib/Styled/Button.tsx +++ b/lib/Styled/Button.tsx @@ -165,6 +165,10 @@ export const RawButton = styled.button` export type ButtonProps = { renderIcon?: () => React.ReactChild; iconProps?: any; + primary?: boolean; + secondary?: boolean; + warning?: boolean; + textLight?: boolean; rightIcon?: boolean; textProps?: any; children?: React.ReactChildren; diff --git a/lib/Styled/Checkbox/Checkbox.tsx b/lib/Styled/Checkbox/Checkbox.tsx index 30cc5a6078b..0c91c514107 100644 --- a/lib/Styled/Checkbox/Checkbox.tsx +++ b/lib/Styled/Checkbox/Checkbox.tsx @@ -14,115 +14,113 @@ import CheckboxIcon from "./Elements/CheckboxIcon"; import HiddenCheckbox from "./Elements/HiddenCheckbox"; import { ICheckboxProps } from "./types"; -const Checkbox = memo( - forwardRef(function Checkbox( - props: ICheckboxProps, - ref: Ref - ) { - const { - isChecked: isCheckedProp, - isDisabled = false, - defaultChecked = false, - isIndeterminate = false, - onChange: onChangeProps, - title, - name, - value, - children, - textProps, - className, - ...rest - } = props; +const Checkbox = forwardRef(function Checkbox( + props: ICheckboxProps, + ref: Ref +) { + const { + isChecked: isCheckedProp, + isDisabled = false, + defaultChecked = false, + isIndeterminate = false, + onChange: onChangeProps, + title, + name, + value, + children, + textProps, + className, + ..._rest + } = props; - const [isCheckedState, setIsCheckedState] = useState( - isCheckedProp !== undefined ? isCheckedProp : defaultChecked - ); + const [isCheckedState, setIsCheckedState] = useState( + isCheckedProp !== undefined ? isCheckedProp : defaultChecked + ); - const onChange = useCallback( - (e: ChangeEvent) => { - setIsCheckedState(e.target.checked); - if (onChangeProps) { - onChangeProps(e); - } - }, - [onChangeProps] - ); + const onChange = useCallback( + (e: ChangeEvent) => { + setIsCheckedState(e.target.checked); + if (onChangeProps) { + onChangeProps(e); + } + }, + [onChangeProps] + ); - // Use isChecked from the state if it is controlled - const isChecked = - isCheckedProp === undefined ? isCheckedState : isCheckedProp; - const id = useUID(); + // Use isChecked from the state if it is controlled + const isChecked = + isCheckedProp === undefined ? isCheckedState : isCheckedProp; + const id = useUID(); - // Add props to children - const childrenWithProps = React.Children.map(children, (child) => { - // Checking isValidElement is the safe way and avoids a typescript - // error too. - if (React.isValidElement(child)) { - return React.cloneElement( - child as ReactElement<{ - isDisabled: boolean; - isChecked: boolean; - style: any; - }>, - { - isDisabled, - isChecked, - style: { fontSize: "inherit" } - } - ); - } - return child; - }); + // Add props to children + const childrenWithProps = React.Children.map(children, (child) => { + // Checking isValidElement is the safe way and avoids a typescript + // error too. + if (React.isValidElement(child)) { + return React.cloneElement( + child as ReactElement<{ + isDisabled: boolean; + isChecked: boolean; + style: any; + }>, + { + isDisabled, + isChecked, + style: { fontSize: "inherit" } + } + ); + } + return child; + }); - return ( - - - - - {childrenWithProps} - - ); - }) -); + `} + {...textProps} + > + + + + {childrenWithProps} + + ); +}); Checkbox.displayName = "Checkbox"; -export default Checkbox; +export default memo(Checkbox); diff --git a/lib/Table/MergedStyleMapLegend.ts b/lib/Table/MergedStyleMapLegend.ts index 4e9669c2b8b..40006a8e2ff 100644 --- a/lib/Table/MergedStyleMapLegend.ts +++ b/lib/Table/MergedStyleMapLegend.ts @@ -18,7 +18,7 @@ export class MergedStyleMapLegend extends LoadableStratum(LegendTraits) { makeObservable(this); } - duplicateLoadableStratum(newModel: BaseModel): this { + duplicateLoadableStratum(_newModel: BaseModel): this { return new MergedStyleMapLegend(this.legends) as this; } diff --git a/lib/Table/TableAutomaticStylesStratum.ts b/lib/Table/TableAutomaticStylesStratum.ts index 2833b0a5298..5428237cfb4 100644 --- a/lib/Table/TableAutomaticStylesStratum.ts +++ b/lib/Table/TableAutomaticStylesStratum.ts @@ -231,7 +231,7 @@ export default class TableAutomaticStylesStratum extends LoadableStratum( i < this.catalogItem.activeTableStyle.rowGroups.length; i++ ) { - const [rowGroupId, rowIds] = + const [_rowGroupId, rowIds] = this.catalogItem.activeTableStyle.rowGroups[i]; // Check if there is only 1 unique date in this rowGroup const dates = rowIds