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
+43 -34
View File
@@ -2,14 +2,13 @@
* @module ol/source/ImageArcGISRest
*/
import ImageWrapper from '../Image.js';
import {assert} from '../asserts.js';
import EventType from '../events/EventType.js';
import {containsExtent, getHeight, getWidth} from '../extent.js';
import {assign} from '../obj.js';
import ImageSource, {defaultImageLoadFunction} from './Image.js';
import ImageWrapper from '../Image.js';
import {appendParams} from '../uri.js';
import {assert} from '../asserts.js';
import {assign} from '../obj.js';
import {containsExtent, getHeight, getWidth} from '../extent.js';
/**
* @typedef {Object} Options
@@ -36,7 +35,6 @@ import {appendParams} from '../uri.js';
* should include /MapServer or /ImageServer.
*/
/**
* @classdesc
* Source for data from ArcGIS Rest services providing single, untiled images.
@@ -54,13 +52,12 @@ class ImageArcGISRest extends ImageSource {
* @param {Options=} opt_options Image ArcGIS Rest Options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : {};
super({
attributions: options.attributions,
projection: options.projection,
resolutions: options.resolutions
resolutions: options.resolutions,
});
/**
@@ -68,7 +65,7 @@ class ImageArcGISRest extends ImageSource {
* @type {?string}
*/
this.crossOrigin_ =
options.crossOrigin !== undefined ? options.crossOrigin : null;
options.crossOrigin !== undefined ? options.crossOrigin : null;
/**
* @private
@@ -86,9 +83,10 @@ class ImageArcGISRest extends ImageSource {
* @private
* @type {import("../Image.js").LoadFunction}
*/
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
options.imageLoadFunction : defaultImageLoadFunction;
this.imageLoadFunction_ =
options.imageLoadFunction !== undefined
? options.imageLoadFunction
: defaultImageLoadFunction;
/**
* @private
@@ -108,7 +106,6 @@ class ImageArcGISRest extends ImageSource {
*/
this.imageSize_ = [0, 0];
/**
* @private
* @type {number}
@@ -120,7 +117,6 @@ class ImageArcGISRest extends ImageSource {
* @type {number}
*/
this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5;
}
/**
@@ -141,7 +137,6 @@ class ImageArcGISRest extends ImageSource {
* @return {import("../Image.js").default} Single image.
*/
getImageInternal(extent, resolution, pixelRatio, projection) {
if (this.url_ === undefined) {
return null;
}
@@ -150,18 +145,20 @@ class ImageArcGISRest extends ImageSource {
pixelRatio = this.hidpi_ ? pixelRatio : 1;
const image = this.image_;
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
containsExtent(image.getExtent(), extent)) {
if (
image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
containsExtent(image.getExtent(), extent)
) {
return image;
}
const params = {
'F': 'image',
'FORMAT': 'PNG32',
'TRANSPARENT': true
'TRANSPARENT': true,
};
assign(params, this.params_);
@@ -169,8 +166,8 @@ class ImageArcGISRest extends ImageSource {
const centerX = (extent[0] + extent[2]) / 2;
const centerY = (extent[1] + extent[3]) / 2;
if (this.ratio_ != 1) {
const halfWidth = this.ratio_ * getWidth(extent) / 2;
const halfHeight = this.ratio_ * getHeight(extent) / 2;
const halfWidth = (this.ratio_ * getWidth(extent)) / 2;
const halfHeight = (this.ratio_ * getHeight(extent)) / 2;
extent[0] = centerX - halfWidth;
extent[1] = centerY - halfHeight;
extent[2] = centerX + halfWidth;
@@ -184,26 +181,39 @@ class ImageArcGISRest extends ImageSource {
const height = Math.ceil(getHeight(extent) / imageResolution);
// Modify the extent to match the integer width and height.
extent[0] = centerX - imageResolution * width / 2;
extent[2] = centerX + imageResolution * width / 2;
extent[1] = centerY - imageResolution * height / 2;
extent[3] = centerY + imageResolution * height / 2;
extent[0] = centerX - (imageResolution * width) / 2;
extent[2] = centerX + (imageResolution * width) / 2;
extent[1] = centerY - (imageResolution * height) / 2;
extent[3] = centerY + (imageResolution * height) / 2;
this.imageSize_[0] = width;
this.imageSize_[1] = height;
const url = this.getRequestUrl_(extent, this.imageSize_, pixelRatio,
projection, params);
const url = this.getRequestUrl_(
extent,
this.imageSize_,
pixelRatio,
projection,
params
);
this.image_ = new ImageWrapper(extent, resolution, pixelRatio,
url, this.crossOrigin_, this.imageLoadFunction_);
this.image_ = new ImageWrapper(
extent,
resolution,
pixelRatio,
url,
this.crossOrigin_,
this.imageLoadFunction_
);
this.renderedRevision_ = this.getRevision();
this.image_.addEventListener(EventType.CHANGE, this.handleImageChange.bind(this));
this.image_.addEventListener(
EventType.CHANGE,
this.handleImageChange.bind(this)
);
return this.image_;
}
/**
@@ -290,5 +300,4 @@ class ImageArcGISRest extends ImageSource {
}
}
export default ImageArcGISRest;