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,18 +1,17 @@
import Attribution from '../../../../src/ol/control/Attribution.js';
import Map from '../../../../src/ol/Map.js';
import Tile from '../../../../src/ol/Tile.js';
import View from '../../../../src/ol/View.js';
import Attribution from '../../../../src/ol/control/Attribution.js';
import TileLayer from '../../../../src/ol/layer/Tile.js';
import TileSource from '../../../../src/ol/source/Tile.js';
import View from '../../../../src/ol/View.js';
import {createXYZ} from '../../../../src/ol/tilegrid.js';
describe('ol.control.Attribution', function() {
describe('ol.control.Attribution', function () {
let map;
const tileLoadFunction = function() {
const tileLoadFunction = function () {
const tile = new Tile([0, 0, -1], 2 /* LOADED */);
tile.getImage = function() {
tile.getImage = function () {
const image = new Image();
image.width = 256;
image.height = 256;
@@ -21,98 +20,107 @@ describe('ol.control.Attribution', function() {
return tile;
};
beforeEach(function() {
beforeEach(function () {
const target = document.createElement('div');
target.style.width = '100px';
target.style.height = '100px';
document.body.appendChild(target);
map = new Map({
target: target,
controls: [new Attribution({
collapsed: false,
collapsible: false
})],
controls: [
new Attribution({
collapsed: false,
collapsible: false,
}),
],
layers: [
new TileLayer({
source: new TileSource({
projection: 'EPSG:3857',
tileGrid: createXYZ(),
attributions: 'foo'
})
attributions: 'foo',
}),
}),
new TileLayer({
source: new TileSource({
projection: 'EPSG:3857',
tileGrid: createXYZ(),
attributions: 'bar'
})
attributions: 'bar',
}),
}),
new TileLayer({
source: new TileSource({
projection: 'EPSG:3857',
tileGrid: createXYZ(),
attributions: 'foo'
})
})
attributions: 'foo',
}),
}),
],
view: new View({
center: [0, 0],
zoom: 0
})
zoom: 0,
}),
});
map.getLayers().forEach(function(layer) {
map.getLayers().forEach(function (layer) {
const source = layer.getSource();
source.getTile = tileLoadFunction;
});
});
afterEach(function() {
afterEach(function () {
disposeMap(map);
map = null;
});
it('does not add duplicate attributions', function() {
it('does not add duplicate attributions', function () {
map.renderSync();
const attribution = map.getTarget().querySelectorAll('.ol-attribution li');
expect(attribution.length).to.be(2);
});
it('renders attributions as non-collapsible if source is configured with attributionsCollapsible set to false', function() {
it('renders attributions as non-collapsible if source is configured with attributionsCollapsible set to false', function () {
map.getControls().clear();
map.addControl(new Attribution());
const source = new TileSource({
projection: 'EPSG:3857',
tileGrid: createXYZ(),
attributions: 'foo',
attributionsCollapsible: false
attributionsCollapsible: false,
});
source.getTile = tileLoadFunction;
map.addLayer(new TileLayer({
source: source
}));
map.addLayer(
new TileLayer({
source: source,
})
);
map.renderSync();
const attribution = map.getTarget().querySelectorAll('.ol-attribution.ol-uncollapsible');
const attribution = map
.getTarget()
.querySelectorAll('.ol-attribution.ol-uncollapsible');
expect(attribution.length).to.be(1);
});
it('renders attributions as collapsible if configured with collapsible set to true', function() {
it('renders attributions as collapsible if configured with collapsible set to true', function () {
map.getControls().clear();
map.addControl(new Attribution({collapsible: true}));
const source = new TileSource({
projection: 'EPSG:3857',
tileGrid: createXYZ(),
attributions: 'foo',
attributionsCollapsible: false
attributionsCollapsible: false,
});
source.getTile = tileLoadFunction;
map.addLayer(new TileLayer({
source: source
}));
map.addLayer(
new TileLayer({
source: source,
})
);
map.renderSync();
const attribution = map.getTarget().querySelectorAll('.ol-attribution.ol-uncollapsible');
const attribution = map
.getTarget()
.querySelectorAll('.ol-attribution.ol-uncollapsible');
expect(attribution.length).to.be(0);
});
});