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

@@ -2,19 +2,21 @@
* @module ol/control/FullScreen
*/
import Control from './Control.js';
import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_UNSUPPORTED} from '../css.js';
import {replaceNode} from '../dom.js';
import {listen} from '../events.js';
import EventType from '../events/EventType.js';
import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_UNSUPPORTED} from '../css.js';
import {listen} from '../events.js';
import {replaceNode} from '../dom.js';
const events = ['fullscreenchange', 'webkitfullscreenchange', 'MSFullscreenChange'];
const events = [
'fullscreenchange',
'webkitfullscreenchange',
'MSFullscreenChange',
];
/**
* @enum {string}
*/
const FullScreenEventType = {
/**
* Triggered after the map entered fullscreen.
* @event FullScreenEventType#enterfullscreen
@@ -27,11 +29,9 @@ const FullScreenEventType = {
* @event FullScreenEventType#leavefullscreen
* @api
*/
LEAVEFULLSCREEN: 'leavefullscreen'
LEAVEFULLSCREEN: 'leavefullscreen',
};
/**
* @typedef {Object} Options
* @property {string} [className='ol-full-screen'] CSS class name.
@@ -49,7 +49,6 @@ const FullScreenEventType = {
* be displayed fullscreen.
*/
/**
* @classdesc
* Provides a button that when clicked fills up the full screen with the map.
@@ -66,25 +65,23 @@ const FullScreenEventType = {
* @api
*/
class FullScreen extends Control {
/**
* @param {Options=} opt_options Options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : {};
super({
element: document.createElement('div'),
target: options.target
target: options.target,
});
/**
* @private
* @type {string}
*/
this.cssClassName_ = options.className !== undefined ? options.className :
'ol-full-screen';
this.cssClassName_ =
options.className !== undefined ? options.className : 'ol-full-screen';
const label = options.label !== undefined ? options.label : '\u2922';
@@ -92,17 +89,20 @@ class FullScreen extends Control {
* @private
* @type {Text}
*/
this.labelNode_ = typeof label === 'string' ?
document.createTextNode(label) : label;
this.labelNode_ =
typeof label === 'string' ? document.createTextNode(label) : label;
const labelActive = options.labelActive !== undefined ? options.labelActive : '\u00d7';
const labelActive =
options.labelActive !== undefined ? options.labelActive : '\u00d7';
/**
* @private
* @type {Text}
*/
this.labelActiveNode_ = typeof labelActive === 'string' ?
document.createTextNode(labelActive) : labelActive;
this.labelActiveNode_ =
typeof labelActive === 'string'
? document.createTextNode(labelActive)
: labelActive;
/**
* @private
@@ -116,11 +116,20 @@ class FullScreen extends Control {
this.button_.title = tipLabel;
this.button_.appendChild(this.labelNode_);
this.button_.addEventListener(EventType.CLICK, this.handleClick_.bind(this), false);
this.button_.addEventListener(
EventType.CLICK,
this.handleClick_.bind(this),
false
);
const cssClasses = this.cssClassName_ + ' ' + CLASS_UNSELECTABLE +
' ' + CLASS_CONTROL + ' ' +
(!isFullScreenSupported() ? CLASS_UNSUPPORTED : '');
const cssClasses =
this.cssClassName_ +
' ' +
CLASS_UNSELECTABLE +
' ' +
CLASS_CONTROL +
' ' +
(!isFullScreenSupported() ? CLASS_UNSUPPORTED : '');
const element = this.element;
element.className = cssClasses;
element.appendChild(this.button_);
@@ -136,7 +145,6 @@ class FullScreen extends Control {
* @type {HTMLElement|string|undefined}
*/
this.source_ = options.source;
}
/**
@@ -164,15 +172,15 @@ class FullScreen extends Control {
} else {
let element;
if (this.source_) {
element = typeof this.source_ === 'string' ?
document.getElementById(this.source_) :
this.source_;
element =
typeof this.source_ === 'string'
? document.getElementById(this.source_)
: this.source_;
} else {
element = map.getTargetElement();
}
if (this.keys_) {
requestFullScreenWithKeys(element);
} else {
requestFullScreen(element);
}
@@ -224,13 +232,13 @@ class FullScreen extends Control {
if (map) {
for (let i = 0, ii = events.length; i < ii; ++i) {
this.listenerKeys.push(
listen(document, events[i], this.handleFullScreenChange_, this));
listen(document, events[i], this.handleFullScreenChange_, this)
);
}
}
}
}
/**
* @return {boolean} Fullscreen is supported by the current platform.
*/
@@ -248,7 +256,9 @@ function isFullScreenSupported() {
*/
function isFullScreen() {
return !!(
document.webkitIsFullScreen || document.msFullscreenElement || document.fullscreenElement
document.webkitIsFullScreen ||
document.msFullscreenElement ||
document.fullscreenElement
);
}