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
+38 -38
View File
@@ -30,7 +30,7 @@ describe('ol.render.canvas.Immediate', function() {
describe('constructor', function() {
it('creates an instance', function() {
var instance = new CanvasImmediateRenderer();
const instance = new CanvasImmediateRenderer();
expect(instance).to.be.a(CanvasImmediateRenderer);
expect(instance).to.be.a(VectorContext);
});
@@ -38,15 +38,15 @@ describe('ol.render.canvas.Immediate', function() {
describe('#setStyle()', function() {
it('calls the more specific methods with style parts', function() {
var context = new CanvasImmediateRenderer();
const context = new CanvasImmediateRenderer();
sinon.spy(context, 'setFillStrokeStyle');
sinon.spy(context, 'setImageStyle');
sinon.spy(context, 'setTextStyle');
var fill = new Fill({});
var stroke = new Stroke({});
var text = new Text({});
var image = new CircleStyle({});
var style = new Style({
const fill = new Fill({});
const stroke = new Stroke({});
const text = new Text({});
const image = new CircleStyle({});
const style = new Style({
fill: fill,
stroke: stroke,
image: image,
@@ -65,80 +65,80 @@ describe('ol.render.canvas.Immediate', function() {
describe('#drawGeometry()', function() {
var extent = [-10, -10, 10, 10];
const extent = [-10, -10, 10, 10];
it('calls drawPoint() with a Point', function() {
var context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
const context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
sinon.spy(context, 'drawPoint');
var geometry = new Point([1, 2]);
const geometry = new Point([1, 2]);
context.drawGeometry(geometry);
expect(context.drawPoint.calledOnce).to.be(true);
expect(context.drawPoint.firstCall.calledWithExactly(geometry)).to.be(true);
});
it('calls drawLineString() with a LineString', function() {
var context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
const context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
sinon.spy(context, 'drawLineString');
var geometry = new LineString([[1, 2], [3, 4]]);
const geometry = new LineString([[1, 2], [3, 4]]);
context.drawGeometry(geometry);
expect(context.drawLineString.calledOnce).to.be(true);
expect(context.drawLineString.firstCall.calledWithExactly(geometry)).to.be(true);
});
it('calls drawPolygon() with a Polygon', function() {
var context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
const context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
sinon.spy(context, 'drawPolygon');
var geometry = new Polygon([[[1, 2], [3, 4], [5, 6], [1, 2]]]);
const geometry = new Polygon([[[1, 2], [3, 4], [5, 6], [1, 2]]]);
context.drawGeometry(geometry);
expect(context.drawPolygon.calledOnce).to.be(true);
expect(context.drawPolygon.firstCall.calledWithExactly(geometry)).to.be(true);
});
it('calls drawMultiPoint() with a MultiPoint', function() {
var context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
const context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
sinon.spy(context, 'drawMultiPoint');
var geometry = new MultiPoint([[1, 2], [3, 4]]);
const geometry = new MultiPoint([[1, 2], [3, 4]]);
context.drawGeometry(geometry);
expect(context.drawMultiPoint.calledOnce).to.be(true);
expect(context.drawMultiPoint.firstCall.calledWithExactly(geometry)).to.be(true);
});
it('calls drawMultiLineString() with a MultiLineString', function() {
var context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
const context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
sinon.spy(context, 'drawMultiLineString');
var geometry = new MultiLineString([[[1, 2], [3, 4]]]);
const geometry = new MultiLineString([[[1, 2], [3, 4]]]);
context.drawGeometry(geometry);
expect(context.drawMultiLineString.calledOnce).to.be(true);
expect(context.drawMultiLineString.firstCall.calledWithExactly(geometry)).to.be(true);
});
it('calls drawMultiPolygon() with a MultiPolygon', function() {
var context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
const context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
sinon.spy(context, 'drawMultiPolygon');
var geometry = new MultiPolygon([[[[1, 2], [3, 4], [5, 6], [1, 2]]]]);
const geometry = new MultiPolygon([[[[1, 2], [3, 4], [5, 6], [1, 2]]]]);
context.drawGeometry(geometry);
expect(context.drawMultiPolygon.calledOnce).to.be(true);
expect(context.drawMultiPolygon.firstCall.calledWithExactly(geometry)).to.be(true);
});
it('calls drawGeometryCollection() with a GeometryCollection', function() {
var context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
const context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
sinon.spy(context, 'drawGeometryCollection');
sinon.spy(context, 'drawPoint');
sinon.spy(context, 'drawLineString');
sinon.spy(context, 'drawPolygon');
var point = new Point([1, 2]);
var linestring = new LineString([[1, 2], [3, 4]]);
var polygon = new Polygon([[[1, 2], [3, 4], [5, 6], [1, 2]]]);
const point = new Point([1, 2]);
const linestring = new LineString([[1, 2], [3, 4]]);
const polygon = new Polygon([[[1, 2], [3, 4], [5, 6], [1, 2]]]);
var geometry = new GeometryCollection([point, linestring, polygon]);
const geometry = new GeometryCollection([point, linestring, polygon]);
context.drawGeometry(geometry);
expect(context.drawGeometryCollection.calledOnce).to.be(true);
@@ -151,10 +151,10 @@ describe('ol.render.canvas.Immediate', function() {
});
it('calls drawCircle() with a Circle', function() {
var context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
const context = new CanvasImmediateRenderer(getMockContext(), 1, extent);
sinon.spy(context, 'drawCircle');
var geometry = new Circle([0, 0]);
const geometry = new Circle([0, 0]);
context.drawGeometry(geometry);
expect(context.drawCircle.calledOnce).to.be(true);
@@ -167,13 +167,13 @@ describe('ol.render.canvas.Immediate', function() {
it('creates the correct canvas instructions for 3D geometries', function() {
var instructions = [];
const instructions = [];
function serialize(index, instruction) {
if (!instruction) {
return 'id: ' + index + ' NO INSTRUCTION';
}
var parts = [
const parts = [
'id: ' + index,
'type: ' + instruction.type
];
@@ -189,7 +189,7 @@ describe('ol.render.canvas.Immediate', function() {
return parts.join(', ');
}
var context = {
const context = {
beginPath: function() {},
moveTo: function(x, y) {
instructions.push({
@@ -212,18 +212,18 @@ describe('ol.render.canvas.Immediate', function() {
stroke: function() {}
};
var transform = [
const transform = [
0.0004088332670837288, 0,
0, -0.0004088332670837288,
4480.991370439071, 1529.5752568707105
];
var extent = [
const extent = [
-10960437.252092224, 2762924.0275091752,
-7572748.158493212, 3741317.9895594316
];
var canvas = new CanvasImmediateRenderer(context, 1, extent, transform);
const canvas = new CanvasImmediateRenderer(context, 1, extent, transform);
canvas.strokeState_ = {
lineCap: 'round',
@@ -234,7 +234,7 @@ describe('ol.render.canvas.Immediate', function() {
strokeStyle: '#00FFFF'
};
var multiPolygonGeometry = new MultiPolygon([[[
const multiPolygonGeometry = new MultiPolygon([[[
// first polygon
[-80.736061, 28.788576000000006, 0], // moveTo()
[-80.763557, 28.821799999999996, 0], // lineTo()
@@ -257,7 +257,7 @@ describe('ol.render.canvas.Immediate', function() {
canvas.drawMultiPolygon(multiPolygonGeometry, null);
var expected = [
const expected = [
// first polygon
{type: 'moveTo', args: [806.6035275946265, 160.48916296287916]},
{type: 'lineTo', args: [805.3521540835154, 158.76358389011807]},
@@ -278,9 +278,9 @@ describe('ol.render.canvas.Immediate', function() {
];
for (var i = 0, ii = instructions.length; i < ii; ++i) {
var actualInstruction = serialize(i, instructions[i]);
var expectedInstruction = serialize(i, expected[i]);
for (let i = 0, ii = instructions.length; i < ii; ++i) {
const actualInstruction = serialize(i, instructions[i]);
const expectedInstruction = serialize(i, expected[i]);
expect(actualInstruction).to.equal(expectedInstruction);
}