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

@@ -2,12 +2,10 @@ import ImageTile from '../../../src/ol/ImageTile.js';
import Tile from '../../../src/ol/Tile.js';
import TileQueue from '../../../src/ol/TileQueue.js';
import TileState from '../../../src/ol/TileState.js';
import {defaultImageLoadFunction} from '../../../src/ol/source/Image.js';
import {DROP} from '../../../src/ol/structs/PriorityQueue.js';
import {defaultImageLoadFunction} from '../../../src/ol/source/Image.js';
describe('ol.TileQueue', function() {
describe('ol.TileQueue', function () {
function addRandomPriorityTiles(tq, num) {
let i, tile, priority;
for (i = 0; i < num; i++) {
@@ -27,19 +25,22 @@ describe('ol.TileQueue', function() {
// The tile queue requires a unique URI for each item added.
// Browsers still load the resource even if they don't understand
// the charset. So we create a unique URI by abusing the charset.
const src = 'data:image/gif;charset=junk-' + tileId +
';base64,R0lGODlhAQABAPAAAP8AAP///' +
'yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
const src =
'data:image/gif;charset=junk-' +
tileId +
';base64,R0lGODlhAQABAPAAAP8AAP///' +
'yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
const tileLoadFunction = opt_tileLoadFunction ?
opt_tileLoadFunction : defaultImageLoadFunction;
const tileLoadFunction = opt_tileLoadFunction
? opt_tileLoadFunction
: defaultImageLoadFunction;
return new ImageTile(tileCoord, state, src, null, tileLoadFunction);
}
describe('#loadMoreTiles()', function() {
const noop = function() {};
describe('#loadMoreTiles()', function () {
const noop = function () {};
it('works when tile queues share tiles', function(done) {
it('works when tile queues share tiles', function (done) {
const q1 = new TileQueue(noop, noop);
const q2 = new TileQueue(noop, noop);
@@ -73,7 +74,7 @@ describe('ol.TileQueue', function() {
expect(q2.getCount()).to.equal(0);
// let all tiles load
setTimeout(function() {
setTimeout(function () {
expect(q1.getTilesLoading()).to.equal(0);
expect(q2.getTilesLoading()).to.equal(0);
@@ -86,25 +87,21 @@ describe('ol.TileQueue', function() {
done();
}, 20);
});
});
describe('heapify', function() {
it('does convert an arbitrary array into a heap', function() {
const tq = new TileQueue(function() {});
describe('heapify', function () {
it('does convert an arbitrary array into a heap', function () {
const tq = new TileQueue(function () {});
addRandomPriorityTiles(tq, 100);
tq.heapify_();
});
});
describe('reprioritize', function() {
it('does reprioritize the array', function() {
const tq = new TileQueue(function() {});
describe('reprioritize', function () {
it('does reprioritize the array', function () {
const tq = new TileQueue(function () {});
addRandomPriorityTiles(tq, 100);
tq.heapify_();
@@ -113,8 +110,8 @@ describe('ol.TileQueue', function() {
// rest
let i = 0;
tq.priorityFunction_ = function() {
if ((i++) % 2 === 0) {
tq.priorityFunction_ = function () {
if (i++ % 2 === 0) {
return DROP;
}
return Math.floor(Math.random() * 100);
@@ -123,14 +120,13 @@ describe('ol.TileQueue', function() {
tq.reprioritize();
expect(tq.elements_.length).to.eql(50);
expect(tq.priorities_.length).to.eql(50);
});
});
describe('tile change event', function() {
const noop = function() {};
describe('tile change event', function () {
const noop = function () {};
it('loaded tiles', function() {
it('loaded tiles', function () {
const tq = new TileQueue(noop, noop);
const tile = createImageTile();
expect(tile.hasListener('change')).to.be(false);
@@ -142,7 +138,7 @@ describe('ol.TileQueue', function() {
expect(tile.hasListener('change')).to.be(false);
});
it('error tiles', function() {
it('error tiles', function () {
const tq = new TileQueue(noop, noop);
const tile = createImageTile(noop);
@@ -154,9 +150,6 @@ describe('ol.TileQueue', function() {
tile.setState(TileState.ERROR);
expect(tq.getTilesLoading()).to.eql(0);
expect(tile.hasListener('change')).to.be(false);
});
});
});