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
+6 -6
View File
@@ -13,11 +13,11 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.Circle', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer) {
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -44,7 +44,7 @@ describe('ol.rendering.style.Circle', function() {
describe('#render', function() {
function createFeatures(multi) {
var feature;
let feature;
feature = new Feature({
geometry: multi ? new MultiPoint([[-20, 18]]) : new Point([-20, 18])
});
@@ -188,14 +188,14 @@ describe('ol.rendering.style.Circle', function() {
createMap('canvas');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/circle-canvas.png',
8.0, done);
8.0, done);
});
it('renders multipoint geometries', function(done) {
createMap('canvas');
createFeatures(true);
expectResemble(map, 'rendering/ol/style/expected/circle-canvas.png',
8.0, done);
8.0, done);
});
where('WebGL').it('tests the WebGL renderer', function(done) {
@@ -203,7 +203,7 @@ describe('ol.rendering.style.Circle', function() {
createMap('webgl');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/circle-webgl.png',
8.0, done);
8.0, done);
});
});
});
+10 -11
View File
@@ -10,9 +10,9 @@ import Style from '../../../../src/ol/style/Style.js';
describe('ol.rendering.style.Icon', function() {
var map, vectorSource;
let map, vectorSource;
var imgInfo = {
const imgInfo = {
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
@@ -23,7 +23,7 @@ describe('ol.rendering.style.Icon', function() {
function createMap(renderer, width, height) {
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -50,12 +50,11 @@ describe('ol.rendering.style.Icon', function() {
describe('#render', function() {
function createFeatures(src, imgInfo, callback) {
var feature;
feature = new Feature({
const feature = new Feature({
geometry: new Point([0, 0])
});
var img = new Image();
const img = new Image();
img.onload = function() {
imgInfo.img = img;
feature.setStyle(new Style({
@@ -71,7 +70,7 @@ describe('ol.rendering.style.Icon', function() {
createMap('canvas');
createFeatures('rendering/ol/data/icon.png', imgInfo, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -82,7 +81,7 @@ describe('ol.rendering.style.Icon', function() {
imgSize: [512, 512]
}, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-canvas-svg-scale.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -94,7 +93,7 @@ describe('ol.rendering.style.Icon', function() {
imgSize: [512, 512]
}, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-canvas-svg-offset.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -106,7 +105,7 @@ describe('ol.rendering.style.Icon', function() {
imgSize: [512, 512]
}, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-canvas-svg-offset2.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
@@ -115,7 +114,7 @@ describe('ol.rendering.style.Icon', function() {
createMap('webgl');
createFeatures('rendering/ol/data/icon.png', imgInfo, function() {
expectResemble(map, 'rendering/ol/style/expected/icon-webgl.png',
2.0, done);
2.0, done);
});
});
});
+13 -13
View File
@@ -10,11 +10,11 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.LineString', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer, opt_pixelRatio) {
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -41,11 +41,11 @@ describe('ol.rendering.style.LineString', function() {
describe('different strokes', function() {
function createFeatures() {
var feature;
let feature;
feature = new Feature({
geometry: new LineString(
[[-20, 20], [15, 20]]
[[-20, 20], [15, 20]]
)
});
feature.setStyle(new Style({
@@ -55,7 +55,7 @@ describe('ol.rendering.style.LineString', function() {
feature = new Feature({
geometry: new LineString(
[[-20, 15], [15, 15]]
[[-20, 15], [15, 15]]
)
});
feature.setStyle(new Style({
@@ -65,7 +65,7 @@ describe('ol.rendering.style.LineString', function() {
feature = new Feature({
geometry: new LineString(
[[-20, 10], [15, 10]]
[[-20, 10], [15, 10]]
)
});
feature.setStyle([new Style({
@@ -77,7 +77,7 @@ describe('ol.rendering.style.LineString', function() {
feature = new Feature({
geometry: new LineString(
[[-20, -20], [-2, 0], [15, -20]]
[[-20, -20], [-2, 0], [15, -20]]
)
});
feature.setStyle(new Style({
@@ -93,7 +93,7 @@ describe('ol.rendering.style.LineString', function() {
feature = new Feature({
geometry: new LineString(
[[-20, -15], [-2, 5], [15, -15]]
[[-20, -15], [-2, 5], [15, -15]]
)
});
feature.setStyle(new Style({
@@ -113,23 +113,23 @@ describe('ol.rendering.style.LineString', function() {
createMap('canvas');
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/linestring-strokes-canvas.png',
3.0, done);
map, 'rendering/ol/style/expected/linestring-strokes-canvas.png',
3.0, done);
});
where('WebGL').it('tests the WebGL renderer', function(done) {
assertWebGL();
createMap('webgl');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/linestring-strokes-webgl.png',
14.6, done);
14.6, done);
});
it('tests the canvas renderer (HiDPI)', function(done) {
createMap('canvas', 2);
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/linestring-strokes-canvas-hidpi.png',
3.0, done);
map, 'rendering/ol/style/expected/linestring-strokes-canvas-hidpi.png',
3.0, done);
});
});
});
+27 -27
View File
@@ -11,13 +11,13 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.Polygon', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer, opt_size) {
var size = opt_size || 50;
const size = opt_size || 50;
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -44,9 +44,9 @@ describe('ol.rendering.style.Polygon', function() {
describe('different types', function() {
function createFeatures() {
var fill = new Fill({color: 'red'});
const fill = new Fill({color: 'red'});
var feature;
let feature;
// rectangle
feature = new Feature({
geometry: new Polygon([
@@ -90,28 +90,28 @@ describe('ol.rendering.style.Polygon', function() {
createMap('canvas');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-types-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the webgl renderer', function(done) {
createMap('webgl');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-types-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
describe('different types with stroke', function() {
function createFeatures() {
var stroke = new Stroke({
const stroke = new Stroke({
width: 10,
color: '#000',
lineJoin: 'round',
lineCap: 'butt'
});
var feature;
let feature;
// rectangle
feature = new Feature({
geometry: new Polygon([
@@ -156,7 +156,7 @@ describe('ol.rendering.style.Polygon', function() {
map.getView().setResolution(0.5);
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-types-canvas-stroke.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the webgl renderer', function(done) {
@@ -164,14 +164,14 @@ describe('ol.rendering.style.Polygon', function() {
map.getView().setResolution(0.5);
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-types-webgl-stroke.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
describe('z-index', function() {
function createFeatures() {
var feature;
let feature;
// rectangle with z-index 2
feature = new Feature({
geometry: new Polygon([
@@ -214,21 +214,21 @@ describe('ol.rendering.style.Polygon', function() {
createMap('canvas');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-zindex-canvas.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the webgl renderer', function(done) {
createMap('webgl');
createFeatures();
expectResemble(map, 'rendering/ol/style/expected/polygon-zindex-webgl.png',
IMAGE_TOLERANCE, done);
IMAGE_TOLERANCE, done);
});
});
describe('different fills and strokes', function() {
function createFeatures() {
var feature;
let feature;
// rectangle
feature = new Feature({
geometry: new Polygon([
@@ -270,25 +270,25 @@ describe('ol.rendering.style.Polygon', function() {
createMap('canvas');
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/polygon-fill-and-strokes-canvas.png',
IMAGE_TOLERANCE, done);
map, 'rendering/ol/style/expected/polygon-fill-and-strokes-canvas.png',
IMAGE_TOLERANCE, done);
});
where('WebGL').it('tests the webgl renderer', function(done) {
createMap('webgl');
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/polygon-fill-and-strokes-webgl.png',
5.76, done);
map, 'rendering/ol/style/expected/polygon-fill-and-strokes-webgl.png',
5.76, done);
});
});
describe('CanvasPattern and LinearGradient as fills and strokes', function() {
function createRainbowGradient() {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var gradient = context.createLinearGradient(0, 0, 30, 0);
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const gradient = context.createLinearGradient(0, 0, 30, 0);
gradient.addColorStop(0, 'red');
gradient.addColorStop(1 / 6, 'orange');
gradient.addColorStop(2 / 6, 'yellow');
@@ -300,8 +300,8 @@ describe('ol.rendering.style.Polygon', function() {
}
function createPattern() {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
canvas.width = 11;
canvas.height = 11;
context.fillStyle = 'rgba(102, 0, 102, 0.5)';
@@ -316,7 +316,7 @@ describe('ol.rendering.style.Polygon', function() {
}
function createFeatures() {
var feature = new Feature({
const feature = new Feature({
geometry: new Polygon([
[[-20, -20], [-20, 20], [18, 20], [-20, -20]]
])
@@ -332,8 +332,8 @@ describe('ol.rendering.style.Polygon', function() {
createMap('canvas');
createFeatures();
expectResemble(
map, 'rendering/ol/style/expected/polygon-pattern-gradient-canvas.png',
2.75, done);
map, 'rendering/ol/style/expected/polygon-pattern-gradient-canvas.png',
2.75, done);
});
});
+7 -7
View File
@@ -12,11 +12,11 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.RegularShape', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer) {
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -41,7 +41,7 @@ describe('ol.rendering.style.RegularShape', function() {
});
function createFeatures(stroke, fill) {
var feature;
let feature;
feature = new Feature({
geometry: new Point([-15, 15])
});
@@ -108,8 +108,8 @@ describe('ol.rendering.style.RegularShape', function() {
describe('#render', function() {
var stroke = new Stroke({width: 2});
var fill = new Fill({color: 'red'});
const stroke = new Stroke({width: 2});
const fill = new Fill({color: 'red'});
it('tests the canvas renderer', function(done) {
createMap('canvas');
@@ -143,8 +143,8 @@ describe('ol.rendering.style.RegularShape', function() {
});
describe('uses the default fill and stroke color', function() {
var stroke = new Stroke();
var fill = new Fill();
const stroke = new Stroke();
const fill = new Fill();
it('tests the canvas renderer', function(done) {
createMap('canvas');
+22 -22
View File
@@ -15,12 +15,12 @@ import Stroke from '../../../../src/ol/style/Stroke.js';
describe('ol.rendering.style.Text', function() {
var map, vectorSource;
let map, vectorSource;
function createMap(renderer, opt_pixelRatio) {
var pixelRatio = opt_pixelRatio || 1;
const pixelRatio = opt_pixelRatio || 1;
vectorSource = new VectorSource();
var vectorLayer = new VectorLayer({
const vectorLayer = new VectorLayer({
source: vectorSource
});
@@ -47,8 +47,8 @@ describe('ol.rendering.style.Text', function() {
describe('#render', function() {
function createFeatures(opt_scale) {
var scale = opt_scale || 1;
var feature;
const scale = opt_scale || 1;
let feature;
feature = new Feature({
geometry: new Point([-20, 18])
});
@@ -97,17 +97,17 @@ describe('ol.rendering.style.Text', function() {
vectorSource.addFeature(feature);
}
var nicePath = [
const nicePath = [
20, 33, 40, 31, 60, 30, 80, 31, 100, 33, 120, 37, 140, 39, 160, 40,
180, 39, 200, 37, 220, 33, 240, 31, 260, 30, 280, 31, 300, 33
];
var uglyPath = [163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
var polygon = [151, 17, 163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
const uglyPath = [163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
const polygon = [151, 17, 163, 22, 159, 30, 150, 30, 143, 24, 151, 17];
function createLineString(coords, textAlign, maxAngle, strokeColor, strokeWidth, scale) {
var geom = new LineString();
let geom = new LineString();
geom.setFlatCoordinates('XY', coords);
var style = new Style({
let style = new Style({
stroke: new Stroke({
color: 'red'
}),
@@ -124,7 +124,7 @@ describe('ol.rendering.style.Text', function() {
})
})
});
var feature = new Feature(geom);
let feature = new Feature(geom);
feature.setStyle(style);
vectorSource.addFeature(feature);
@@ -174,7 +174,7 @@ describe('ol.rendering.style.Text', function() {
it('renders multiline text with alignment options', function(done) {
createMap('canvas');
var feature;
let feature;
feature = new Feature(new Point([25, 0]));
feature.setStyle(new Style({
text: new Text({
@@ -216,7 +216,7 @@ describe('ol.rendering.style.Text', function() {
it('renders multiline text with positioning options', function(done) {
createMap('canvas');
var feature;
let feature;
feature = new Feature(new Point([0, 0]));
feature.setStyle(new Style({
text: new Text({
@@ -262,9 +262,9 @@ describe('ol.rendering.style.Text', function() {
it('renders text along a MultiLineString', function(done) {
createMap('canvas');
var line = new LineString();
let line = new LineString();
line.setFlatCoordinates('XY', nicePath);
var geom = new MultiLineString(null);
const geom = new MultiLineString(null);
geom.appendLineString(line);
line = line.clone();
line.translate(0, 50);
@@ -272,7 +272,7 @@ describe('ol.rendering.style.Text', function() {
line = line.clone();
line.translate(0, -100);
geom.appendLineString(line);
var feature = new Feature(geom);
const feature = new Feature(geom);
feature.setStyle(new Style({
text: new Text({
text: 'Hello world',
@@ -287,9 +287,9 @@ describe('ol.rendering.style.Text', function() {
it('renders text along a Polygon', function(done) {
createMap('canvas');
var geom = new Polygon(null);
const geom = new Polygon(null);
geom.setFlatCoordinates('XY', polygon, [polygon.length]);
var feature = new Feature(geom);
const feature = new Feature(geom);
feature.setStyle(new Style({
text: new Text({
text: 'Hello world',
@@ -305,9 +305,9 @@ describe('ol.rendering.style.Text', function() {
it('renders text along a MultiPolygon', function(done) {
createMap('canvas');
var geom = new Polygon(null);
let geom = new Polygon(null);
geom.setFlatCoordinates('XY', polygon, [polygon.length]);
var multiPolygon = new MultiPolygon(null);
const multiPolygon = new MultiPolygon(null);
multiPolygon.appendPolygon(geom);
geom = geom.clone();
geom.translate(0, 30);
@@ -315,7 +315,7 @@ describe('ol.rendering.style.Text', function() {
geom = geom.clone();
geom.translate(0, -60);
multiPolygon.appendPolygon(geom);
var feature = new Feature(multiPolygon);
const feature = new Feature(multiPolygon);
feature.setStyle(new Style({
text: new Text({
text: 'Hello world',
@@ -332,7 +332,7 @@ describe('ol.rendering.style.Text', function() {
it('renders text background', function(done) {
createMap('canvas');
createFeatures();
var features = vectorSource.getFeatures();
const features = vectorSource.getFeatures();
features[0].getStyle().getText().setBackgroundFill(new Fill({
color: 'red'
}));