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
+34 -22
View File
@@ -3,11 +3,10 @@
*/
// FIXME draw drag box
import Event from '../events/Event.js';
import {mouseActionButton} from '../events/condition.js';
import {VOID} from '../functions.js';
import PointerInteraction from './Pointer.js';
import RenderBox from '../render/Box.js';
import {VOID} from '../functions.js';
import {mouseActionButton} from '../events/condition.js';
/**
* A function that takes a {@link module:ol/MapBrowserEvent} and two
@@ -16,7 +15,6 @@ import RenderBox from '../render/Box.js';
* @typedef {function(this: ?, import("../MapBrowserEvent.js").default, import("../pixel.js").Pixel, import("../pixel.js").Pixel):boolean} EndCondition
*/
/**
* @typedef {Object} Options
* @property {string} [className='ol-dragbox'] CSS class name for styling the box.
@@ -32,7 +30,6 @@ import RenderBox from '../render/Box.js';
* before `boxend` is fired.
*/
/**
* @enum {string}
*/
@@ -56,17 +53,15 @@ const DragBoxEventType = {
* @event DragBoxEvent#boxend
* @api
*/
BOXEND: 'boxend'
BOXEND: 'boxend',
};
/**
* @classdesc
* Events emitted by {@link module:ol/interaction/DragBox~DragBox} instances are instances of
* this type.
*/
class DragBoxEvent extends Event {
/**
* @param {string} type The event type.
* @param {import("../coordinate.js").Coordinate} coordinate The event coordinate.
@@ -89,12 +84,9 @@ class DragBoxEvent extends Event {
* @api
*/
this.mapBrowserEvent = mapBrowserEvent;
}
}
/**
* @classdesc
* Allows the user to draw a vector box by clicking and dragging on the map,
@@ -112,7 +104,6 @@ class DragBox extends PointerInteraction {
* @param {Options=} opt_options Options.
*/
constructor(opt_options) {
super();
const options = opt_options ? opt_options : {};
@@ -152,8 +143,9 @@ class DragBox extends PointerInteraction {
* @private
* @type {EndCondition}
*/
this.boxEndCondition_ = options.boxEndCondition ?
options.boxEndCondition : this.defaultBoxEndCondition;
this.boxEndCondition_ = options.boxEndCondition
? options.boxEndCondition
: this.defaultBoxEndCondition;
}
/**
@@ -187,8 +179,13 @@ class DragBox extends PointerInteraction {
handleDragEvent(mapBrowserEvent) {
this.box_.setPixels(this.startPixel_, mapBrowserEvent.pixel);
this.dispatchEvent(new DragBoxEvent(DragBoxEventType.BOXDRAG,
mapBrowserEvent.coordinate, mapBrowserEvent));
this.dispatchEvent(
new DragBoxEvent(
DragBoxEventType.BOXDRAG,
mapBrowserEvent.coordinate,
mapBrowserEvent
)
);
}
/**
@@ -199,10 +196,21 @@ class DragBox extends PointerInteraction {
handleUpEvent(mapBrowserEvent) {
this.box_.setMap(null);
if (this.boxEndCondition_(mapBrowserEvent, this.startPixel_, mapBrowserEvent.pixel)) {
if (
this.boxEndCondition_(
mapBrowserEvent,
this.startPixel_,
mapBrowserEvent.pixel
)
) {
this.onBoxEnd_(mapBrowserEvent);
this.dispatchEvent(new DragBoxEvent(DragBoxEventType.BOXEND,
mapBrowserEvent.coordinate, mapBrowserEvent));
this.dispatchEvent(
new DragBoxEvent(
DragBoxEventType.BOXEND,
mapBrowserEvent.coordinate,
mapBrowserEvent
)
);
}
return false;
}
@@ -217,8 +225,13 @@ class DragBox extends PointerInteraction {
this.startPixel_ = mapBrowserEvent.pixel;
this.box_.setMap(mapBrowserEvent.map);
this.box_.setPixels(this.startPixel_, this.startPixel_);
this.dispatchEvent(new DragBoxEvent(DragBoxEventType.BOXSTART,
mapBrowserEvent.coordinate, mapBrowserEvent));
this.dispatchEvent(
new DragBoxEvent(
DragBoxEventType.BOXSTART,
mapBrowserEvent.coordinate,
mapBrowserEvent
)
);
return true;
} else {
return false;
@@ -226,5 +239,4 @@ class DragBox extends PointerInteraction {
}
}
export default DragBox;