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

View File

@@ -3,12 +3,16 @@
*/
import 'elm-pep';
import {listen} from '../events.js';
import Control from './Control.js';
import EventType from '../pointer/EventType.js';
import {getChangeEventType} from '../Object.js';
import Control from './Control.js';
import {getTransformFromProjections, identityTransform, get as getProjection, getUserProjection} from '../proj.js';
import {
get as getProjection,
getTransformFromProjections,
getUserProjection,
identityTransform,
} from '../proj.js';
import {listen} from '../events.js';
/**
* @type {string}
@@ -20,7 +24,6 @@ const PROJECTION = 'projection';
*/
const COORDINATE_FORMAT = 'coordinateFormat';
/**
* @typedef {Object} Options
* @property {string} [className='ol-mouse-position'] CSS class name.
@@ -38,7 +41,6 @@ const COORDINATE_FORMAT = 'coordinateFormat';
* string `''`).
*/
/**
* @classdesc
* A control to show the 2D coordinates of the mouse cursor. By default, these
@@ -52,24 +54,26 @@ const COORDINATE_FORMAT = 'coordinateFormat';
* @api
*/
class MousePosition extends Control {
/**
* @param {Options=} opt_options Mouse position options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : {};
const element = document.createElement('div');
element.className = options.className !== undefined ? options.className : 'ol-mouse-position';
element.className =
options.className !== undefined ? options.className : 'ol-mouse-position';
super({
element: element,
render: options.render || render,
target: options.target
target: options.target,
});
this.addEventListener(getChangeEventType(PROJECTION), this.handleProjectionChanged_);
this.addEventListener(
getChangeEventType(PROJECTION),
this.handleProjectionChanged_
);
if (options.coordinateFormat) {
this.setCoordinateFormat(options.coordinateFormat);
@@ -82,7 +86,8 @@ class MousePosition extends Control {
* @private
* @type {string}
*/
this.undefinedHTML_ = options.undefinedHTML !== undefined ? options.undefinedHTML : ' ';
this.undefinedHTML_ =
options.undefinedHTML !== undefined ? options.undefinedHTML : ' ';
/**
* @private
@@ -107,7 +112,6 @@ class MousePosition extends Control {
* @type {?import("../proj.js").TransformFunction}
*/
this.transform_ = null;
}
/**
@@ -126,9 +130,9 @@ class MousePosition extends Control {
* @api
*/
getCoordinateFormat() {
return (
/** @type {import("../coordinate.js").CoordinateFormat|undefined} */ (this.get(COORDINATE_FORMAT))
);
return /** @type {import("../coordinate.js").CoordinateFormat|undefined} */ (this.get(
COORDINATE_FORMAT
));
}
/**
@@ -139,9 +143,9 @@ class MousePosition extends Control {
* @api
*/
getProjection() {
return (
/** @type {import("../proj/Projection.js").default|undefined} */ (this.get(PROJECTION))
);
return /** @type {import("../proj/Projection.js").default|undefined} */ (this.get(
PROJECTION
));
}
/**
@@ -216,7 +220,9 @@ class MousePosition extends Control {
const projection = this.getProjection();
if (projection) {
this.transform_ = getTransformFromProjections(
this.mapProjection_, projection);
this.mapProjection_,
projection
);
} else {
this.transform_ = identityTransform;
}
@@ -227,7 +233,9 @@ class MousePosition extends Control {
const userProjection = getUserProjection();
if (userProjection) {
this.transform_ = getTransformFromProjections(
this.mapProjection_, userProjection);
this.mapProjection_,
userProjection
);
}
this.transform_(coordinate, coordinate);
const coordinateFormat = this.getCoordinateFormat();
@@ -245,7 +253,6 @@ class MousePosition extends Control {
}
}
/**
* Update the projection. Rendering of the coordinates is done in
* `handleMouseMove` and `handleMouseUp`.
@@ -264,5 +271,4 @@ export function render(mapEvent) {
}
}
export default MousePosition;