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

NOMERGE Add/Replace ts-ignore with ts-expect-error #647

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
46 changes: 22 additions & 24 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

module.exports = {

"parser": "@typescript-eslint/parser",
plugins: ['prettier', 'babel', 'import', "@typescript-eslint", 'react', "react-hooks"],
parser: '@typescript-eslint/parser',
plugins: ['prettier', 'babel', 'import', '@typescript-eslint', 'react', 'react-hooks'],
extends: [
'eslint-config-uber-jsx',
'eslint-config-uber-es2015',
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
'prettier'
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'prettier',
],
rules: {
'callback-return': 'off',
Expand All @@ -25,7 +23,7 @@ module.exports = {

/* This is needed for class property function declarations */
'no-invalid-this': 'off',
'babel/no-invalid-this': 'error',
'babel/no-invalid-this': 'warn',

/* Style guide */
'import/first': 'error',
Expand All @@ -36,14 +34,14 @@ module.exports = {
'import/extensions': 'off',

// Those are rules for typescript migration
"@typescript-eslint/interface-name-prefix": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"no-inline-comments": 0,
'@typescript-eslint/interface-name-prefix': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'no-inline-comments': 0,
// TODO: Please remove these rules and fix eslint error when possible
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/camelcase": 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/camelcase': 0,

/* Ignore rules conflicting with prettier */
'react/jsx-wrap-multilines': 'off',
Expand All @@ -53,19 +51,19 @@ module.exports = {
/* Use the 'query-string' module instead */
'no-restricted-imports': ['error', 'querystring'],

'no-unused-vars': ['error', { args: 'none', 'ignoreRestSiblings': true }]
'no-unused-vars': ['error', { args: 'none', ignoreRestSiblings: true }],
},
globals: {
Buffer: true,
window: true
window: true,
},
env: {
// Support global Jest variables (test, expect, etc.)
jest: true
jest: true,
},
settings: {
react: {
version: 'detect',
},
},
"settings": {
"react": {
"version": "detect"
}
}
};
12 changes: 6 additions & 6 deletions examples/advanced/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"styled-components": "^4.3.2"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-export-default-from": "^7.8.3",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "7.9.0",
"@babel/core": "^7.15.8",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@babel/plugin-proposal-export-default-from": "7.14.5",
"@babel/preset-env": "7.15.8",
"@babel/preset-react": "7.14.5",
"@babel/preset-typescript": "7.15.0",
"babel-loader": "^8.1.0",
"html-webpack-plugin": "^3.2.0",
"url-loader": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-map-gl-draw/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function getEditHandleStyle({ feature, shape, index, state }) {

switch (shape) {
case 'circle':
//@ts-ignore
// @ts-ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not expect-error here?

style.r = CIRCLE_RADIUS;
break;
case 'rect':
Expand Down
6 changes: 3 additions & 3 deletions modules/edit-modes/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Utils
import * as utils from './utils';

export type { EditMode } from './lib/edit-mode';
export type { GeoJsonEditModeType } from './lib/geojson-edit-mode';
export type { GeoJsonEditModeConstructor } from './lib/geojson-edit-mode';
Expand Down Expand Up @@ -82,7 +85,4 @@ export type {
FeatureCollection,
AnyGeoJson,
} from './geojson-types';

// Utils
import * as utils from './utils';
export { utils };
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class DrawEllipseByBoundingBoxMode extends TwoClickPolygonMode {
const xSemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[1])), 0.001);
const ySemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[3])), 0.001);

// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type 'Feature<Polygon, { [name: string]: any; }>' ... Remove this comment to see the full error message
return ellipse(centerCoordinates, xSemiAxis, ySemiAxis);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class DrawEllipseUsingThreePointsMode extends ThreeClickPolygonMode {
const xSemiAxis = Math.max(distance(centerCoordinates, point(coord3)), 0.001);
const ySemiAxis = Math.max(distance(coord1, coord2), 0.001) / 2;
const options = { angle: bearing(coord1, coord2) };
// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type 'Feature<Polygon, { [name: string]: any; }>' ... Remove this comment to see the full error message
return ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options);
}
}
2 changes: 1 addition & 1 deletion modules/edit-modes/src/lib/draw-line-string-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class DrawLineStringMode extends GeoJsonEditMode {
}));

guides.features.push(...editHandles);
// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ type: string; features: any[]; }' is not a... Remove this comment to see the full error message
return guides;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/edit-modes/src/lib/draw-point-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class DrawPointMode extends GeoJsonEditMode {
type: 'Point',
coordinates: mapCoords,
};
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '{ type: string; coordinates: Pos... Remove this comment to see the full error message
props.onEdit(this.getAddFeatureAction(geometry, props.data));
}

