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

@@ -11,18 +11,18 @@ import Fill from '../../../../../src/ol/style/Fill.js';
import Stroke from '../../../../../src/ol/style/Stroke.js';
describe('ol.render.webgl.PolygonReplay', function() {
var replay;
let replay;
var fillStyle = new Fill({
const fillStyle = new Fill({
color: [0, 0, 255, 0.5]
});
var strokeStyle = new Stroke({
const strokeStyle = new Stroke({
color: [0, 255, 0, 0.4]
});
beforeEach(function() {
var tolerance = 0.1;
var maxExtent = [-10000, -20000, 10000, 20000];
const tolerance = 0.1;
const maxExtent = [-10000, -20000, 10000, 20000];
replay = new _ol_render_webgl_PolygonReplay_(tolerance, maxExtent);
});
@@ -32,8 +32,8 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
it('sets the buffer data', function() {
var polygon1 = new Polygon(
[[[1000, 2000], [1200, 2000], [1200, 3000]]]
const polygon1 = new Polygon(
[[[1000, 2000], [1200, 2000], [1200, 3000]]]
);
replay.drawPolygon(polygon1, null);
expect(replay.vertices).to.have.length(8);
@@ -43,8 +43,8 @@ describe('ol.render.webgl.PolygonReplay', function() {
1000, 2000, 1200, 3000, 1200, 2000, 1000, 2000]);
expect(replay.indices).to.eql([2, 0, 1]);
var polygon2 = new Polygon(
[[[4000, 2000], [4200, 2000], [4200, 3000]]]
const polygon2 = new Polygon(
[[[4000, 2000], [4200, 2000], [4200, 3000]]]
);
replay.drawPolygon(polygon2, null);
expect(replay.vertices).to.have.length(16);
@@ -64,7 +64,7 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
it('sets the buffer data', function() {
var multiPolygon = new MultiPolygon([
const multiPolygon = new MultiPolygon([
[[[1000, 2000], [1200, 2000], [1200, 3000]]],
[[[4000, 2000], [4200, 2000], [4200, 3000]]]
]);
@@ -81,7 +81,7 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
describe('triangulating functions', function() {
var list, rtree;
let list, rtree;
beforeEach(function() {
list = new LinkedList();
rtree = new RBush();
@@ -89,7 +89,7 @@ describe('ol.render.webgl.PolygonReplay', function() {
describe('#createPoint_', function() {
it('creates a WebGL polygon vertex', function() {
var p = replay.createPoint_(1, 1, 1);
const p = replay.createPoint_(1, 1, 1);
expect(p.x).to.be(1);
expect(p.y).to.be(1);
expect(p.i).to.be(1);
@@ -105,20 +105,20 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
describe('#insertItem_', function() {
var p0, p1;
let p0, p1;
beforeEach(function() {
p0 = replay.createPoint_(1, 1, 1);
p1 = replay.createPoint_(2, 2, 2);
});
it('creates a WebGL polygon segment', function() {
var seg = replay.insertItem_(p0, p1, list, rtree);
const seg = replay.insertItem_(p0, p1, list, rtree);
expect(seg.p0).to.be(p0);
expect(seg.p1).to.be(p1);
});
it('inserts the segment into the provided linked list', function() {
var seg = replay.insertItem_(p0, p1, list, rtree);
const seg = replay.insertItem_(p0, p1, list, rtree);
expect(list.head_.data).to.be(seg);
});
@@ -131,13 +131,13 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
describe('#removeItem_', function() {
var s0, s1;
let s0, s1;
beforeEach(function() {
var p = replay.createPoint_(2, 2, 2);
const p = replay.createPoint_(2, 2, 2);
s0 = replay.insertItem_(replay.createPoint_(1, 1, 1),
p, list, rtree);
p, list, rtree);
s1 = replay.insertItem_(p,
replay.createPoint_(5, 2, 3), list, rtree);
replay.createPoint_(5, 2, 3), list, rtree);
});
it('removes the current item', function() {
@@ -147,7 +147,7 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
it('updates the preceding segment', function() {
var dataExtent = rtree.getExtent();
const dataExtent = rtree.getExtent();
replay.removeItem_(s0, s1, list, rtree);
expect(s0.p1).to.be(s1.p1);
expect(rtree.getExtent()).to.eql(dataExtent);
@@ -155,7 +155,7 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
describe('#getPointsInTriangle_', function() {
var p0, p1, p2, p3;
let p0, p1, p2, p3;
beforeEach(function() {
p0 = replay.createPoint_(2, 0, 0);
p1 = replay.createPoint_(0, 5, 1);
@@ -169,20 +169,20 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
it('gets every point in a triangle', function() {
var points = replay.getPointsInTriangle_({x: -3, y: 6}, {x: 7, y: 6},
{x: 2, y: 2}, rtree);
const points = replay.getPointsInTriangle_({x: -3, y: 6}, {x: 7, y: 6},
{x: 2, y: 2}, rtree);
expect(points).to.eql([p1, p2, p3]);
});
it('gets only reflex points in a triangle', function() {
var points = replay.getPointsInTriangle_({x: -3, y: 6}, {x: 7, y: 6},
{x: 2, y: 2}, rtree, true);
const points = replay.getPointsInTriangle_({x: -3, y: 6}, {x: 7, y: 6},
{x: 2, y: 2}, rtree, true);
expect(points).to.eql([p2]);
});
});
describe('#getIntersections_', function() {
var p0, p1, p2, p3, s0, s1, s2, s3;
let p0, p1, p2, p3, s0, s1, s2, s3;
beforeEach(function() {
p0 = replay.createPoint_(2, 0, 0);
p1 = replay.createPoint_(0, 5, 1);
@@ -195,39 +195,39 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
it('gets intersecting, but non touching segments', function() {
var segments = replay.getIntersections_({p0: {x: 0, y: 3}, p1: {x: 4, y: 5}},
rtree);
const segments = replay.getIntersections_({p0: {x: 0, y: 3}, p1: {x: 4, y: 5}},
rtree);
expect(segments).to.eql([s0, s1]);
});
it('gets intersecting and touching segments', function() {
var segments = replay.getIntersections_({p0: {x: 0, y: 3}, p1: {x: 4, y: 5}},
rtree, true);
const segments = replay.getIntersections_({p0: {x: 0, y: 3}, p1: {x: 4, y: 5}},
rtree, true);
expect(segments).to.eql([s0, s1, s2, s3]);
});
});
describe('#calculateIntersection_', function() {
var p0 = {x: 0, y: 0};
var p1 = {x: 4, y: 4};
var p2 = {x: 0, y: 4};
var p3 = {x: 4, y: 0};
const p0 = {x: 0, y: 0};
const p1 = {x: 4, y: 4};
const p2 = {x: 0, y: 4};
const p3 = {x: 4, y: 0};
it('calculates the intersection point of two intersecting segments', function() {
var i = replay.calculateIntersection_(p0, p1, p2, p3);
var t = replay.calculateIntersection_(p0, p1, p1, p2);
const i = replay.calculateIntersection_(p0, p1, p2, p3);
const t = replay.calculateIntersection_(p0, p1, p1, p2);
expect(i).to.eql([2, 2]);
expect(t).to.be(undefined);
});
it('calculates the intersection point of two touching segments', function() {
var t = replay.calculateIntersection_(p0, p1, p1, p2, true);
const t = replay.calculateIntersection_(p0, p1, p1, p2, true);
expect(t).to.eql([4, 4]);
});
});
describe('#diagonalIsInside_', function() {
var p0, p1, p2, p3;
let p0, p1, p2, p3;
beforeEach(function() {
p0 = replay.createPoint_(2, 0, 0);
p1 = replay.createPoint_(0, 5, 1);
@@ -241,18 +241,18 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
it('identifies if diagonal is inside the polygon', function() {
var inside = replay.diagonalIsInside_(p1, p2, p3, p0, p1);
const inside = replay.diagonalIsInside_(p1, p2, p3, p0, p1);
expect(inside).to.be(true);
});
it('identifies if diagonal is outside the polygon', function() {
var inside = replay.diagonalIsInside_(p0, p1, p2, p3, p0);
const inside = replay.diagonalIsInside_(p0, p1, p2, p3, p0);
expect(inside).to.be(false);
});
});
describe('#classifyPoints_', function() {
var p0, p1, p2, p3;
let p0, p1, p2, p3;
beforeEach(function() {
p0 = replay.createPoint_(2, 0, 0);
p1 = replay.createPoint_(0, 5, 1);
@@ -289,7 +289,7 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
describe('#isSimple_', function() {
var p0, p1, p2, p3;
let p0, p1, p2, p3;
beforeEach(function() {
p0 = replay.createPoint_(2, 0, 0);
p1 = replay.createPoint_(0, 5, 1);
@@ -302,24 +302,24 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
it('identifies simple polygons', function() {
var simple = replay.isSimple_(list, rtree);
const simple = replay.isSimple_(list, rtree);
expect(simple).to.be(true);
});
it('identifies self-intersecting polygons', function() {
var p4 = replay.createPoint_(2, 5, 4);
var p5 = replay.createPoint_(4, 2, 5);
const p4 = replay.createPoint_(2, 5, 4);
const p5 = replay.createPoint_(4, 2, 5);
replay.insertItem_(p0, p4, list, rtree);
replay.insertItem_(p4, p5, list, rtree);
replay.insertItem_(p5, p0, list, rtree);
var simple = replay.isSimple_(list, rtree);
const simple = replay.isSimple_(list, rtree);
expect(simple).to.be(false);
});
});
});
describe('#setUpProgram', function() {
var context, gl;
let context, gl;
beforeEach(function() {
context = {
getProgram: function() {},
@@ -336,9 +336,9 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
it('returns the locations used by the shaders', function() {
var locations = replay.setUpProgram(gl, context, [2, 2], 1);
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
expect(locations).to.be.a(
_ol_render_webgl_polygonreplay_defaultshader_Locations_);
_ol_render_webgl_polygonreplay_defaultshader_Locations_);
});
it('gets and compiles the shaders', function() {
@@ -347,8 +347,8 @@ describe('ol.render.webgl.PolygonReplay', function() {
replay.setUpProgram(gl, context, [2, 2], 1);
expect(context.getProgram.calledWithExactly(
_ol_render_webgl_polygonreplay_defaultshader_.fragment,
_ol_render_webgl_polygonreplay_defaultshader_.vertex)).to.be(true);
_ol_render_webgl_polygonreplay_defaultshader_.fragment,
_ol_render_webgl_polygonreplay_defaultshader_.vertex)).to.be(true);
expect(context.useProgram.calledOnce).to.be(true);
});
@@ -360,12 +360,12 @@ describe('ol.render.webgl.PolygonReplay', function() {
replay.setUpProgram(gl, context, [2, 2], 1);
expect(gl.vertexAttribPointer.callCount).to.be(gl.getAttribLocation.callCount);
expect(gl.enableVertexAttribArray.callCount).to.be(
gl.getAttribLocation.callCount);
gl.getAttribLocation.callCount);
});
});
describe('#shutDownProgram', function() {
var context, gl;
let context, gl;
beforeEach(function() {
context = {
getProgram: function() {},
@@ -386,22 +386,22 @@ describe('ol.render.webgl.PolygonReplay', function() {
sinon.spy(gl, 'getAttribLocation');
sinon.spy(gl, 'disableVertexAttribArray');
var locations = replay.setUpProgram(gl, context, [2, 2], 1);
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
replay.shutDownProgram(gl, locations);
expect(gl.disableVertexAttribArray.callCount).to.be(
gl.getAttribLocation.callCount);
gl.getAttribLocation.callCount);
});
});
describe('#drawReplay', function() {
var gl, context;
var feature1 = new Feature({
let gl, context;
const feature1 = new Feature({
geometry: new Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]])
});
var feature2 = new Feature({
const feature2 = new Feature({
geometry: new Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]])
});
var feature3 = new Feature({
const feature3 = new Feature({
geometry: new Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]])
});
beforeEach(function() {
@@ -435,7 +435,7 @@ describe('ol.render.webgl.PolygonReplay', function() {
});
it('draws the elements in batches if there are multiple fill styles', function() {
var fillStyle2 = new Fill({
const fillStyle2 = new Fill({
color: [0, 255, 0, 1]
});
replay.setFillStrokeStyle(fillStyle, strokeStyle);
@@ -459,7 +459,7 @@ describe('ol.render.webgl.PolygonReplay', function() {
replay.setFillStrokeStyle(fillStyle, strokeStyle);
replay.drawPolygon(feature3.getGeometry(), feature3);
replay.startIndices.push(replay.indices.length);
var skippedFeatHash = {};
const skippedFeatHash = {};
skippedFeatHash[getUid(feature2).toString()] = true;
replay.drawReplay(gl, context, skippedFeatHash, false);