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:
@@ -2,27 +2,24 @@
|
||||
* @module ol/Collection
|
||||
*/
|
||||
import AssertionError from './AssertionError.js';
|
||||
import CollectionEventType from './CollectionEventType.js';
|
||||
import BaseObject from './Object.js';
|
||||
import CollectionEventType from './CollectionEventType.js';
|
||||
import Event from './events/Event.js';
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
* @private
|
||||
*/
|
||||
const Property = {
|
||||
LENGTH: 'length'
|
||||
LENGTH: 'length',
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Events emitted by {@link module:ol/Collection~Collection} instances are instances of this
|
||||
* type.
|
||||
*/
|
||||
export class CollectionEvent extends Event {
|
||||
|
||||
/**
|
||||
* @param {CollectionEventType} type Type.
|
||||
* @param {*=} opt_element Element.
|
||||
@@ -45,10 +42,8 @@ export class CollectionEvent extends Event {
|
||||
*/
|
||||
this.index = opt_index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {boolean} [unique=false] Disallow the same item from being added to
|
||||
@@ -69,13 +64,11 @@ export class CollectionEvent extends Event {
|
||||
* @api
|
||||
*/
|
||||
class Collection extends BaseObject {
|
||||
|
||||
/**
|
||||
* @param {Array<T>=} opt_array Array.
|
||||
* @param {Options=} opt_options Collection options.
|
||||
*/
|
||||
constructor(opt_array, opt_options) {
|
||||
|
||||
super();
|
||||
|
||||
const options = opt_options || {};
|
||||
@@ -99,7 +92,6 @@ class Collection extends BaseObject {
|
||||
}
|
||||
|
||||
this.updateLength_();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +177,8 @@ class Collection extends BaseObject {
|
||||
this.array_.splice(index, 0, elem);
|
||||
this.updateLength_();
|
||||
this.dispatchEvent(
|
||||
new CollectionEvent(CollectionEventType.ADD, elem, index));
|
||||
new CollectionEvent(CollectionEventType.ADD, elem, index)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +233,9 @@ class Collection extends BaseObject {
|
||||
const prev = this.array_[index];
|
||||
this.array_.splice(index, 1);
|
||||
this.updateLength_();
|
||||
this.dispatchEvent(new CollectionEvent(CollectionEventType.REMOVE, prev, index));
|
||||
this.dispatchEvent(
|
||||
new CollectionEvent(CollectionEventType.REMOVE, prev, index)
|
||||
);
|
||||
return prev;
|
||||
}
|
||||
|
||||
@@ -259,9 +254,11 @@ class Collection extends BaseObject {
|
||||
const prev = this.array_[index];
|
||||
this.array_[index] = elem;
|
||||
this.dispatchEvent(
|
||||
new CollectionEvent(CollectionEventType.REMOVE, prev, index));
|
||||
new CollectionEvent(CollectionEventType.REMOVE, prev, index)
|
||||
);
|
||||
this.dispatchEvent(
|
||||
new CollectionEvent(CollectionEventType.ADD, elem, index));
|
||||
new CollectionEvent(CollectionEventType.ADD, elem, index)
|
||||
);
|
||||
} else {
|
||||
for (let j = n; j < index; ++j) {
|
||||
this.insertAt(j, undefined);
|
||||
@@ -291,5 +288,4 @@ class Collection extends BaseObject {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default Collection;
|
||||
|
||||
Reference in New Issue
Block a user