Skip to content

Commit

Permalink
Fix lint issues in lib/*
Browse files Browse the repository at this point in the history
Turn off exhaustive-deps as fixing these are likely to have side effects
  • Loading branch information
ljowen committed Sep 17, 2024
1 parent d0ca149 commit 72343c7
Show file tree
Hide file tree
Showing 58 changed files with 192 additions and 228 deletions.
8 changes: 5 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
},
"overrides": [
{
"files": ["*.ts", "**/*.tsx"],
"files": ["**/*.ts", "**/*.tsx"],
"rules": {
// @TODO: revise these rules
"@typescript-eslint/consistent-type-assertions": "error",
Expand All @@ -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"
}
}
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### next release (8.7.7)

- Fix remaining lint warnings
- [The next improvement]

#### 8.7.6 - 2024-08-22
Expand Down
14 changes: 7 additions & 7 deletions lib/Core/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,10 +33,10 @@ const transitionEnd = (element: Element | null) =>
});

const animationTimeout = (
timeoutID: ReturnType<typeof setTimeout> | undefined
_timeoutID: ReturnType<typeof setTimeout> | undefined
) =>
new Promise<void>((_, reject) => {
timeoutID = setTimeout(() => {
_timeoutID = setTimeout(() => {
reject("Animation timed out. Did you forget to animate the element?");
}, ANIMATION_TIMEOUT);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/Core/autoUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/Core/createColorForIdTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions lib/Map/Cesium/CesiumRenderLoopPauser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/Map/Leaflet/ImageryProviderLeafletTileLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/Map/SizeMap/ConstantPointSizeMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
4 changes: 2 additions & 2 deletions lib/ModelMixins/GltfMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function GltfMixin<T extends AbstractConstructor<BaseType>>(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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/ModelMixins/TimeFilterMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function TimeFilterMixin<T extends AbstractConstructor<BaseType>>(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
)
);
Expand Down
22 changes: 0 additions & 22 deletions lib/Models/BoxDrawing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*/
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/CatalogItems/OpenDataSoftCatalogItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class CatalogIndexReference extends ReferenceMixin(
}

protected async forceLoadReference(
previousTarget: BaseModel | undefined
_previousTarget: BaseModel | undefined
): Promise<BaseModel | undefined> {
if (this.uniqueId === undefined) {
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/CatalogReferences/SplitItemReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class SplitItemReference extends ReferenceMixin(
}

protected async forceLoadReference(
previousTarget: BaseModel | undefined
_previousTarget: BaseModel | undefined
): Promise<BaseModel | undefined> {
if (this.splitSourceItemId === undefined || this.uniqueId === undefined) {
throw new TerriaError({
Expand Down
6 changes: 3 additions & 3 deletions lib/Models/Catalog/CatalogReferences/ThreddsItemReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -109,7 +109,7 @@ export default class ThreddsItemReference extends UrlMixin(
}

async forceLoadReference(
previousTarget: BaseModel | undefined
_previousTarget: BaseModel | undefined
): Promise<BaseModel | undefined> {
this.setThreddsStrata(this);

Expand All @@ -121,7 +121,7 @@ export default class ThreddsItemReference extends UrlMixin(
);
if (model === undefined) return;
this.setThreddsStrata(model);
previousTarget = model;
_previousTarget = model;
return model;
}
}
2 changes: 1 addition & 1 deletion lib/Models/Catalog/CatalogReferences/UrlReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class UrlReference extends UrlMixin(
}

protected forceLoadReference(
previousTarget: BaseModel | undefined
_previousTarget: BaseModel | undefined
): Promise<BaseModel | undefined> {
if (this.url === undefined || this.uniqueId === undefined) {
return Promise.resolve(undefined);
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/Ckan/CkanDefaultFormatsStratum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Models/Catalog/Ckan/CkanItemReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export default class CkanItemReference extends UrlMixin(
}

async forceLoadReference(
previousTarget: BaseModel | undefined
_previousTarget: BaseModel | undefined
): Promise<BaseModel | undefined> {
await this.setCkanStrata(this);

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions lib/Models/Catalog/Esri/ArcGisCatalogGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ import ArcGisMapServerCatalogGroup, {
MapServerStratum
} from "./ArcGisMapServerCatalogGroup";

interface DocumentInfo {
Title?: string;
Author?: string;
}

interface Service {
name: string;
type: string;
Expand Down
11 changes: 3 additions & 8 deletions lib/Models/Catalog/Esri/ArcGisPortalItemReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -309,7 +309,7 @@ export default class ArcGisPortalItemReference extends AccessControlMixin(
}

async forceLoadReference(
previousTarget: BaseModel | undefined
_previousTarget: BaseModel | undefined
): Promise<BaseModel | undefined> {
// So when we first crawl we'll get this far
await this.setArcgisStrata(this);
Expand Down Expand Up @@ -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);
Expand All @@ -372,11 +372,6 @@ interface ArcGisItemInfo {
error?: JsonObject;
}

interface ArcGisItemWithFormat {
supportedFormat: PreparedSupportedFormat;
arcgisItem: ArcGisItem;
}

interface PreparedSupportedFormat {
formatRegex: RegExp | undefined;
urlRegex: RegExp | undefined;
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Definition/FlattenedFromTraits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type SingleTrait<TTrait> = If<
TTrait extends ModelTraits ? FlattenedFromTraits<TTrait> : never
>;

type ArrayTrait<TTrait, TElement> = ReadonlyArray<SingleTrait<TElement>>;
type ArrayTrait<_TTrait, TElement> = ReadonlyArray<SingleTrait<TElement>>;

/**
* Transforms a {@link ModelTraits} class into a type usable as a flattened view of multiple strata.
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Definition/LoadableStratum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."
);
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Definition/ModelPropertiesFromTraits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type SingleTrait<TTrait> = If<
TTrait,
TTrait extends ModelTraits ? Model<TTrait> : never
>;
type ArrayTrait<TTrait, TElement> = ReadonlyArray<SingleTrait<TElement>>;
type ArrayTrait<_TTrait, TElement> = ReadonlyArray<SingleTrait<TElement>>;

/**
* Transforms a {@link ModelTraits} class into a type representative of the traits properties exposed on
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Definition/StratumFromTraits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type SingleTrait<TTrait> = If<
TTrait extends ModelTraits ? StratumFromTraits<TTrait> : never
>;

type ArrayTrait<TTrait, TElement> = Array<SingleTrait<TElement>>;
type ArrayTrait<_TTrait, TElement> = Array<SingleTrait<TElement>>;

/**
* Transforms a {@link ModelTraits} class into a type usable as a stratum.
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/FunctionParameters/InfoParameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class InfoParameter extends FunctionParameter<string> {
this._value = v;
}

clearValue(strataId: string) {
clearValue(_strataId: string) {
this._value = undefined;
}
}
2 changes: 1 addition & 1 deletion lib/Models/Leaflet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/LocationMarkerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Loading

0 comments on commit 72343c7

Please sign in to comment.