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

@@ -1,15 +1,18 @@
/**
* @module ol/source/Tile
*/
import {abstract} from '../util.js';
import Event from '../events/Event.js';
import Source from './Source.js';
import TileCache from '../TileCache.js';
import TileState from '../TileState.js';
import Event from '../events/Event.js';
import {abstract} from '../util.js';
import {equivalent} from '../proj.js';
import {toSize, scale as scaleSize} from '../size.js';
import Source from './Source.js';
import {getKeyZXY, withinExtentAndZ} from '../tilecoord.js';
import {wrapX, getForProjection as getTileGridForProjection} from '../tilegrid.js';
import {
getForProjection as getTileGridForProjection,
wrapX,
} from '../tilegrid.js';
import {scale as scaleSize, toSize} from '../size.js';
/**
* @typedef {Object} Options
@@ -27,7 +30,6 @@ import {wrapX, getForProjection as getTileGridForProjection} from '../tilegrid.j
* @property {number} [zDirection=0]
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
@@ -41,13 +43,12 @@ class TileSource extends Source {
* @param {Options} options SourceTile source options.
*/
constructor(options) {
super({
attributions: options.attributions,
attributionsCollapsible: options.attributionsCollapsible,
projection: options.projection,
state: options.state,
wrapX: options.wrapX
wrapX: options.wrapX,
});
/**
@@ -60,8 +61,8 @@ class TileSource extends Source {
* @private
* @type {number}
*/
this.tilePixelRatio_ = options.tilePixelRatio !== undefined ?
options.tilePixelRatio : 1;
this.tilePixelRatio_ =
options.tilePixelRatio !== undefined ? options.tilePixelRatio : 1;
/**
* @protected
@@ -75,15 +76,18 @@ class TileSource extends Source {
toSize(tileGrid.getTileSize(tileGrid.getMinZoom()), tileSize);
}
const canUseScreen = typeof screen !== 'undefined';
const width = canUseScreen ? (screen.availWidth || screen.width) : 1920;
const height = canUseScreen ? (screen.availHeight || screen.height) : 1080;
const minCacheSize = 4 * Math.ceil(width / tileSize[0]) * Math.ceil(height / tileSize[1]);
const width = canUseScreen ? screen.availWidth || screen.width : 1920;
const height = canUseScreen ? screen.availHeight || screen.height : 1080;
const minCacheSize =
4 * Math.ceil(width / tileSize[0]) * Math.ceil(height / tileSize[1]);
/**
* @protected
* @type {import("../TileCache.js").default}
*/
this.tileCache = new TileCache(Math.max(minCacheSize, options.cacheSize || 0));
this.tileCache = new TileCache(
Math.max(minCacheSize, options.cacheSize || 0)
);
/**
* @protected
@@ -153,10 +157,12 @@ class TileSource extends Source {
tileCoordKey = getKeyZXY(z, x, y);
loaded = false;
if (tileCache.containsKey(tileCoordKey)) {
tile = /** @type {!import("../Tile.js").default} */ (tileCache.get(tileCoordKey));
tile = /** @type {!import("../Tile.js").default} */ (tileCache.get(
tileCoordKey
));
loaded = tile.getState() === TileState.LOADED;
if (loaded) {
loaded = (callback(tile) !== false);
loaded = callback(tile) !== false;
}
}
if (!loaded) {
@@ -304,8 +310,8 @@ class TileSource extends Source {
* null if no tile URL should be created for the passed `tileCoord`.
*/
getTileCoordForTileUrlFunction(tileCoord, opt_projection) {
const projection = opt_projection !== undefined ?
opt_projection : this.getProjection();
const projection =
opt_projection !== undefined ? opt_projection : this.getProjection();
const tileGrid = this.getTileGridForProjection(projection);
if (this.getWrapX() && projection.isGlobal()) {
tileCoord = wrapX(tileGrid, tileCoord, projection);
@@ -335,10 +341,8 @@ class TileSource extends Source {
* @param {import("../proj/Projection.js").default} projection Projection.
*/
useTile(z, x, y, projection) {}
}
/**
* @classdesc
* Events emitted by {@link module:ol/source/Tile~TileSource} instances are instances of this
@@ -350,7 +354,6 @@ export class TileSourceEvent extends Event {
* @param {import("../Tile.js").default} tile The tile.
*/
constructor(type, tile) {
super(type);
/**
@@ -359,9 +362,7 @@ export class TileSourceEvent extends Event {
* @api
*/
this.tile = tile;
}
}
export default TileSource;