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
+13 -23
View File
@@ -1,9 +1,9 @@
/**
* @module ol/structs/RBush
*/
import {getUid} from '../util.js';
import RBush_ from 'rbush/rbush.js';
import {createOrUpdate, equals} from '../extent.js';
import {getUid} from '../util.js';
import {isEmpty} from '../obj.js';
/**
@@ -27,7 +27,6 @@ class RBush {
* @param {number=} opt_maxEntries Max entries.
*/
constructor(opt_maxEntries) {
/**
* @private
*/
@@ -40,7 +39,6 @@ class RBush {
* @type {Object<string, Entry>}
*/
this.items_ = {};
}
/**
@@ -55,14 +53,13 @@ class RBush {
minY: extent[1],
maxX: extent[2],
maxY: extent[3],
value: value
value: value,
};
this.rbush_.insert(item);
this.items_[getUid(value)] = item;
}
/**
* Bulk-insert values into the RBush.
* @param {Array<import("../extent.js").Extent>} extents Extents.
@@ -80,7 +77,7 @@ class RBush {
minY: extent[1],
maxX: extent[2],
maxY: extent[3],
value: value
value: value,
};
items[i] = item;
this.items_[getUid(value)] = item;
@@ -88,7 +85,6 @@ class RBush {
this.rbush_.load(items);
}
/**
* Remove a value from the RBush.
* @param {T} value Value.
@@ -104,7 +100,6 @@ class RBush {
return this.rbush_.remove(item) !== null;
}
/**
* Update the extent of a value in the RBush.
* @param {import("../extent.js").Extent} extent Extent.
@@ -119,19 +114,17 @@ class RBush {
}
}
/**
* Return all values in the RBush.
* @return {Array<T>} All.
*/
getAll() {
const items = this.rbush_.all();
return items.map(function(item) {
return items.map(function (item) {
return item.value;
});
}
/**
* Return all values in the given extent.
* @param {import("../extent.js").Extent} extent Extent.
@@ -143,15 +136,14 @@ class RBush {
minX: extent[0],
minY: extent[1],
maxX: extent[2],
maxY: extent[3]
maxY: extent[3],
};
const items = this.rbush_.search(bbox);
return items.map(function(item) {
return items.map(function (item) {
return item.value;
});
}
/**
* Calls a callback function with each value in the tree.
* If the callback returns a truthy value, this value is returned without
@@ -163,7 +155,6 @@ class RBush {
return this.forEach_(this.getAll(), callback);
}
/**
* Calls a callback function with each value in the provided extent.
* @param {import("../extent.js").Extent} extent Extent.
@@ -174,7 +165,6 @@ class RBush {
return this.forEach_(this.getInExtent(extent), callback);
}
/**
* @param {Array<T>} values Values.
* @param {function(T): *} callback Callback.
@@ -192,7 +182,6 @@ class RBush {
return result;
}
/**
* @return {boolean} Is empty.
*/
@@ -200,7 +189,6 @@ class RBush {
return isEmpty(this.items_);
}
/**
* Remove all values from the RBush.
*/
@@ -209,17 +197,21 @@ class RBush {
this.items_ = {};
}
/**
* @param {import("../extent.js").Extent=} opt_extent Extent.
* @return {import("../extent.js").Extent} Extent.
*/
getExtent(opt_extent) {
const data = this.rbush_.toJSON();
return createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent);
return createOrUpdate(
data.minX,
data.minY,
data.maxX,
data.maxY,
opt_extent
);
}
/**
* @param {RBush} rbush R-Tree.
*/
@@ -229,8 +221,6 @@ class RBush {
this.items_[i] = rbush.items_[i];
}
}
}
export default RBush;