Expand Down
4 changes: 2 additions & 2 deletions modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {
this.addClickSequence(event);
const clickSequence = this.getClickSequence();
// @ts-ignore
// @ts-expect-error ts-migrate(2339) FIXME: Property 'cancel' does not exist on type 'Dragging... Remove this comment to see the full error message
if (this.handleDraggingThrottled && this.handleDraggingThrottled.cancel) {
// @ts-ignore
// @ts-expect-error ts-migrate(2339) FIXME: Property 'cancel' does not exist on type 'Dragging... Remove this comment to see the full error message
this.handleDraggingThrottled.cancel();
}

Expand Down
2 changes: 1 addition & 1 deletion modules/edit-modes/src/lib/draw-polygon-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class DrawPolygonMode extends GeoJsonEditMode {
}));

guides.features.push(...editHandles);
// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ type: string; features: any[]; }' is not a... Remove this comment to see the full error message
return guides;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/edit-modes/src/lib/draw-rectangle-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class DrawRectangleMode extends TwoClickPolygonMode {
rectangle.properties = rectangle.properties || {};
rectangle.properties.shape = 'Rectangle';

// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type 'Feature<Polygon, { [name: string]: any; }>' ... Remove this comment to see the full error message
return rectangle;
}
}
2 changes: 1 addition & 1 deletion modules/edit-modes/src/lib/draw-square-from-center-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class DrawSquareFromCenterMode extends TwoClickPolygonMode {
square.properties = square.properties || {};
square.properties.shape = 'Square';

// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type 'Feature<Polygon, { [name: string]: any; }>' ... Remove this comment to see the full error message
return square;
}
}
4 changes: 2 additions & 2 deletions modules/edit-modes/src/lib/elevation-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export class ElevationMode extends ModifyMode {
handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {
const editHandle = getPickedEditHandle(event.pointerDownPicks);
const position = editHandle ? editHandle.geometry.coordinates : event.mapCoords;
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Record<string, any>' is not assi... Remove this comment to see the full error message
super.handlePointerMove(this.makeElevatedEvent(event, position, props), props);
}

handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {
const editHandle = getPickedEditHandle(event.picks);
const position = editHandle ? editHandle.geometry.coordinates : event.mapCoords;
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Record<string, any>' is not assi... Remove this comment to see the full error message
super.handleStopDragging(this.makeElevatedEvent(event, position, props), props);
}

Expand Down
4 changes: 2 additions & 2 deletions modules/edit-modes/src/lib/extend-line-string-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ExtendLineStringMode extends GeoJsonEditMode {
const selectedLineString = this.getSingleSelectedLineString(props);
if (!selectedLineString) {
// nothing to do
// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ type: string; features: any[]; }' is not a... Remove this comment to see the full error message
return guides;
}

Expand All @@ -79,7 +79,7 @@ export class ExtendLineStringMode extends GeoJsonEditMode {
coordinates: [startPosition, mapCoords],
},
});
// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ type: string; features: any[]; }' is not a... Remove this comment to see the full error message
return guides;
}

Expand Down
10 changes: 5 additions & 5 deletions modules/edit-modes/src/lib/geojson-edit-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
getTentativeGuide(props: ModeProps<FeatureCollection>): TentativeFeature | null | undefined {
const guides = this.getGuides(props);

// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type 'Readonly<GuideFeature>' is not assignable to... Remove this comment to see the full error message
return guides.features.find((f) => f.properties && f.properties.guideType === 'tentative');
}

Expand All @@ -105,7 +105,7 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature

const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';
if (isPolygonal) {
// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type 'AllGeoJSON' is not assignable to type 'Featu... Remove this comment to see the full error message
return rewind(feature);
}

Expand Down Expand Up @@ -202,10 +202,10 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
if (modeConfig.booleanOperation === 'union') {
updatedGeometry = turfUnion(selectedFeature, feature);
} else if (modeConfig.booleanOperation === 'difference') {
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Feature' is not assignable to pa... Remove this comment to see the full error message
updatedGeometry = turfDifference(selectedFeature, feature);
} else if (modeConfig.booleanOperation === 'intersection') {
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Feature' is not assignable to pa... Remove this comment to see the full error message
updatedGeometry = turfIntersect(selectedFeature, feature);
} else {
// eslint-disable-next-line no-console,no-undef
Expand Down Expand Up @@ -277,6 +277,6 @@ export function getIntermediatePosition(position1: Position, position2: Position
(position1[0] + position2[0]) / 2.0,
(position1[1] + position2[1]) / 2.0,
];
// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type 'number[]' is not assignable to type 'Positio... Remove this comment to see the full error message
return intermediatePosition;
}
4 changes: 1 addition & 3 deletions modules/edit-modes/src/lib/measure-angle-mode.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import turfBearing from '@turf/bearing';
// @ts-ignore
import turfCenter from '@turf/center';
// @ts-ignore
import memoize from '../memoize';

