Skip to content

Commit 8555031

Browse files
authored
Forbid unnecessary type assertions (#933)
* Forbid unnecessary type assertions * Autofix lint errors and format
1 parent 5417a83 commit 8555031

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
},
1212
plugins: ["@typescript-eslint", "import"],
1313
rules: {
14+
"@typescript-eslint/ban-ts-comment": "warn",
1415
"@typescript-eslint/naming-convention": [
1516
"error",
1617
{
@@ -31,7 +32,7 @@ module.exports = {
3132
],
3233
"@typescript-eslint/no-explicit-any": "off",
3334
"@typescript-eslint/no-namespace": "off",
34-
"@typescript-eslint/ban-ts-comment": "warn",
35+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
3536
"@typescript-eslint/no-use-before-define": "off",
3637
"@typescript-eslint/quotes": [
3738
"error",

packages/base/src/classificationModes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ export namespace GeoTiffClassifications {
347347
if (numValuesInCurrentBin + 1 < valuesPerBin) {
348348
numValuesInCurrentBin++;
349349
} else {
350-
breaks.push(bandSortedValues[i] as number);
350+
breaks.push(bandSortedValues[i]);
351351
numValuesInCurrentBin = 0;
352352
}
353353
}

packages/base/src/dialogs/symbology/classificationModes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ export namespace GeoTiffClassifications {
347347
if (numValuesInCurrentBin + 1 < valuesPerBin) {
348348
numValuesInCurrentBin++;
349349
} else {
350-
breaks.push(bandSortedValues[i] as number);
350+
breaks.push(bandSortedValues[i]);
351351
numValuesInCurrentBin = 0;
352352
}
353353
}

packages/base/src/mainview/mainView.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ export class MainView extends React.Component<IProps, IStates> {
244244
const options = this._model.getOptions();
245245
const center =
246246
options.longitude !== undefined && options.latitude !== undefined
247-
? fromLonLat([options.longitude!, options.latitude!])
247+
? fromLonLat([options.longitude, options.latitude])
248248
: [0, 0];
249-
const zoom = options.zoom !== undefined ? options.zoom! : 1;
249+
const zoom = options.zoom !== undefined ? options.zoom : 1;
250250

251251
await this.generateMap(center, zoom);
252252
this.addContextMenu();
@@ -871,7 +871,7 @@ export class MainView extends React.Component<IProps, IStates> {
871871
// create updated source
872872
await this.addSource(id, source);
873873
// change source of target layer
874-
(mapLayer as Layer).setSource(this._sources[id]);
874+
mapLayer.setSource(this._sources[id]);
875875
}
876876

877877
/**
@@ -1957,7 +1957,7 @@ export class MainView extends React.Component<IProps, IStates> {
19571957
return;
19581958
}
19591959
} else {
1960-
jsonData = data as IAnnotation;
1960+
jsonData = data;
19611961
}
19621962

19631963
newState[key] = jsonData;
@@ -2004,7 +2004,7 @@ export class MainView extends React.Component<IProps, IStates> {
20042004

20052005
// The id is a layer
20062006
let extent;
2007-
const layer = this.getLayer(id) as Layer;
2007+
const layer = this.getLayer(id);
20082008
const source = layer?.getSource();
20092009

20102010
if (source instanceof VectorSource) {

packages/base/src/tools.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ export const loadFile = async (fileInfo: {
663663
if (typeof file.content === 'string') {
664664
const { toGeoJson } = await import('geoparquet');
665665

666-
const arrayBuffer = await stringToArrayBuffer(file.content as string);
666+
const arrayBuffer = await stringToArrayBuffer(file.content);
667667

668668
return await toGeoJson({ file: arrayBuffer, compressors });
669669
} else {
@@ -959,7 +959,7 @@ export async function getGeoJSONDataFromLayerSource(
959959
): Promise<string | null> {
960960
const vectorSourceTypes: SourceType[] = ['GeoJSONSource', 'ShapefileSource'];
961961

962-
if (!vectorSourceTypes.includes(source.type as SourceType)) {
962+
if (!vectorSourceTypes.includes(source.type)) {
963963
console.error(
964964
`Invalid source type '${source.type}'. Expected one of: ${vectorSourceTypes.join(', ')}`,
965965
);

packages/schema/src/doc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ export class JupyterGISDoc
347347
needEmit = true;
348348
}
349349
changes.push({
350-
id: key as string,
350+
id: key,
351351
oldValue: change.oldValue,
352352
newValue: JSONExt.deepCopy(event.target.toJSON()[key]),
353353
});
@@ -376,7 +376,7 @@ export class JupyterGISDoc
376376
needEmit = true;
377377
}
378378
changes.push({
379-
id: key as string,
379+
id: key,
380380
newValue: JSONExt.deepCopy(event.target.toJSON()[key]),
381381
});
382382
});

python/jupytergis_lab/src/notebookrenderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export const notebookRendererPlugin: JupyterFrontEndPlugin<void> = {
209209
);
210210
}
211211

212-
const sharedModel = drive!.sharedModelFactory.createNew({
212+
const sharedModel = drive.sharedModelFactory.createNew({
213213
path: localPath,
214214
format: fileFormat,
215215
contentType,

0 commit comments

Comments
 (0)