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:
+34
-25
@@ -4,11 +4,10 @@
|
||||
|
||||
import Tile from '../Tile.js';
|
||||
import TileState from '../TileState.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import {toSize} from '../size.js';
|
||||
import XYZ from './XYZ.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import {getKeyZXY} from '../tilecoord.js';
|
||||
|
||||
import {toSize} from '../size.js';
|
||||
|
||||
class LabeledTile extends Tile {
|
||||
/**
|
||||
@@ -17,33 +16,31 @@ class LabeledTile extends Tile {
|
||||
* @param {string} text Text.
|
||||
*/
|
||||
constructor(tileCoord, tileSize, text) {
|
||||
|
||||
super(tileCoord, TileState.LOADED);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {import("../size.js").Size}
|
||||
*/
|
||||
* @private
|
||||
* @type {import("../size.js").Size}
|
||||
*/
|
||||
this.tileSize_ = tileSize;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.text_ = text;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
* @private
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
this.canvas_ = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the image element for this tile.
|
||||
* @return {HTMLCanvasElement} Image.
|
||||
*/
|
||||
* Get the image element for this tile.
|
||||
* @return {HTMLCanvasElement} Image.
|
||||
*/
|
||||
getImage() {
|
||||
if (this.canvas_) {
|
||||
return this.canvas_;
|
||||
@@ -60,8 +57,18 @@ class LabeledTile extends Tile {
|
||||
context.textBaseline = 'middle';
|
||||
context.font = '24px sans-serif';
|
||||
context.lineWidth = 4;
|
||||
context.strokeText(this.text_, tileSize[0] / 2, tileSize[1] / 2, tileSize[0]);
|
||||
context.fillText(this.text_, tileSize[0] / 2, tileSize[1] / 2, tileSize[0]);
|
||||
context.strokeText(
|
||||
this.text_,
|
||||
tileSize[0] / 2,
|
||||
tileSize[1] / 2,
|
||||
tileSize[0]
|
||||
);
|
||||
context.fillText(
|
||||
this.text_,
|
||||
tileSize[0] / 2,
|
||||
tileSize[1] / 2,
|
||||
tileSize[0]
|
||||
);
|
||||
|
||||
this.canvas_ = context.canvas;
|
||||
return context.canvas;
|
||||
@@ -71,7 +78,6 @@ class LabeledTile extends Tile {
|
||||
load() {}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Optional projection.
|
||||
@@ -84,7 +90,6 @@ class LabeledTile extends Tile {
|
||||
* nearest higher resolution will be used.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* A pseudo tile source, which does not fetch tiles from a server, but renders
|
||||
@@ -109,9 +114,8 @@ class TileDebug extends XYZ {
|
||||
projection: options.projection,
|
||||
tileGrid: options.tileGrid,
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true,
|
||||
zDirection: options.zDirection
|
||||
zDirection: options.zDirection,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +134,13 @@ class TileDebug extends XYZ {
|
||||
const textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
|
||||
let text;
|
||||
if (textTileCoord) {
|
||||
text = 'z:' + textTileCoord[0] + ' x:' + textTileCoord[1] + ' y:' + textTileCoord[2];
|
||||
text =
|
||||
'z:' +
|
||||
textTileCoord[0] +
|
||||
' x:' +
|
||||
textTileCoord[1] +
|
||||
' y:' +
|
||||
textTileCoord[2];
|
||||
} else {
|
||||
text = 'none';
|
||||
}
|
||||
@@ -141,5 +151,4 @@ class TileDebug extends XYZ {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default TileDebug;
|
||||
|
||||
Reference in New Issue
Block a user