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
+22 -26
View File
@@ -3,13 +3,12 @@
*/
// FIXME should handle all geo-referenced data, not just vector data
import {TRUE} from '../functions.js';
import {listen, unlistenByKey} from '../events.js';
import Event from '../events/Event.js';
import EventType from '../events/EventType.js';
import Interaction from './Interaction.js';
import {TRUE} from '../functions.js';
import {get as getProjection} from '../proj.js';
import {listen, unlistenByKey} from '../events.js';
/**
* @typedef {Object} Options
@@ -23,7 +22,6 @@ import {get as getProjection} from '../proj.js';
* @property {HTMLElement} [target] The element that is used as the drop target, default is the viewport element.
*/
/**
* @enum {string}
*/
@@ -33,17 +31,15 @@ const DragAndDropEventType = {
* @event DragAndDropEvent#addfeatures
* @api
*/
ADD_FEATURES: 'addfeatures'
ADD_FEATURES: 'addfeatures',
};
/**
* @classdesc
* Events emitted by {@link module:ol/interaction/DragAndDrop~DragAndDrop} instances are instances
* of this type.
*/
class DragAndDropEvent extends Event {
/**
* @param {DragAndDropEventType} type Type.
* @param {File} file File.
@@ -51,7 +47,6 @@ class DragAndDropEvent extends Event {
* @param {import("../proj/Projection.js").default=} opt_projection Projection.
*/
constructor(type, file, opt_features, opt_projection) {
super(type);
/**
@@ -74,12 +69,9 @@ class DragAndDropEvent extends Event {
* @api
*/
this.projection = opt_projection;
}
}
/**
* @classdesc
* Handles input of vector data by drag and drop.
@@ -92,26 +84,27 @@ class DragAndDrop extends Interaction {
* @param {Options=} opt_options Options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : {};
super({
handleEvent: TRUE
handleEvent: TRUE,
});
/**
* @private
* @type {Array<typeof import("../format/Feature.js").default>}
*/
this.formatConstructors_ = options.formatConstructors ?
options.formatConstructors : [];
this.formatConstructors_ = options.formatConstructors
? options.formatConstructors
: [];
/**
* @private
* @type {import("../proj/Projection.js").default}
*/
this.projection_ = options.projection ?
getProjection(options.projection) : null;
this.projection_ = options.projection
? getProjection(options.projection)
: null;
/**
* @private
@@ -130,7 +123,6 @@ class DragAndDrop extends Interaction {
* @type {HTMLElement}
*/
this.target = options.target ? options.target : null;
}
/**
@@ -152,7 +144,7 @@ class DragAndDrop extends Interaction {
for (let i = 0, ii = formatConstructors.length; i < ii; ++i) {
const format = new formatConstructors[i]();
features = this.tryReadFeatures_(format, result, {
featureProjection: projection
featureProjection: projection,
});
if (features && features.length > 0) {
break;
@@ -164,8 +156,12 @@ class DragAndDrop extends Interaction {
}
this.dispatchEvent(
new DragAndDropEvent(
DragAndDropEventType.ADD_FEATURES, file,
features, projection));
DragAndDropEventType.ADD_FEATURES,
file,
features,
projection
)
);
}
/**
@@ -179,7 +175,7 @@ class DragAndDrop extends Interaction {
listen(dropArea, EventType.DROP, handleDrop, this),
listen(dropArea, EventType.DRAGENTER, handleStop, this),
listen(dropArea, EventType.DRAGOVER, handleStop, this),
listen(dropArea, EventType.DROP, handleStop, this)
listen(dropArea, EventType.DROP, handleStop, this),
];
}
}
@@ -240,7 +236,6 @@ class DragAndDrop extends Interaction {
}
}
/**
* @param {DragEvent} event Event.
* @this {DragAndDrop}
@@ -250,12 +245,14 @@ function handleDrop(event) {
for (let i = 0, ii = files.length; i < ii; ++i) {
const file = files.item(i);
const reader = new FileReader();
reader.addEventListener(EventType.LOAD, this.handleResult_.bind(this, file));
reader.addEventListener(
EventType.LOAD,
this.handleResult_.bind(this, file)
);
reader.readAsText(file);
}
}
/**
* @param {DragEvent} event Event.
*/
@@ -265,5 +262,4 @@ function handleStop(event) {
event.dataTransfer.dropEffect = 'copy';
}
export default DragAndDrop;