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
+20 -20
View File
@@ -1,12 +1,11 @@
/**
* @module ol/interaction/KeyboardPan
*/
import {rotate as rotateCoordinate} from '../coordinate.js';
import EventType from '../events/EventType.js';
import Interaction, {pan} from './Interaction.js';
import KeyCode from '../events/KeyCode.js';
import {noModifierKeys, targetNotEditable} from '../events/condition.js';
import Interaction, {pan} from './Interaction.js';
import {rotate as rotateCoordinate} from '../coordinate.js';
/**
* @typedef {Object} Options
@@ -20,7 +19,6 @@ import Interaction, {pan} from './Interaction.js';
* press.
*/
/**
* @classdesc
* Allows the user to pan the map using keyboard arrows.
@@ -39,9 +37,8 @@ class KeyboardPan extends Interaction {
* @param {Options=} opt_options Options.
*/
constructor(opt_options) {
super({
handleEvent: handleEvent
handleEvent: handleEvent,
});
const options = opt_options || {};
@@ -51,17 +48,20 @@ class KeyboardPan extends Interaction {
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Browser event.
* @return {boolean} Combined condition result.
*/
this.defaultCondition_ = function(mapBrowserEvent) {
return noModifierKeys(mapBrowserEvent) &&
targetNotEditable(mapBrowserEvent);
this.defaultCondition_ = function (mapBrowserEvent) {
return (
noModifierKeys(mapBrowserEvent) && targetNotEditable(mapBrowserEvent)
);
};
/**
* @private
* @type {import("../events/condition.js").Condition}
*/
this.condition_ = options.condition !== undefined ?
options.condition : this.defaultCondition_;
this.condition_ =
options.condition !== undefined
? options.condition
: this.defaultCondition_;
/**
* @private
@@ -73,14 +73,11 @@ class KeyboardPan extends Interaction {
* @private
* @type {number}
*/
this.pixelDelta_ = options.pixelDelta !== undefined ?
options.pixelDelta : 128;
this.pixelDelta_ =
options.pixelDelta !== undefined ? options.pixelDelta : 128;
}
}
/**
* Handles the {@link module:ol/MapBrowserEvent map browser event} if it was a
* `KeyEvent`, and decides the direction to pan to (if an arrow key was
@@ -94,15 +91,18 @@ function handleEvent(mapBrowserEvent) {
if (mapBrowserEvent.type == EventType.KEYDOWN) {
const keyEvent = /** @type {KeyboardEvent} */ (mapBrowserEvent.originalEvent);
const keyCode = keyEvent.keyCode;
if (this.condition_(mapBrowserEvent) &&
(keyCode == KeyCode.DOWN ||
if (
this.condition_(mapBrowserEvent) &&
(keyCode == KeyCode.DOWN ||
keyCode == KeyCode.LEFT ||
keyCode == KeyCode.RIGHT ||
keyCode == KeyCode.UP)) {
keyCode == KeyCode.UP)
) {
const map = mapBrowserEvent.map;
const view = map.getView();
const mapUnitsDelta = view.getResolution() * this.pixelDelta_;
let deltaX = 0, deltaY = 0;
let deltaX = 0,
deltaY = 0;
if (keyCode == KeyCode.DOWN) {
deltaY = -mapUnitsDelta;
} else if (keyCode == KeyCode.LEFT) {