Use blocked scoped variables

In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions

View File

@@ -9,7 +9,7 @@ import PriorityQueue from '../../../src/ol/structs/PriorityQueue.js';
describe('ol.TileQueue', function() {
function addRandomPriorityTiles(tq, num) {
var i, tile, priority;
let i, tile, priority;
for (i = 0; i < num; i++) {
tile = new Tile();
priority = Math.floor(Math.random() * 100);
@@ -19,33 +19,33 @@ describe('ol.TileQueue', function() {
}
}
var tileId = 0;
let tileId = 0;
function createImageTile(opt_tileLoadFunction) {
++tileId;
var tileCoord = [tileId, tileId, tileId];
var state = 0; // IDLE
const tileCoord = [tileId, tileId, tileId];
const state = 0; // IDLE
// 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.
var src = 'data:image/gif;charset=junk-' + tileId +
const src = 'data:image/gif;charset=junk-' + tileId +
';base64,R0lGODlhAQABAPAAAP8AAP///' +
'yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
var tileLoadFunction = opt_tileLoadFunction ?
const tileLoadFunction = opt_tileLoadFunction ?
opt_tileLoadFunction : ImageSource.defaultImageLoadFunction;
return new ImageTile(tileCoord, state, src, null, tileLoadFunction);
}
describe('#loadMoreTiles()', function() {
var noop = function() {};
const noop = function() {};
it('works when tile queues share tiles', function(done) {
var q1 = new TileQueue(noop, noop);
var q2 = new TileQueue(noop, noop);
const q1 = new TileQueue(noop, noop);
const q2 = new TileQueue(noop, noop);
var numTiles = 20;
for (var i = 0; i < numTiles; ++i) {
var tile = createImageTile();
const numTiles = 20;
for (let i = 0; i < numTiles; ++i) {
const tile = createImageTile();
q1.enqueue([tile]);
q2.enqueue([tile]);
}
@@ -54,7 +54,7 @@ describe('ol.TileQueue', function() {
expect(q1.getCount()).to.equal(numTiles);
expect(q2.getCount()).to.equal(numTiles);
var maxLoading = numTiles / 2;
const maxLoading = numTiles / 2;
// and nothing is loading
expect(q1.getTilesLoading()).to.equal(0);
@@ -90,15 +90,15 @@ describe('ol.TileQueue', function() {
});
it('calls #tileChangeCallback_ when all wanted tiles are aborted', function() {
var tileChangeCallback = sinon.spy();
var queue = new TileQueue(noop, tileChangeCallback);
var numTiles = 20;
for (var i = 0; i < numTiles; ++i) {
var tile = createImageTile();
const tileChangeCallback = sinon.spy();
const queue = new TileQueue(noop, tileChangeCallback);
const numTiles = 20;
for (let i = 0; i < numTiles; ++i) {
const tile = createImageTile();
tile.state = TileState.ABORT;
queue.enqueue([tile]);
}
var maxLoading = numTiles / 2;
const maxLoading = numTiles / 2;
queue.loadMoreTiles(maxLoading, maxLoading);
expect(tileChangeCallback.callCount).to.be(1);
});
@@ -108,7 +108,7 @@ describe('ol.TileQueue', function() {
describe('heapify', function() {
it('does convert an arbitrary array into a heap', function() {
var tq = new TileQueue(function() {});
const tq = new TileQueue(function() {});
addRandomPriorityTiles(tq, 100);
tq.heapify_();
@@ -118,7 +118,7 @@ describe('ol.TileQueue', function() {
describe('reprioritize', function() {
it('does reprioritize the array', function() {
var tq = new TileQueue(function() {});
const tq = new TileQueue(function() {});
addRandomPriorityTiles(tq, 100);
tq.heapify_();
@@ -126,7 +126,7 @@ describe('ol.TileQueue', function() {
// now reprioritize, changing the priority of 50 tiles and removing the
// rest
var i = 0;
let i = 0;
tq.priorityFunction_ = function() {
if ((i++) % 2 === 0) {
return PriorityQueue.DROP;
@@ -142,11 +142,11 @@ describe('ol.TileQueue', function() {
});
describe('tile change event', function() {
var noop = function() {};
const noop = function() {};
it('abort queued tiles', function() {
var tq = new TileQueue(noop, noop);
var tile = createImageTile();
const tq = new TileQueue(noop, noop);
const tile = createImageTile();
expect(tile.hasListener('change')).to.be(false);
tq.enqueue([tile]);
@@ -158,8 +158,8 @@ describe('ol.TileQueue', function() {
});
it('abort loading tiles', function() {
var tq = new TileQueue(noop, noop);
var tile = createImageTile(noop);
const tq = new TileQueue(noop, noop);
const tile = createImageTile(noop);
tq.enqueue([tile]);
tq.loadMoreTiles(Infinity, Infinity);