Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint: use recommended configuration #7323

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
// https://github.com/typescript-eslint/typescript-eslint/blob/v6/packages/eslint-plugin/src/configs/recommended.ts
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier"
Expand Down Expand Up @@ -33,9 +34,11 @@
}
},
"rules": {
/* ban-types is split in ESLint v8:
https://typescript-eslint.io/rules/ban-types/ */
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/unified-signatures": "error",
"react-hooks/exhaustive-deps": "error",
"react/jsx-boolean-value": ["error", "never", { "always": [] }],
Expand Down Expand Up @@ -90,14 +93,18 @@

/* Variables */
"no-label-var": 1,
"no-unused-vars": [
"@typescript-eslint/no-unused-vars": [
"warn",
{
"vars": "local",
"args": "none"
"args": "all",
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],

"camelcase": [
0,
{
Expand All @@ -123,20 +130,6 @@
"@typescript-eslint/no-useless-constructor": "error",
// @TODO: revise these rules
"@typescript-eslint/consistent-type-assertions": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-loss-of-precision": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "error",
"react-hooks/exhaustive-deps": "error",
"react/prop-types": "warn"
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Core/ServerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ServerConfig.prototype.init = function (serverConfigUrl) {
that.config = config;
return that.config;
})
.catch(function (e) {
.catch(function (_e) {
console.error(
i18next.t("core.serverConfig.failedToGet", {
serverConfigUrl: that.serverConfigUrl
Expand Down
2 changes: 1 addition & 1 deletion lib/Core/autoUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Args {

export default function autoUpdate(updater: (...args: any[]) => void) {
return function (
target: any,
_target: any,
propertyName: string,
property: PropertyDescriptor
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Core/triggerResize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export default function triggerResize() {
try {
window.dispatchEvent(new Event("resize"));
} catch (e) {
} catch (_e) {
const evt = window.document.createEvent("UIEvents");
evt.initUIEvent("resize", true, false, window, 0);
window.dispatchEvent(evt);
Expand Down
4 changes: 2 additions & 2 deletions lib/Map/Geocoder/AddressGeocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var AddressGeocoder = function () {};
* @return {Promise} Promise that resolves to an BulkAddressGeocoderResult object.
*/
AddressGeocoder.prototype.bulkConvertAddresses = function (
tableStructure,
corsProxy
tableStructure, // eslint-disable-line @typescript-eslint/no-unused-vars
corsProxy // eslint-disable-line @typescript-eslint/no-unused-vars
) {
throw new DeveloperError(i18next.t("map.addressGeocoder.devError"));
};
Expand Down
6 changes: 3 additions & 3 deletions lib/Map/ImageryProvider/ArcGisImageServerImageryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ export default class ArcGisImageServerImageryProvider {
}

async pickFeatures(
x: number,
y: number,
level: number,
_x: number,
_y: number,
_level: number,
longitude: number,
latitude: number
): Promise<ImageryLayerFeatureInfo[]> {
Expand Down
6 changes: 3 additions & 3 deletions lib/Map/ImageryProvider/ProtomapsImageryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ export default class ProtomapsImageryProvider
}

async pickFeatures(
x: number,
y: number,
_x: number,
_y: number,
level: number,
longitude: number,
latitude: number
Expand Down Expand Up @@ -716,7 +716,7 @@ export default class ProtomapsImageryProvider
}),
minzoom: 0,
maxzoom: Infinity,
filter: (zoom, feature) =>
filter: (_zoom, feature) =>
feature.props?.[featureProp!] === featureId
}
]
Expand Down
2 changes: 1 addition & 1 deletion lib/Map/Region/RegionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export default class RegionProvider {
];
}
await Promise.all(this._loadRegionIDsPromises);
} catch (e) {
} catch (_e) {
console.log(`Failed to load region IDS for ${this.regionType}`);
} finally {
runInAction(() => (this._loaded = true));
Expand Down
4 changes: 2 additions & 2 deletions lib/ModelMixins/FeatureInfoUrlTemplateMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function FeatureInfoUrlTemplateMixin<T extends AbstractConstructor<BaseType>>(
: undefined
)
);
} catch (e) {
} catch (_e) {
if (!feature.properties) {
feature.properties = new PropertyBag();
}
Expand Down Expand Up @@ -163,7 +163,7 @@ function FeatureInfoUrlTemplateMixin<T extends AbstractConstructor<BaseType>>(
? catalogItem.showStringIfPropertyValueIsNull
: undefined
);
} catch (e) {
} catch (_e) {
if (!feature.properties) {
feature.properties = {};
}
Expand Down
8 changes: 4 additions & 4 deletions lib/ModelMixins/GeojsonMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,14 @@ function GeoJsonMixin<T extends AbstractConstructor<BaseType>>(Base: T) {
this.useOutlineColorForLineFeatures;

// Style function
const getColorValue = (z: number, f?: ProtomapsFeature) => {
const getColorValue = (_z: number, f?: ProtomapsFeature) => {
const rowId = f?.props[FEATURE_ID_PROP];
return colorMap
.mapValueToColor(isJsonNumber(rowId) ? rows?.[rowId] : null)
.toCssColorString();
};

const getOutlineWidthValue = (z: number, f?: ProtomapsFeature) => {
const getOutlineWidthValue = (_z: number, f?: ProtomapsFeature) => {
const rowId = f?.props[FEATURE_ID_PROP];
return (
(isConstantStyleMap(outlineStyleMap)
Expand All @@ -754,7 +754,7 @@ function GeoJsonMixin<T extends AbstractConstructor<BaseType>>(Base: T) {
);
};

const getOutlineColorValue = (z: number, f?: ProtomapsFeature) => {
const getOutlineColorValue = (_z: number, f?: ProtomapsFeature) => {
const rowId = f?.props[FEATURE_ID_PROP];
return (
(isConstantStyleMap(outlineStyleMap)
Expand All @@ -765,7 +765,7 @@ function GeoJsonMixin<T extends AbstractConstructor<BaseType>>(Base: T) {
};

// Filter features by time if applicable
const showFeature = (z: number, f?: ProtomapsFeature) =>
const showFeature = (_z: number, f?: ProtomapsFeature) =>
!currentTimeRows ||
(isJsonNumber(f?.props[FEATURE_ID_PROP]) &&
currentTimeRows.includes(f?.props[FEATURE_ID_PROP] as number));
Expand Down
4 changes: 2 additions & 2 deletions lib/ModelMixins/TableMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function TableMixin<T extends AbstractConstructor<BaseType>>(Base: T) {

if (rowsToRemove.size > 0) {
return dataColumnMajor.map((col) =>
col.filter((cell, idx) => !rowsToRemove.has(idx))
col.filter((_cell, idx) => !rowsToRemove.has(idx))
);
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ function TableMixin<T extends AbstractConstructor<BaseType>>(Base: T) {
if (isDefined(this.dataColumnMajor)) {
// I am assuming all columns have the same length -> so use first column
const csvString = this.dataColumnMajor[0]
.map((row, rowIndex) =>
.map((_row, rowIndex) =>
this.dataColumnMajor!.map((col) => col[rowIndex]).join(",")
)
.join("\n");
Expand Down
4 changes: 2 additions & 2 deletions lib/Models/Catalog/CatalogFunctions/YDYRCatalogFunctionJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export default class YDYRCatalogFunctionJob extends CatalogFunctionJobMixin(
data.values.map((val, idx) => (val === null ? idx : undefined))
);

data.ids = data.ids.filter((id, idx) => !invalidRows.includes(idx));
data.ids = data.ids.filter((_id, idx) => !invalidRows.includes(idx));
data.values = data.values.filter(
(value, idx) => !invalidRows.includes(idx)
(_value, idx) => !invalidRows.includes(idx)
);

const params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class MapboxVectorTileCatalogItem extends MappableMixin(
minzoom: this.minimumZoom,
maxzoom: this.maximumZoom,
// Only apply polygon/fill symbolizer to polygon features (otherwise it will also apply to line features)
filter: (z, f) => f.geomType === GeomType.Polygon
filter: (_z, f) => f.geomType === GeomType.Polygon
});
}
if (this.lineColor) {
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 @@ -602,7 +602,7 @@ export default class OpenDataSoftCatalogItem
new Array(Math.ceil(recordsToFetch / 100))
.fill(0)
.map(
async (v, index) =>
async (_v, index) =>
(await this.apiClient.get(q.offset(index * 100))).records ?? []
)
)
Expand Down
4 changes: 2 additions & 2 deletions lib/Models/Catalog/CatalogReferences/MagdaReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ export default class MagdaReference extends AccessControlMixin(
private static createMemberFromTerriaAspect(
terria: Terria,
sourceReference: BaseModel | undefined,
magdaUri: uri.URI | undefined,
_magdaUri: uri.URI | undefined,
id: string | undefined,
record: JsonObject,
terriaAspect: JsonObject,
Expand Down Expand Up @@ -634,7 +634,7 @@ export default class MagdaReference extends AccessControlMixin(
private static createMemberFromDistributionFormat(
terria: Terria,
sourceReference: BaseModel | undefined,
magdaUri: uri.URI | undefined,
_magdaUri: uri.URI | undefined,
id: string | undefined,
datasetRecord: JsonObject,
distributionRecord: JsonObject,
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/Ckan/CkanCatalogGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class CkanServerStratum extends LoadableStratum(CkanCatalogGroupTraits) {
@action
addCatalogItemToCatalogGroup(
catalogItem: any,
dataset: CkanDataset,
_dataset: CkanDataset,
groupId: string
) {
const group: CatalogGroup | undefined =
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/Esri/ArcGisPortalCatalogGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class ArcGisPortalStratum extends LoadableStratum(
@action
addCatalogItemToCatalogGroup(
catalogItem: any,
dataset: ArcGisItem,
_dataset: ArcGisItem,
groupId: string
) {
const group: CatalogGroup | undefined =
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/Esri/ArcGisPortalItemReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ async function loadAdditionalPortalInfo(portalItem: ArcGisPortalItemReference) {
proxyCatalogItemUrl(portalItem, uri.toString(), portalItem.cacheDuration)
);
return response;
} catch (err) {
} catch (_err) {
return undefined;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/Ows/WebFeatureServiceCapabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default class WebFeatureServiceCapabilities {
readonly featureTypes: FeatureType[];
readonly srsNames: SrsNamesForLayer[] | undefined;

private constructor(xml: XMLDocument, json: any) {
private constructor(_xml: XMLDocument, json: any) {
this.service = getService(json);
this.outputTypes = getOutputTypes(json);
this.featureTypes = getFeatureTypes(json);
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/createCatalogItemFromFileOrUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import createUrlReferenceFromUrl from "./CatalogReferences/createUrlReferenceFro

export default function createCatalogItemFromFileOrUrl(
terria: Terria,
viewState: ViewState,
_viewState: ViewState,
fileOrUrl: File | string,
dataType?: string
): Promise<BaseModel | undefined> {
Expand Down
8 changes: 4 additions & 4 deletions lib/Models/Cesium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export default class Cesium extends GlobeOrMap {
creditDisplay.destroy = () => {
try {
creditDisplayOldDestroy();
} catch (err) {
} catch (_err) {
/* TODO: handle Error */
}
};
Expand Down Expand Up @@ -552,7 +552,7 @@ export default class Cesium extends GlobeOrMap {
private previousRenderError: string | undefined;

/** Show error message to user if Cesium stops rendering. */
private onRenderError(scene: Scene, error: unknown) {
private onRenderError(_scene: Scene, error: unknown) {
// This function can be called many times with the same error
// So we do a rudimentary check to only show the error message once
// - by comparing error.toString() to this.previousRenderError
Expand Down Expand Up @@ -767,7 +767,7 @@ export default class Cesium extends GlobeOrMap {
const fnArray = this._3dTilesetEventListeners.get(primitive);
try {
fnArray?.forEach((fn) => fn()); // Run the remover functions
} catch (error) {
} catch (_error) {
/* TODO: handle error */
}

Expand Down Expand Up @@ -1799,7 +1799,7 @@ function zoomToDataSource(
false,
boundingSphereScratch
);
} catch (e) {
} catch (_e) {
/* TODO: handle error */
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Models/Definition/CreateModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default function CreateModel<T extends TraitsConstructor<ModelTraits>>(
this.terria,
sourceReference
);
} catch (e) {
} catch (_e) {
throw TerriaError.from(`Failed to create model \`"${newId}"\``);
}

Expand Down Expand Up @@ -191,7 +191,7 @@ export default function CreateModel<T extends TraitsConstructor<ModelTraits>>(
let maxIndex = -1;
this.strata.forEach((s) =>
(s[traitId] as Array<unknown> | undefined)?.forEach(
(e, idx) => (maxIndex = idx > maxIndex ? idx : maxIndex)
(_e, idx) => (maxIndex = idx > maxIndex ? idx : maxIndex)
)
);

Expand Down
4 changes: 2 additions & 2 deletions lib/Models/FunctionParameters/BooleanParameterGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ BooleanParameterGroup.defaultUpdaters.OneForAll = function (
functionParameter,
json,
propertyName,
options
_options
) {
functionParameter.OneForAll = makeBooleanEditorFromJson(
json[propertyName],
Expand All @@ -118,7 +118,7 @@ BooleanParameterGroup.defaultUpdaters.ParameterList = function (
functionParameter,
json,
propertyName,
options
_options
) {
functionParameter.ParameterList = makeBooleanEditorArrayFromJson(
json[propertyName],
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 @@ -47,7 +47,7 @@ export default class InfoParameter extends FunctionParameter<string> {
return this._value;
}

setValue(strataId: string, v: string) {
setValue(_strataId: string, v: string) {
this._value = v;
}

Expand Down
Loading
Loading