import { ClickEvent, PointerMoveEvent, Tooltip, ModeProps, GuideFeatureCollection } from '../types';
Expand Down Expand Up @@ -30,7 +28,7 @@ export class MeasureAngleMode extends GeoJsonEditMode {
text = formatTooltip(angle);
} else {
// By default, round to 2 decimal places and append units
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'number' is not assignable to par... Remove this comment to see the full error message
text = `${parseFloat(angle).toFixed(2)} ${units}`;
}

Expand Down
3 changes: 1 addition & 2 deletions modules/edit-modes/src/lib/measure-area-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export class MeasureAreaMode extends DrawPolygonMode {
handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {
const propsWithoutEdit = {
...props,
// @ts-ignore
onEdit: () => {},
};

Expand All @@ -33,7 +32,7 @@ export class MeasureAreaMode extends DrawPolygonMode {
text = formatTooltip(area);
} else {
// By default, round to 2 decimal places and append units
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'number' is not assignable to par... Remove this comment to see the full error message
text = `${parseFloat(area).toFixed(2)} ${units}`;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/edit-modes/src/lib/measure-distance-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class MeasureDistanceMode extends GeoJsonEditMode {
}));

guides.features.push(...editHandles);
// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ type: string; features: any[]; }' is not a... Remove this comment to see the full error message
return guides;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/edit-modes/src/lib/modify-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class ModifyMode extends GeoJsonEditMode {
(lineString, prefix) => {
const lineStringFeature = toLineString(lineString);
const candidateIntermediatePoint = this.getNearestPoint(
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Feature<LineString, { [name: str... Remove this comment to see the full error message
lineStringFeature,
referencePoint,
props.modeConfig && props.modeConfig.viewport
Expand Down
2 changes: 1 addition & 1 deletion modules/edit-modes/src/lib/resize-circle-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class ResizeCircleMode extends GeoJsonEditMode {
(lineString, prefix) => {
const lineStringFeature = toLineString(lineString);
const candidateIntermediatePoint = this.getNearestPoint(
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Feature<LineString, { [name: str... Remove this comment to see the full error message
lineStringFeature,
referencePoint,
props.modeConfig && props.modeConfig.viewport
Expand Down
17 changes: 6 additions & 11 deletions modules/edit-modes/src/lib/rotate-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export class RotateMode extends GeoJsonEditMode {
_isSinglePointGeometrySelected = (geometry: FeatureCollection | null | undefined): boolean => {
const { features } = geometry || {};
if (Array.isArray(features) && features.length === 1) {
// @ts-ignore
const { type } = getGeom(features[0]);
const { type } = getGeom<any>(features[0]);
return type === 'Point';
}
return false;
Expand Down Expand Up @@ -61,7 +60,7 @@ export class RotateMode extends GeoJsonEditMode {

coordEach(boundingBox, (coord) => {
if (previousCoord) {
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'number[]' is not assignable to p... Remove this comment to see the full error message
const edgeMidpoint = getIntermediatePosition(coord, previousCoord);
if (!topEdgeMidpointCoords || edgeMidpoint[1] > topEdgeMidpointCoords[1]) {
// Get the top edge midpoint of the enveloping box
Expand All @@ -86,15 +85,11 @@ export class RotateMode extends GeoJsonEditMode {
guideType: 'editHandle',
editHandleType: 'rotate',
});
// @ts-ignore
return featureCollection([
// @ts-ignore
polygonToLine(boundingBox),
// @ts-ignore
polygonToLine(boundingBox) as any,
rotateHandle,
// @ts-ignore
lineFromEnvelopeToRotateHandle,
]);
]) as any;
}

handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {
Expand Down Expand Up @@ -175,9 +170,9 @@ export class RotateMode extends GeoJsonEditMode {

const centroid = turfCentroid(this._geometryBeingRotated);
const angle = getRotationAngle(centroid, startDragPoint, currentPoint);
// @ts-ignore
// @ts-expect-error ts-migrate(2322) FIXME: Type 'AllGeoJSON' is not assignable to type 'Featu... Remove this comment to see the full error message
const rotatedFeatures: FeatureCollection = turfTransformRotate(
// @ts-ignore
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'FeatureCollection' is not assign... Remove this comment to see the full error message
this._geometryBeingRotated,
angle,
{
Expand Down
Loading