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,34 +1,32 @@
import TileState from '../../../src/ol/TileState.js';
import {defaultLoadFunction} from '../../../src/ol/source/VectorTile.js';
import VectorTileSource from '../../../src/ol/source/VectorTile.js';
import {listen, unlistenByKey} from '../../../src/ol/events.js';
import EventType from '../../../src/ol/events/EventType.js';
import GeoJSON from '../../../src/ol/format/GeoJSON.js';
import TileGrid from '../../../src/ol/tilegrid/TileGrid.js';
import EventType from '../../../src/ol/events/EventType.js';
import TileState from '../../../src/ol/TileState.js';
import VectorTileSource from '../../../src/ol/source/VectorTile.js';
import {defaultLoadFunction} from '../../../src/ol/source/VectorTile.js';
import {listen, unlistenByKey} from '../../../src/ol/events.js';
describe('ol.VectorRenderTile', function() {
it('triggers "change" when previously failed source tiles are loaded', function(done) {
describe('ol.VectorRenderTile', function () {
it('triggers "change" when previously failed source tiles are loaded', function (done) {
let sourceTile;
const source = new VectorTileSource({
format: new GeoJSON(),
url: 'spec/ol/data/unavailable.json',
tileLoadFunction: function(tile, url) {
tileLoadFunction: function (tile, url) {
sourceTile = tile;
defaultLoadFunction(tile, url);
}
},
});
const tile = source.getTile(0, 0, 0, 1, source.getProjection());
tile.load();
let calls = 0;
listen(tile, 'change', function(e) {
listen(tile, 'change', function (e) {
++calls;
if (calls === 1) {
expect(tile.getState()).to.be(TileState.LOADED);
expect(tile.hifi).to.be(false);
setTimeout(function() {
setTimeout(function () {
sourceTile.setState(TileState.LOADED);
expect(tile.hifi).to.be(true);
}, 0);
@@ -38,26 +36,26 @@ describe('ol.VectorRenderTile', function() {
});
});
it('sets LOADED state and hifi==false when source tiles fail to load', function(done) {
it('sets LOADED state and hifi==false when source tiles fail to load', function (done) {
const source = new VectorTileSource({
format: new GeoJSON(),
url: 'spec/ol/data/unavailable.json'
url: 'spec/ol/data/unavailable.json',
});
const tile = source.getTile(0, 0, 0, 1, source.getProjection());
tile.load();
listen(tile, 'change', function(e) {
listen(tile, 'change', function (e) {
expect(tile.getState()).to.be(TileState.LOADED);
expect(tile.hifi).to.be(false);
done();
});
});
it('sets EMPTY state when tile has only empty source tiles', function() {
it('sets EMPTY state when tile has only empty source tiles', function () {
const source = new VectorTileSource({
format: new GeoJSON(),
url: ''
url: '',
});
const tile = source.getTile(0, 0, 0, 1, source.getProjection());
@@ -65,7 +63,7 @@ describe('ol.VectorRenderTile', function() {
expect(tile.getState()).to.be(TileState.EMPTY);
});
it('only loads tiles within the source tileGrid\'s extent', function(done) {
it("only loads tiles within the source tileGrid's extent", function (done) {
const url = 'spec/ol/data/point.json';
const source = new VectorTileSource({
projection: 'EPSG:4326',
@@ -73,25 +71,28 @@ describe('ol.VectorRenderTile', function() {
tileGrid: new TileGrid({
resolutions: [0.02197265625, 0.010986328125, 0.0054931640625],
origin: [-180, 90],
extent: [-88, 35, -87, 36]
extent: [-88, 35, -87, 36],
}),
tileUrlFunction: function(zxy) {
tileUrlFunction: function (zxy) {
return url;
},
url: url
url: url,
});
const tile = source.getTile(0, 0, 0, 1, source.getProjection());
tile.load();
const key = listen(tile, EventType.CHANGE, function() {
const key = listen(tile, EventType.CHANGE, function () {
if (tile.getState() === TileState.LOADED) {
unlistenByKey(key);
const sourceTiles = source.getSourceTiles(1, source.getProjection(), tile);
const sourceTiles = source.getSourceTiles(
1,
source.getProjection(),
tile
);
expect(sourceTiles.length).to.be(1);
expect(sourceTiles[0].tileCoord).to.eql([0, 16, 9]);
done();
}
});
});
});