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,71 +1,66 @@
import GeoJSON from '../../../../src/ol/format/GeoJSON.js';
import Map from '../../../../src/ol/Map.js';
import VectorTileLayer from '../../../../src/ol/layer/VectorTile.js';
import VectorTileSource from '../../../../src/ol/source/VectorTile.js';
import GeoJSON from '../../../../src/ol/format/GeoJSON.js';
import View from '../../../../src/ol/View.js';
import Map from '../../../../src/ol/Map.js';
import {fromLonLat} from '../../../../src/ol/proj.js';
describe('ol.layer.VectorTile', function() {
describe('constructor (defaults)', function() {
describe('ol.layer.VectorTile', function () {
describe('constructor (defaults)', function () {
let layer;
beforeEach(function() {
beforeEach(function () {
layer = new VectorTileLayer({
source: new VectorTileSource({})
source: new VectorTileSource({}),
});
});
afterEach(function() {
afterEach(function () {
layer.dispose();
});
it('creates an instance', function() {
it('creates an instance', function () {
expect(layer).to.be.a(VectorTileLayer);
});
it('provides default preload', function() {
it('provides default preload', function () {
expect(layer.getPreload()).to.be(0);
});
it('provides default useInterimTilesOnError', function() {
it('provides default useInterimTilesOnError', function () {
expect(layer.getUseInterimTilesOnError()).to.be(true);
});
it('provides default renderMode', function() {
it('provides default renderMode', function () {
expect(layer.getRenderMode()).to.be('hybrid');
});
});
describe('constructor (options)', function() {
it('works with options', function() {
describe('constructor (options)', function () {
it('works with options', function () {
let layer = new VectorTileLayer({
renderMode: 'hybrid',
source: new VectorTileSource({})
source: new VectorTileSource({}),
});
expect(layer.getRenderMode()).to.be('hybrid');
layer = new VectorTileLayer({
renderMode: 'image',
source: new VectorTileSource({})
source: new VectorTileSource({}),
});
expect(layer.getRenderMode()).to.be('image');
expect(function() {
expect(function () {
layer = new VectorTileLayer({
renderMode: 'foo',
source: new VectorTileSource({})
source: new VectorTileSource({}),
});
}).to.throwException();
});
});
describe('#getFeatures()', function() {
describe('#getFeatures()', function () {
let map, layer;
beforeEach(function() {
beforeEach(function () {
layer = new VectorTileLayer({
source: new VectorTileSource({
format: new GeoJSON(),
@@ -95,8 +90,8 @@ describe('ol.layer.VectorTile', function() {
}
]
}
`
})
`,
}),
});
const container = document.createElement('div');
container.style.width = '256px';
@@ -104,56 +99,60 @@ describe('ol.layer.VectorTile', function() {
document.body.appendChild(container);
map = new Map({
target: container,
layers: [
layer
],
layers: [layer],
view: new View({
zoom: 0,
center: [0, 0]
})
center: [0, 0],
}),
});
});
afterEach(function() {
afterEach(function () {
document.body.removeChild(map.getTargetElement());
map.setTarget(null);
});
it('detects features properly', function(done) {
map.once('rendercomplete', function() {
it('detects features properly', function (done) {
map.once('rendercomplete', function () {
const pixel = map.getPixelFromCoordinate(fromLonLat([-36, 0]));
layer.getFeatures(pixel).then(function(features) {
expect(features[0].get('name')).to.be('feature1');
done();
}).catch(done);
layer
.getFeatures(pixel)
.then(function (features) {
expect(features[0].get('name')).to.be('feature1');
done();
})
.catch(done);
});
});
it('does not give false positives', function(done) {
map.once('rendercomplete', function() {
it('does not give false positives', function (done) {
map.once('rendercomplete', function () {
const pixel = map.getPixelFromCoordinate(fromLonLat([0, 0]));
layer.getFeatures(pixel).then(function(features) {
expect(features.length).to.be(0);
done();
}).catch(done);
layer
.getFeatures(pixel)
.then(function (features) {
expect(features.length).to.be(0);
done();
})
.catch(done);
});
});
it('stores separate hit detection data for each layer that uses the source', function(done) {
it('stores separate hit detection data for each layer that uses the source', function (done) {
const layer2 = new VectorTileLayer({
source: layer.getSource()
source: layer.getSource(),
});
map.addLayer(layer2);
map.once('rendercomplete', function() {
map.once('rendercomplete', function () {
const pixel = map.getPixelFromCoordinate(fromLonLat([-36, 0]));
Promise.all([layer.getFeatures(pixel), layer2.getFeatures(pixel)]).then(function(result) {
const tile = layer.getSource().tileCache.get('0/0/0');
expect(Object.keys(tile.hitDetectionImageData).length).to.be(2);
done();
}).catch(done);
Promise.all([layer.getFeatures(pixel), layer2.getFeatures(pixel)])
.then(function (result) {
const tile = layer.getSource().tileCache.get('0/0/0');
expect(Object.keys(tile.hitDetectionImageData).length).to.be(2);
done();
})
.catch(done);
});
});
});
});