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
+45 -45
View File
@@ -6,13 +6,13 @@ import Polygon from '../../../../src/ol/geom/Polygon.js';
describe('ol.geom.GeometryCollection', function() {
var outer = [[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]];
var inner1 = [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]];
var inner2 = [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]];
const outer = [[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]];
const inner1 = [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]];
const inner2 = [[8, 8], [9, 8], [9, 9], [8, 9], [8, 8]];
describe('constructor', function() {
var line, multi, point, poly;
let line, multi, point, poly;
beforeEach(function() {
point = new Point([10, 20]);
line = new LineString([[10, 20], [30, 40]]);
@@ -26,12 +26,12 @@ describe('ol.geom.GeometryCollection', function() {
});
it('fires a change event when one of its component changes',
function(done) {
multi.on('change', function() {
done();
});
point.setCoordinates([10, 10]);
}
function(done) {
multi.on('change', function() {
done();
});
point.setCoordinates([10, 10]);
}
);
it('deregister old components', function() {
@@ -43,7 +43,7 @@ describe('ol.geom.GeometryCollection', function() {
});
it('register new components', function(done) {
var point2 = new Point([10, 20]);
const point2 = new Point([10, 20]);
multi.setGeometriesArray([point2]);
multi.on('change', function() {
done();
@@ -56,12 +56,12 @@ describe('ol.geom.GeometryCollection', function() {
describe('#getGeometries', function() {
it('returns a collection of geometries', function() {
var point = new Point([10, 20]);
var line = new LineString([[10, 20], [30, 40]]);
var poly = new Polygon([outer, inner1, inner2]);
var multi = new GeometryCollection([point, line, poly]);
const point = new Point([10, 20]);
const line = new LineString([[10, 20], [30, 40]]);
const poly = new Polygon([outer, inner1, inner2]);
const multi = new GeometryCollection([point, line, poly]);
var geometries = multi.getGeometries();
const geometries = multi.getGeometries();
expect(geometries).to.be.an(Array);
expect(geometries).to.have.length(3);
expect(geometries[0]).to.be.a(Point);
@@ -74,30 +74,30 @@ describe('ol.geom.GeometryCollection', function() {
describe('#clone()', function() {
it('has a working clone method', function() {
var point = new Point([10, 20]);
var line = new LineString([[10, 20], [30, 40]]);
var poly = new Polygon([outer, inner1, inner2]);
var multi = new GeometryCollection([point, line, poly]);
var clone = multi.clone();
const point = new Point([10, 20]);
const line = new LineString([[10, 20], [30, 40]]);
const poly = new Polygon([outer, inner1, inner2]);
const multi = new GeometryCollection([point, line, poly]);
const clone = multi.clone();
expect(clone).to.not.be(multi);
var geometries = clone.getGeometries();
const geometries = clone.getGeometries();
expect(geometries[0].getCoordinates()).to.eql([10, 20]);
expect(geometries[1].getCoordinates()).to.eql([[10, 20], [30, 40]]);
expect(geometries[2].getCoordinates()).to.eql([outer, inner1, inner2]);
});
it('does a deep clone', function() {
var point = new Point([30, 40]);
var originalGeometries = [point];
var multi = new GeometryCollection(originalGeometries);
var clone = multi.clone();
var clonedGeometries = clone.getGeometries();
const point = new Point([30, 40]);
const originalGeometries = [point];
const multi = new GeometryCollection(originalGeometries);
const clone = multi.clone();
const clonedGeometries = clone.getGeometries();
expect(clonedGeometries).not.to.be(originalGeometries);
expect(clonedGeometries).to.have.length(originalGeometries.length);
expect(clonedGeometries).to.have.length(1);
expect(clonedGeometries[0]).not.to.be(originalGeometries[0]);
expect(clonedGeometries[0].getCoordinates()).
to.eql(originalGeometries[0].getCoordinates());
to.eql(originalGeometries[0].getCoordinates());
});
});
@@ -105,10 +105,10 @@ describe('ol.geom.GeometryCollection', function() {
describe('#getExtent()', function() {
it('returns the bounding extent', function() {
var point = new Point([10, 2]);
var line = new LineString([[1, 20], [30, 40]]);
var multi = new GeometryCollection([point, line]);
var extent = multi.getExtent();
const point = new Point([10, 2]);
const line = new LineString([[1, 20], [30, 40]]);
const multi = new GeometryCollection([point, line]);
const extent = multi.getExtent();
expect(extent[0]).to.be(1);
expect(extent[2]).to.be(30);
expect(extent[1]).to.be(2);
@@ -119,7 +119,7 @@ describe('ol.geom.GeometryCollection', function() {
describe('#intersectsExtent()', function() {
var point, line, poly, multi;
let point, line, poly, multi;
beforeEach(function() {
point = new Point([5, 20]);
@@ -141,7 +141,7 @@ describe('ol.geom.GeometryCollection', function() {
});
it('returns false for non-matching extent within own extent', function() {
var extent = [0, 35, 5, 40];
const extent = [0, 35, 5, 40];
expect(poly.intersectsExtent(extent)).to.be(false);
});
@@ -149,7 +149,7 @@ describe('ol.geom.GeometryCollection', function() {
describe('#setGeometries', function() {
var line, multi, point, poly;
let line, multi, point, poly;
beforeEach(function() {
point = new Point([10, 20]);
line = new LineString([[10, 20], [30, 40]]);
@@ -158,7 +158,7 @@ describe('ol.geom.GeometryCollection', function() {
});
it('fires a change event', function() {
var listener = sinon.spy();
const listener = sinon.spy();
multi.on('change', listener);
multi.setGeometries([point, line, poly]);
expect(listener.calledOnce).to.be(true);
@@ -175,34 +175,34 @@ describe('ol.geom.GeometryCollection', function() {
describe('#scale()', function() {
it('scales a collection', function() {
var geom = new GeometryCollection([
const geom = new GeometryCollection([
new Point([-1, -2]),
new LineString([[0, 0], [1, 2]])
]);
geom.scale(10);
var geometries = geom.getGeometries();
const geometries = geom.getGeometries();
expect(geometries[0].getCoordinates()).to.eql([-10, -20]);
expect(geometries[1].getCoordinates()).to.eql([[0, 0], [10, 20]]);
});
it('accepts sx and sy', function() {
var geom = new GeometryCollection([
const geom = new GeometryCollection([
new Point([-1, -2]),
new LineString([[0, 0], [1, 2]])
]);
geom.scale(2, 3);
var geometries = geom.getGeometries();
const geometries = geom.getGeometries();
expect(geometries[0].getCoordinates()).to.eql([-2, -6]);
expect(geometries[1].getCoordinates()).to.eql([[0, 0], [2, 6]]);
});
it('accepts an anchor', function() {
var geom = new GeometryCollection([
const geom = new GeometryCollection([
new Point([-1, -2]),
new LineString([[0, 0], [1, 2]])
]);
geom.scale(10, 15, [-1, -2]);
var geometries = geom.getGeometries();
const geometries = geom.getGeometries();
expect(geometries[0].getCoordinates()).to.eql([-1, -2]);
expect(geometries[1].getCoordinates()).to.eql([[9, 28], [19, 58]]);
});
@@ -211,7 +211,7 @@ describe('ol.geom.GeometryCollection', function() {
describe('#transform()', function() {
var line, multi, point;
let line, multi, point;
beforeEach(function() {
point = new Point([10, 20]);
line = new LineString([[10, 20], [30, 40]]);
@@ -221,11 +221,11 @@ describe('ol.geom.GeometryCollection', function() {
it('transforms all geometries', function() {
multi.transform('EPSG:4326', 'EPSG:3857');
var geometries = multi.getGeometries();
const geometries = multi.getGeometries();
expect(geometries[0]).to.be.a(Point);
expect(geometries[1]).to.be.a(LineString);
var coords = geometries[0].getCoordinates();
let coords = geometries[0].getCoordinates();
expect(coords[0]).to.roughlyEqual(1113194.90, 1e-2);
expect(coords[1]).to.roughlyEqual(2273030.92, 1e-2);