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

@@ -21,22 +21,22 @@ describe('ol.render.canvas.ReplayGroup', function() {
describe('#replay', function() {
var context, replay, fillCount, transform;
var strokeCount, beginPathCount, moveToCount, lineToCount;
var feature0, feature1, feature2, feature3;
var fill0, fill1, style1, style2;
let context, replay, fillCount, transform;
let strokeCount, beginPathCount, moveToCount, lineToCount;
let feature0, feature1, feature2, feature3;
let fill0, fill1, style1, style2;
beforeEach(function() {
transform = _ol_transform_.create();
replay = new _ol_render_canvas_ReplayGroup_(1, [-180, -90, 180, 90], 1, 1, false);
feature0 = new Feature(new Polygon(
[[[-90, 0], [-45, 45], [0, 0], [1, 1], [0, -45], [-90, 0]]]));
[[[-90, 0], [-45, 45], [0, 0], [1, 1], [0, -45], [-90, 0]]]));
feature1 = new Feature(new Polygon(
[[[-90, -45], [-90, 0], [0, 0], [0, -45], [-90, -45]]]));
[[[-90, -45], [-90, 0], [0, 0], [0, -45], [-90, -45]]]));
feature2 = new Feature(new Polygon(
[[[90, 45], [90, 0], [0, 0], [0, 45], [90, 45]]]));
[[[90, 45], [90, 0], [0, 0], [0, 45], [90, 45]]]));
feature3 = new Feature(new Polygon(
[[[-90, -45], [-90, 45], [90, 45], [90, -45], [-90, -45]]]));
[[[-90, -45], [-90, 45], [90, 45], [90, -45], [-90, -45]]]));
fill0 = new Style({
fill: new Fill({color: 'black'})
});
@@ -138,7 +138,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
_ol_renderer_vector_.renderFeature(replay, feature2, style2, 1);
_ol_renderer_vector_.renderFeature(replay, feature3, style2, 1);
var skippedUids = {};
const skippedUids = {};
skippedUids[getUid(feature1)] = true;
replay.replay(context, transform, 0, skippedUids);
expect(fillCount).to.be(1);
@@ -150,7 +150,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
_ol_renderer_vector_.renderFeature(replay, feature2, style1, 1);
_ol_renderer_vector_.renderFeature(replay, feature3, style2, 1);
var skippedUids = {};
const skippedUids = {};
skippedUids[getUid(feature3)] = true;
replay.replay(context, transform, 0, skippedUids);
expect(fillCount).to.be(1);
@@ -162,7 +162,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
_ol_renderer_vector_.renderFeature(replay, feature2, style1, 1);
_ol_renderer_vector_.renderFeature(replay, feature3, style2, 1);
var skippedUids = {};
const skippedUids = {};
skippedUids[getUid(feature1)] = true;
skippedUids[getUid(feature2)] = true;
replay.replay(context, transform, 0, skippedUids);
@@ -186,7 +186,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
// replay with a pixelRatio of 2
replay = new _ol_render_canvas_ReplayGroup_(1, [-180, -90, 180, 90], 1, 2, true);
var lineDash, lineDashCount = 0,
let lineDash, lineDashCount = 0,
lineDashOffset, lineDashOffsetCount = 0;
context.setLineDash = function(lineDash_) {
@@ -215,8 +215,8 @@ describe('ol.render.canvas.ReplayGroup', function() {
});
it('calls the renderer function configured for the style', function() {
var calls = [];
var style = new Style({
const calls = [];
const style = new Style({
renderer: function(coords, state) {
calls.push({
coords: coords,
@@ -229,18 +229,18 @@ describe('ol.render.canvas.ReplayGroup', function() {
});
}
});
var point = new Feature(new Point([45, 90]));
var multipoint = new Feature(new MultiPoint(
[[45, 90], [90, 45]]));
var linestring = new Feature(new LineString(
[[45, 90], [45, 45], [90, 45]]));
var multilinestring = new Feature(new MultiLineString(
[linestring.getGeometry().getCoordinates(), linestring.getGeometry().getCoordinates()]));
var polygon = feature1;
var multipolygon = new Feature(new MultiPolygon(
[polygon.getGeometry().getCoordinates(), polygon.getGeometry().getCoordinates()]));
var geometrycollection = new Feature(new GeometryCollection(
[point.getGeometry(), linestring.getGeometry(), polygon.getGeometry()]));
const point = new Feature(new Point([45, 90]));
const multipoint = new Feature(new MultiPoint(
[[45, 90], [90, 45]]));
const linestring = new Feature(new LineString(
[[45, 90], [45, 45], [90, 45]]));
const multilinestring = new Feature(new MultiLineString(
[linestring.getGeometry().getCoordinates(), linestring.getGeometry().getCoordinates()]));
const polygon = feature1;
const multipolygon = new Feature(new MultiPolygon(
[polygon.getGeometry().getCoordinates(), polygon.getGeometry().getCoordinates()]));
const geometrycollection = new Feature(new GeometryCollection(
[point.getGeometry(), linestring.getGeometry(), polygon.getGeometry()]));
replay = new _ol_render_canvas_ReplayGroup_(1, [-180, -90, 180, 90], 1, 1, true);
_ol_renderer_vector_.renderFeature(replay, point, style, 1);
_ol_renderer_vector_.renderFeature(replay, multipoint, style, 1);
@@ -283,9 +283,9 @@ describe('ol.render.canvas.Replay', function() {
describe('constructor', function() {
it('creates a new replay batch', function() {
var tolerance = 10;
var extent = [-180, -90, 180, 90];
var replay = new _ol_render_canvas_Replay_(tolerance, extent, 1, 1, true);
const tolerance = 10;
const extent = [-180, -90, 180, 90];
const replay = new _ol_render_canvas_Replay_(tolerance, extent, 1, 1, true);
expect(replay).to.be.a(_ol_render_canvas_Replay_);
});
@@ -293,31 +293,31 @@ describe('ol.render.canvas.Replay', function() {
describe('#appendFlatCoordinates()', function() {
var replay;
let replay;
beforeEach(function() {
replay = new _ol_render_canvas_Replay_(1, [-180, -90, 180, 90], 1, 1, true);
});
it('appends coordinates that are within the max extent', function() {
var flat = [-110, 45, 110, 45, 110, -45, -110, -45];
const flat = [-110, 45, 110, 45, 110, -45, -110, -45];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
expect(replay.coordinates).to.eql(flat);
});
it('appends polygon coordinates that are within the max extent', function() {
var flat = [-110, 45, 110, 45, 110, -45, -110, -45, -110, 45];
const flat = [-110, 45, 110, 45, 110, -45, -110, -45, -110, 45];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
expect(replay.coordinates).to.eql(flat);
});
it('appends polygon coordinates that are within the max extent (skipping first)', function() {
var flat = [-110, 45, 110, 45, 110, -45, -110, -45, -110, 45];
const flat = [-110, 45, 110, 45, 110, -45, -110, -45, -110, 45];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
expect(replay.coordinates).to.eql([110, 45, 110, -45, -110, -45, -110, 45]);
});
it('works with a single coordinate (inside)', function() {
var flat = [-110, 45];
const flat = [-110, 45];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
expect(replay.coordinates).to.eql(flat);
});
@@ -325,7 +325,7 @@ describe('ol.render.canvas.Replay', function() {
it('always appends first point (even if outside)', function() {
// this could be changed, but to make the code simpler for properly
// closing rings, we always add the first point
var flat = [-110, 145];
const flat = [-110, 145];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
expect(replay.coordinates).to.eql(flat);
});
@@ -333,13 +333,13 @@ describe('ol.render.canvas.Replay', function() {
it('always appends first polygon vertex (even if outside)', function() {
// this could be changed, but to make the code simpler for properly
// closing rings, we always add the first point
var flat = [-110, 145, -110, 145];
const flat = [-110, 145, -110, 145];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
expect(replay.coordinates).to.eql(flat);
});
it('skips first polygon vertex upon request (also when outside)', function() {
var flat = [-110, 145, -110, 145];
const flat = [-110, 145, -110, 145];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
expect(replay.coordinates).to.eql([-110, 145]);
});
@@ -347,13 +347,13 @@ describe('ol.render.canvas.Replay', function() {
it('appends points when segments cross (top to bottom)', function() {
// this means we get a few extra points when coordinates are not
// part of a linestring or ring, but only a few extra
var flat = [0, 200, 0, -200];
const flat = [0, 200, 0, -200];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
expect(replay.coordinates).to.eql(flat);
});
it('appends points when segments cross (top to inside)', function() {
var flat = [0, 200, 0, 0];
const flat = [0, 200, 0, 0];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
expect(replay.coordinates).to.eql(flat);
});
@@ -361,7 +361,7 @@ describe('ol.render.canvas.Replay', function() {
it('always appends the first segment (even when outside)', function() {
// this could be changed, but to make the code simpler for properly
// closing rings, we always add the first segment
var flat = [-10, 200, 10, 200];
const flat = [-10, 200, 10, 200];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
expect(replay.coordinates).to.eql(flat);
});
@@ -369,67 +369,67 @@ describe('ol.render.canvas.Replay', function() {
it('always appends the first polygon segment (even when outside)', function() {
// this could be changed, but to make the code simpler for properly
// closing rings, we always add the first segment
var flat = [-10, 200, 10, 200, -10, 200];
const flat = [-10, 200, 10, 200, -10, 200];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
expect(replay.coordinates).to.eql(flat);
});
it('skips first polygon segment upon request (also when outside)', function() {
var flat = [-10, 200, 10, 200, -10, 200];
const flat = [-10, 200, 10, 200, -10, 200];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
expect(replay.coordinates).to.eql([10, 200, -10, 200]);
});
it('eliminates segments outside (and not changing rel)', function() {
var flat = [0, 0, 0, 200, 5, 200, 10, 200];
const flat = [0, 0, 0, 200, 5, 200, 10, 200];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
expect(replay.coordinates).to.eql([0, 0, 0, 200]);
});
it('eliminates polygon segments outside (and not changing rel)', function() {
var flat = [0, 0, 0, 200, 5, 200, 10, 200, 0, 0];
const flat = [0, 0, 0, 200, 5, 200, 10, 200, 0, 0];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
expect(replay.coordinates).to.eql([0, 0, 0, 200, 10, 200, 0, 0]);
});
it('eliminates polygon segments outside (skipping first and not changing rel)', function() {
var flat = [0, 0, 0, 10, 0, 200, 5, 200, 10, 200, 0, 0];
const flat = [0, 0, 0, 10, 0, 200, 5, 200, 10, 200, 0, 0];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
expect(replay.coordinates).to.eql([0, 10, 0, 200, 10, 200, 0, 0]);
});
it('eliminates segments outside (and not changing rel)', function() {
var flat = [0, 0, 0, 200, 10, 200];
const flat = [0, 0, 0, 200, 10, 200];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
expect(replay.coordinates).to.eql([0, 0, 0, 200]);
});
it('includes polygon segments outside (and not changing rel) when on last segment', function() {
var flat = [0, 0, 0, 200, 10, 200, 0, 0];
const flat = [0, 0, 0, 200, 10, 200, 0, 0];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
expect(replay.coordinates).to.eql(flat);
});
it('includes polygon segments outside (skipping first and not changing rel) when on last segment', function() {
var flat = [0, 0, 0, 200, 10, 200, 0, 0];
const flat = [0, 0, 0, 200, 10, 200, 0, 0];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
expect(replay.coordinates).to.eql([0, 200, 10, 200, 0, 0]);
});
it('includes outside segments that change relationship', function() {
var flat = [0, 0, 0, 200, 200, 200, 250, 200];
const flat = [0, 0, 0, 200, 200, 200, 250, 200];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
expect(replay.coordinates).to.eql([0, 0, 0, 200, 200, 200]);
});
it('includes outside polygon segments that change relationship when on last segment', function() {
var flat = [0, 0, 0, 200, 200, 200, 250, 200, 0, 0];
const flat = [0, 0, 0, 200, 200, 200, 250, 200, 0, 0];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
expect(replay.coordinates).to.eql(flat);
});
it('includes outside polygon segments that change relationship when on last segment (when skipping first)', function() {
var flat = [0, 0, 0, 200, 200, 200, 250, 200, 0, 0];
const flat = [0, 0, 0, 200, 200, 200, 250, 200, 0, 0];
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
expect(replay.coordinates).to.eql([0, 200, 200, 200, 250, 200, 0, 0]);
});
@@ -443,16 +443,16 @@ describe('ol.render.canvas.LineStringReplay', function() {
describe('#getBufferedMaxExtent()', function() {
it('buffers the max extent to accommodate stroke width', function() {
var tolerance = 1;
var extent = [-180, -90, 180, 90];
var resolution = 10;
var replay = new _ol_render_canvas_LineStringReplay_(tolerance, extent,
resolution);
var stroke = new Stroke({
const tolerance = 1;
const extent = [-180, -90, 180, 90];
const resolution = 10;
const replay = new _ol_render_canvas_LineStringReplay_(tolerance, extent,
resolution);
const stroke = new Stroke({
width: 2
});
replay.setFillStrokeStyle(null, stroke);
var buffered = replay.getBufferedMaxExtent();
const buffered = replay.getBufferedMaxExtent();
expect(buffered).to.eql([-195, -105, 195, 105]);
});
@@ -462,25 +462,25 @@ describe('ol.render.canvas.LineStringReplay', function() {
describe('ol.render.canvas.PolygonReplay', function() {
var replay;
let replay;
beforeEach(function() {
var tolerance = 1;
var extent = [-180, -90, 180, 90];
var resolution = 10;
const tolerance = 1;
const extent = [-180, -90, 180, 90];
const resolution = 10;
replay = new _ol_render_canvas_PolygonReplay_(tolerance, extent,
resolution);
resolution);
});
describe('#drawFlatCoordinatess_()', function() {
it('returns correct offset', function() {
var coords = [1, 2, 3, 4, 5, 6, 1, 2, 1, 2, 3, 4, 5, 6, 1, 2];
var ends = [7, 14];
var stroke = new Stroke({
const coords = [1, 2, 3, 4, 5, 6, 1, 2, 1, 2, 3, 4, 5, 6, 1, 2];
const ends = [7, 14];
const stroke = new Stroke({
width: 5
});
replay.setFillStrokeStyle(null, stroke);
var offset = replay.drawFlatCoordinatess_(coords, 0, ends, 2);
let offset = replay.drawFlatCoordinatess_(coords, 0, ends, 2);
expect(offset).to.be(14);
replay.setFillStrokeStyle(null, null);
offset = replay.drawFlatCoordinatess_(coords, 0, ends, 2);
@@ -491,11 +491,11 @@ describe('ol.render.canvas.PolygonReplay', function() {
describe('#getBufferedMaxExtent()', function() {
it('buffers the max extent to accommodate stroke width', function() {
var stroke = new Stroke({
const stroke = new Stroke({
width: 5
});
replay.setFillStrokeStyle(null, stroke);
var buffered = replay.getBufferedMaxExtent();
const buffered = replay.getBufferedMaxExtent();
expect(buffered).to.eql([-210, -120, 210, 120]);
});