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
+40 -27
View File
@@ -2,13 +2,12 @@
* @module ol/interaction/Translate
*/
import Collection from '../Collection.js';
import {getChangeEventType} from '../Object.js';
import Event from '../events/Event.js';
import {TRUE} from '../functions.js';
import {includes} from '../array.js';
import PointerInteraction from './Pointer.js';
import InteractionProperty from './Property.js';
import PointerInteraction from './Pointer.js';
import {TRUE} from '../functions.js';
import {getChangeEventType} from '../Object.js';
import {includes} from '../array.js';
/**
* @enum {string}
@@ -31,7 +30,7 @@ const TranslateEventType = {
* @event TranslateEvent#translateend
* @api
*/
TRANSLATEEND: 'translateend'
TRANSLATEEND: 'translateend',
};
/**
@@ -59,7 +58,6 @@ const TranslateEventType = {
* will be checked for features.
*/
/**
* @classdesc
* Events emitted by {@link module:ol/interaction/Translate~Translate} instances
@@ -74,7 +72,6 @@ export class TranslateEvent extends Event {
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
*/
constructor(type, features, coordinate, startCoordinate, mapBrowserEvent) {
super(type);
/**
@@ -106,12 +103,9 @@ export class TranslateEvent extends Event {
* @api
*/
this.mapBrowserEvent = mapBrowserEvent;
}
}
/**
* @classdesc
* Interaction for translating (moving) features.
@@ -142,7 +136,6 @@ class Translate extends PointerInteraction {
*/
this.startCoordinate_ = null;
/**
* @type {Collection<import("../Feature.js").default>}
* @private
@@ -156,7 +149,7 @@ class Translate extends PointerInteraction {
layerFilter = options.layers;
} else {
const layers = options.layers;
layerFilter = function(layer) {
layerFilter = function (layer) {
return includes(layers, layer);
};
}
@@ -188,8 +181,10 @@ class Translate extends PointerInteraction {
*/
this.lastFeature_ = null;
this.addEventListener(getChangeEventType(InteractionProperty.ACTIVE), this.handleActiveChanged_);
this.addEventListener(
getChangeEventType(InteractionProperty.ACTIVE),
this.handleActiveChanged_
);
}
/**
@@ -208,8 +203,13 @@ class Translate extends PointerInteraction {
this.dispatchEvent(
new TranslateEvent(
TranslateEventType.TRANSLATESTART, features,
event.coordinate, this.startCoordinate_, event));
TranslateEventType.TRANSLATESTART,
features,
event.coordinate,
this.startCoordinate_,
event
)
);
return true;
}
return false;
@@ -229,8 +229,13 @@ class Translate extends PointerInteraction {
this.dispatchEvent(
new TranslateEvent(
TranslateEventType.TRANSLATEEND, features,
event.coordinate, this.startCoordinate_, event));
TranslateEventType.TRANSLATEEND,
features,
event.coordinate,
this.startCoordinate_,
event
)
);
// cleanup
this.startCoordinate_ = null;
return true;
@@ -250,7 +255,7 @@ class Translate extends PointerInteraction {
const features = this.features_ || new Collection([this.lastFeature_]);
features.forEach(function(feature) {
features.forEach(function (feature) {
const geom = feature.getGeometry();
geom.translate(deltaX, deltaY);
feature.setGeometry(geom);
@@ -259,8 +264,13 @@ class Translate extends PointerInteraction {
this.lastCoordinate_ = newCoordinate;
this.dispatchEvent(
new TranslateEvent(
TranslateEventType.TRANSLATING, features,
newCoordinate, this.startCoordinate_, event));
TranslateEventType.TRANSLATING,
features,
newCoordinate,
this.startCoordinate_,
event
)
);
}
}
@@ -291,17 +301,20 @@ class Translate extends PointerInteraction {
* @private
*/
featuresAtPixel_(pixel, map) {
return map.forEachFeatureAtPixel(pixel,
function(feature, layer) {
return map.forEachFeatureAtPixel(
pixel,
function (feature, layer) {
if (this.filter_(feature, layer)) {
if (!this.features_ || includes(this.features_.getArray(), feature)) {
return feature;
}
}
}.bind(this), {
}.bind(this),
{
layerFilter: this.layerFilter_,
hitTolerance: this.hitTolerance_
});
hitTolerance: this.hitTolerance_,
}
);
}
/**