Make code prettier

This updates ESLint and our shared eslint-config-openlayers to use Prettier.  Most formatting changes were automatically applied with this:

    npm run lint -- --fix

A few manual changes were required:

 * In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
 * In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason.  While editing this, I reworked `ExampleBuilder` to be a class.
 * In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
Tim Schaub
2020-04-06 12:25:12 -06:00
parent 53b48baf62
commit 054af09032
790 changed files with 46833 additions and 33765 deletions
+48 -35
View File
@@ -1,13 +1,16 @@
/**
* @module ol/Geolocation
*/
import BaseObject, {getChangeEventType} from './Object.js';
import BaseEvent from './events/Event.js';
import BaseObject, {getChangeEventType} from './Object.js';
import EventType from './events/EventType.js';
import {circular as circularPolygon} from './geom/Polygon.js';
import {
get as getProjection,
getTransformFromProjections,
identityTransform,
} from './proj.js';
import {toRadians} from './math.js';
import {get as getProjection, getTransformFromProjections, identityTransform} from './proj.js';
/**
* @enum {string}
@@ -22,10 +25,9 @@ const Property = {
PROJECTION: 'projection',
SPEED: 'speed',
TRACKING: 'tracking',
TRACKING_OPTIONS: 'trackingOptions'
TRACKING_OPTIONS: 'trackingOptions',
};
/**
* @classdesc
* Events emitted on Geolocation error.
@@ -49,7 +51,6 @@ class GeolocationError extends BaseEvent {
}
}
/**
* @typedef {Object} Options
* @property {boolean} [tracking=false] Start Tracking right after
@@ -60,7 +61,6 @@ class GeolocationError extends BaseEvent {
* is reported in.
*/
/**
* @classdesc
* Helper class for providing HTML5 Geolocation capabilities.
@@ -85,12 +85,10 @@ class GeolocationError extends BaseEvent {
* @api
*/
class Geolocation extends BaseObject {
/**
* @param {Options=} opt_options Options.
*/
constructor(opt_options) {
super();
const options = opt_options || {};
@@ -114,8 +112,14 @@ class Geolocation extends BaseObject {
*/
this.watchId_ = undefined;
this.addEventListener(getChangeEventType(Property.PROJECTION), this.handleProjectionChanged_);
this.addEventListener(getChangeEventType(Property.TRACKING), this.handleTrackingChanged_);
this.addEventListener(
getChangeEventType(Property.PROJECTION),
this.handleProjectionChanged_
);
this.addEventListener(
getChangeEventType(Property.TRACKING),
this.handleTrackingChanged_
);
if (options.projection !== undefined) {
this.setProjection(options.projection);
@@ -125,7 +129,6 @@ class Geolocation extends BaseObject {
}
this.setTracking(options.tracking !== undefined ? options.tracking : false);
}
/**
@@ -143,7 +146,9 @@ class Geolocation extends BaseObject {
const projection = this.getProjection();
if (projection) {
this.transform_ = getTransformFromProjections(
getProjection('EPSG:4326'), projection);
getProjection('EPSG:4326'),
projection
);
if (this.position_) {
this.set(Property.POSITION, this.transform_(this.position_));
}
@@ -160,7 +165,8 @@ class Geolocation extends BaseObject {
this.watchId_ = navigator.geolocation.watchPosition(
this.positionChange_.bind(this),
this.positionError_.bind(this),
this.getTrackingOptions());
this.getTrackingOptions()
);
} else if (!tracking && this.watchId_ !== undefined) {
navigator.geolocation.clearWatch(this.watchId_);
this.watchId_ = undefined;
@@ -175,13 +181,18 @@ class Geolocation extends BaseObject {
positionChange_(position) {
const coords = position.coords;
this.set(Property.ACCURACY, coords.accuracy);
this.set(Property.ALTITUDE,
coords.altitude === null ? undefined : coords.altitude);
this.set(Property.ALTITUDE_ACCURACY,
coords.altitudeAccuracy === null ?
undefined : coords.altitudeAccuracy);
this.set(Property.HEADING, coords.heading === null ?
undefined : toRadians(coords.heading));
this.set(
Property.ALTITUDE,
coords.altitude === null ? undefined : coords.altitude
);
this.set(
Property.ALTITUDE_ACCURACY,
coords.altitudeAccuracy === null ? undefined : coords.altitudeAccuracy
);
this.set(
Property.HEADING,
coords.heading === null ? undefined : toRadians(coords.heading)
);
if (!this.position_) {
this.position_ = [coords.longitude, coords.latitude];
} else {
@@ -190,8 +201,7 @@ class Geolocation extends BaseObject {
}
const projectedPosition = this.transform_(this.position_);
this.set(Property.POSITION, projectedPosition);
this.set(Property.SPEED,
coords.speed === null ? undefined : coords.speed);
this.set(Property.SPEED, coords.speed === null ? undefined : coords.speed);
const geometry = circularPolygon(this.position_, coords.accuracy);
geometry.applyTransform(this.transform_);
this.set(Property.ACCURACY_GEOMETRY, geometry);
@@ -225,9 +235,9 @@ class Geolocation extends BaseObject {
* @api
*/
getAccuracyGeometry() {
return (
/** @type {?import("./geom/Polygon.js").default} */ (this.get(Property.ACCURACY_GEOMETRY) || null)
);
return /** @type {?import("./geom/Polygon.js").default} */ (this.get(
Property.ACCURACY_GEOMETRY
) || null);
}
/**
@@ -249,7 +259,9 @@ class Geolocation extends BaseObject {
* @api
*/
getAltitudeAccuracy() {
return /** @type {number|undefined} */ (this.get(Property.ALTITUDE_ACCURACY));
return /** @type {number|undefined} */ (this.get(
Property.ALTITUDE_ACCURACY
));
}
/**
@@ -272,9 +284,9 @@ class Geolocation extends BaseObject {
* @api
*/
getPosition() {
return (
/** @type {import("./coordinate.js").Coordinate|undefined} */ (this.get(Property.POSITION))
);
return /** @type {import("./coordinate.js").Coordinate|undefined} */ (this.get(
Property.POSITION
));
}
/**
@@ -285,9 +297,9 @@ class Geolocation extends BaseObject {
* @api
*/
getProjection() {
return (
/** @type {import("./proj/Projection.js").default|undefined} */ (this.get(Property.PROJECTION))
);
return /** @type {import("./proj/Projection.js").default|undefined} */ (this.get(
Property.PROJECTION
));
}
/**
@@ -321,7 +333,9 @@ class Geolocation extends BaseObject {
* @api
*/
getTrackingOptions() {
return /** @type {PositionOptions|undefined} */ (this.get(Property.TRACKING_OPTIONS));
return /** @type {PositionOptions|undefined} */ (this.get(
Property.TRACKING_OPTIONS
));
}
/**
@@ -359,5 +373,4 @@ class Geolocation extends BaseObject {
}
}
export default Geolocation;