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,35 +1,39 @@
import Map from '../src/ol/Map.js';
import Overlay from '../src/ol/Overlay.js';
import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js';
import TileJSON from '../src/ol/source/TileJSON.js';
import TileLayer from '../src/ol/layer/Tile.js';
import UTFGrid from '../src/ol/source/UTFGrid.js';
import View from '../src/ol/View.js';
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
const key =
'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
const mapLayer = new TileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v4/mapbox.geography-class.json?secure&access_token=' + key
})
url:
'https://api.tiles.mapbox.com/v4/mapbox.geography-class.json?secure&access_token=' +
key,
}),
});
const gridSource = new UTFGrid({
url: 'https://api.tiles.mapbox.com/v4/mapbox.geography-class.json?secure&access_token=' + key
url:
'https://api.tiles.mapbox.com/v4/mapbox.geography-class.json?secure&access_token=' +
key,
});
const gridLayer = new TileLayer({source: gridSource});
const view = new View({
center: [0, 0],
zoom: 1
zoom: 1,
});
const mapElement = document.getElementById('map');
const map = new Map({
layers: [mapLayer, gridLayer],
target: mapElement,
view: view
view: view,
});
const infoElement = document.getElementById('country-info');
@@ -39,14 +43,16 @@ const nameElement = document.getElementById('country-name');
const infoOverlay = new Overlay({
element: infoElement,
offset: [15, 15],
stopEvent: false
stopEvent: false,
});
map.addOverlay(infoOverlay);
const displayCountryInfo = function(coordinate) {
const displayCountryInfo = function (coordinate) {
const viewResolution = /** @type {number} */ (view.getResolution());
gridSource.forDataAtCoordinateAndResolution(coordinate, viewResolution,
function(data) {
gridSource.forDataAtCoordinateAndResolution(
coordinate,
viewResolution,
function (data) {
// If you want to use the template from the TileJSON,
// load the mustache.js library separately and call
// info.innerHTML = Mustache.render(gridSource.getTemplate(), data);
@@ -56,10 +62,11 @@ const displayCountryInfo = function(coordinate) {
nameElement.innerHTML = data['admin'];
}
infoOverlay.setPosition(data ? coordinate : undefined);
});
}
);
};
map.on('pointermove', function(evt) {
map.on('pointermove', function (evt) {
if (evt.dragging) {
return;
}
@@ -67,6 +74,6 @@ map.on('pointermove', function(evt) {
displayCountryInfo(coordinate);
});
map.on('click', function(evt) {
map.on('click', function (evt) {
displayCountryInfo(evt.coordinate);
});