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
+44 -44
View File
@@ -5,7 +5,7 @@ describe('ol.geom.Circle', function() {
describe('with a unit circle', function() {
var circle;
let circle;
beforeEach(function() {
circle = new Circle([0, 0], 1);
});
@@ -13,7 +13,7 @@ describe('ol.geom.Circle', function() {
describe('#clone', function() {
it('returns a clone', function() {
var clone = circle.clone();
const clone = circle.clone();
expect(clone).to.be.an(Circle);
expect(clone.getCenter()).to.eql(circle.getCenter());
expect(clone.getCenter()).not.to.be(circle.getCenter());
@@ -62,7 +62,7 @@ describe('ol.geom.Circle', function() {
describe('#getClosestPoint', function() {
it('returns the closest point on the perimeter', function() {
var closestPoint;
let closestPoint;
closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint[0]).to.roughlyEqual(1, 1e-15);
expect(closestPoint[1]).to.roughlyEqual(0, 1e-15);
@@ -90,9 +90,9 @@ describe('ol.geom.Circle', function() {
});
it('maintains Z coordinates', function() {
var circle = new Circle([0, 0, 1], 1);
const circle = new Circle([0, 0, 1], 1);
expect(circle.getLayout()).to.be('XYZ');
var closestPoint = circle.getClosestPoint([2, 0]);
const closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint).to.have.length(3);
expect(closestPoint[0]).to.roughlyEqual(1, 1e-15);
expect(closestPoint[1]).to.roughlyEqual(0, 1e-15);
@@ -100,9 +100,9 @@ describe('ol.geom.Circle', function() {
});
it('maintains M coordinates', function() {
var circle = new Circle([0, 0, 2], 1,
'XYM');
var closestPoint = circle.getClosestPoint([2, 0]);
const circle = new Circle([0, 0, 2], 1,
'XYM');
const closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint).to.have.length(3);
expect(closestPoint[0]).to.roughlyEqual(1, 1e-15);
expect(closestPoint[1]).to.roughlyEqual(0, 1e-15);
@@ -110,9 +110,9 @@ describe('ol.geom.Circle', function() {
});
it('maintains Z and M coordinates', function() {
var circle = new Circle([0, 0, 1, 2], 1);
const circle = new Circle([0, 0, 1, 2], 1);
expect(circle.getLayout()).to.be('XYZM');
var closestPoint = circle.getClosestPoint([2, 0]);
const closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint).to.have.length(4);
expect(closestPoint[0]).to.roughlyEqual(1, 1e-15);
expect(closestPoint[1]).to.roughlyEqual(0, 1e-15);
@@ -162,7 +162,7 @@ describe('ol.geom.Circle', function() {
});
it('fires a change event', function() {
var spy = sinon.spy();
const spy = sinon.spy();
circle.on('change', spy);
circle.setCenter([1, 2]);
expect(spy.calledOnce).to.be(true);
@@ -179,7 +179,7 @@ describe('ol.geom.Circle', function() {
});
it('fires a single change event', function() {
var spy = sinon.spy();
const spy = sinon.spy();
circle.on('change', spy);
circle.setFlatCoordinates('XY', [1, 2, 4, 2]);
expect(spy.calledOnce).to.be(true);
@@ -195,7 +195,7 @@ describe('ol.geom.Circle', function() {
});
it('fires a change event', function() {
var spy = sinon.spy();
const spy = sinon.spy();
circle.on('change', spy);
circle.setRadius(2);
expect(spy.calledOnce).to.be(true);
@@ -206,36 +206,36 @@ describe('ol.geom.Circle', function() {
describe('#intersectsExtent', function() {
it('returns false for non-intersecting extents (wide outside own bbox)',
function() {
var wideOutsideLeftTop = [-3, 2, -2, 3];
var wideOutsideRightTop = [2, 2, 3, 3];
var wideOutsideRightBottom = [2, -3, 3, -2];
var wideOutsideLeftBottom = [-3, -3, -2, -2];
expect(circle.intersectsExtent(wideOutsideLeftTop)).to.be(false);
expect(circle.intersectsExtent(wideOutsideRightTop)).to.be(false);
expect(circle.intersectsExtent(wideOutsideRightBottom)).to.be(false);
expect(circle.intersectsExtent(wideOutsideLeftBottom)).to.be(false);
}
function() {
const wideOutsideLeftTop = [-3, 2, -2, 3];
const wideOutsideRightTop = [2, 2, 3, 3];
const wideOutsideRightBottom = [2, -3, 3, -2];
const wideOutsideLeftBottom = [-3, -3, -2, -2];
expect(circle.intersectsExtent(wideOutsideLeftTop)).to.be(false);
expect(circle.intersectsExtent(wideOutsideRightTop)).to.be(false);
expect(circle.intersectsExtent(wideOutsideRightBottom)).to.be(false);
expect(circle.intersectsExtent(wideOutsideLeftBottom)).to.be(false);
}
);
it('returns false for non-intersecting extents (inside own bbox)',
function() {
var nearOutsideLeftTop = [-1, 0.9, -0.9, 1];
var nearOutsideRightTop = [0.9, 0.9, 1, 1];
var nearOutsideRightBottom = [0.9, -1, 1, -0.9];
var nearOutsideLeftBottom = [-1, -1, -0.9, -0.9];
expect(circle.intersectsExtent(nearOutsideLeftTop)).to.be(false);
expect(circle.intersectsExtent(nearOutsideRightTop)).to.be(false);
expect(circle.intersectsExtent(nearOutsideRightBottom)).to.be(false);
expect(circle.intersectsExtent(nearOutsideLeftBottom)).to.be(false);
}
function() {
const nearOutsideLeftTop = [-1, 0.9, -0.9, 1];
const nearOutsideRightTop = [0.9, 0.9, 1, 1];
const nearOutsideRightBottom = [0.9, -1, 1, -0.9];
const nearOutsideLeftBottom = [-1, -1, -0.9, -0.9];
expect(circle.intersectsExtent(nearOutsideLeftTop)).to.be(false);
expect(circle.intersectsExtent(nearOutsideRightTop)).to.be(false);
expect(circle.intersectsExtent(nearOutsideRightBottom)).to.be(false);
expect(circle.intersectsExtent(nearOutsideLeftBottom)).to.be(false);
}
);
it('returns true for extents that intersect clearly', function() {
var intersectingLeftTop = [-1.5, 0.5, -0.5, 1.5];
var intersectingRightTop = [0.5, 0.5, 1.5, 1.5];
var intersectingRightBottom = [0.5, -1.5, 1.5, -0.5];
var intersectingLeftBottom = [-1.5, -1.5, -0.5, -0.5];
const intersectingLeftTop = [-1.5, 0.5, -0.5, 1.5];
const intersectingRightTop = [0.5, 0.5, 1.5, 1.5];
const intersectingRightBottom = [0.5, -1.5, 1.5, -0.5];
const intersectingLeftBottom = [-1.5, -1.5, -0.5, -0.5];
expect(circle.intersectsExtent(intersectingLeftTop)).to.be(true);
expect(circle.intersectsExtent(intersectingRightTop)).to.be(true);
expect(circle.intersectsExtent(intersectingRightBottom)).to.be(true);
@@ -243,10 +243,10 @@ describe('ol.geom.Circle', function() {
});
it('returns true for extents that touch the circumference', function() {
var touchCircumferenceLeft = [-2, 0, -1, 1];
var touchCircumferenceTop = [0, 1, 1, 2];
var touchCircumferenceRight = [1, -1, 2, 0];
var touchCircumferenceBottom = [-1, -2, 0, -1];
const touchCircumferenceLeft = [-2, 0, -1, 1];
const touchCircumferenceTop = [0, 1, 1, 2];
const touchCircumferenceRight = [1, -1, 2, 0];
const touchCircumferenceBottom = [-1, -2, 0, -1];
expect(circle.intersectsExtent(touchCircumferenceLeft)).to.be(true);
expect(circle.intersectsExtent(touchCircumferenceTop)).to.be(true);
expect(circle.intersectsExtent(touchCircumferenceRight)).to.be(true);
@@ -254,17 +254,17 @@ describe('ol.geom.Circle', function() {
});
it('returns true for a contained extent', function() {
var containedExtent = [-0.5, -0.5, 0.5, 0.5];
const containedExtent = [-0.5, -0.5, 0.5, 0.5];
expect(circle.intersectsExtent(containedExtent)).to.be(true);
});
it('returns true for a covering extent', function() {
var bigCoveringExtent = [-5, -5, 5, 5];
const bigCoveringExtent = [-5, -5, 5, 5];
expect(circle.intersectsExtent(bigCoveringExtent)).to.be(true);
});
it('returns true for the geom\'s own extent', function() {
var circleExtent = circle.getExtent();
const circleExtent = circle.getExtent();
expect(circle.intersectsExtent(circleExtent)).to.be(true);
});