Skip to content

Commit d9ed4ac

Browse files
committed
Run eslint on all js files
1 parent 3977133 commit d9ed4ac

File tree

5 files changed

+47
-27
lines changed

5 files changed

+47
-27
lines changed

Diff for: __tests__/.eslintrc

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"env": {
33
"mocha": true
4+
},
5+
"rules": {
6+
"no-console": [
7+
"error", {
8+
"allow": ["error"]
9+
}
10+
]
411
}
512
}

Diff for: __tests__/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('ol-mapbox-style', function() {
8888
'https://c.tile.openstreetmap.org/{z}/{x}/{y}.png'
8989
]);
9090
should(osm.getSource().getAttributions()()[0]).equal(
91-
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors.');
91+
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors.');
9292
should(wms.getSource().getTileGrid().getTileSize()).eql(256);
9393
should(wms.getSource().getTileGrid().getMaxZoom()).eql(12);
9494
done();

Diff for: env-setup.js

+29-25
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,36 @@
55

66
// MIT license
77
(function() {
8-
var lastTime = 0;
9-
var vendors = ['ms', 'moz', 'webkit', 'o'];
10-
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
11-
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
12-
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
13-
|| window[vendors[x]+'CancelRequestAnimationFrame'];
14-
}
15-
16-
if (!window.requestAnimationFrame)
17-
window.requestAnimationFrame = function(callback, element) {
18-
var currTime = new Date().getTime();
19-
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
20-
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
21-
timeToCall);
22-
lastTime = currTime + timeToCall;
23-
return id;
24-
};
25-
26-
if (!window.cancelAnimationFrame)
27-
window.cancelAnimationFrame = function(id) {
28-
clearTimeout(id);
29-
};
8+
var lastTime = 0;
9+
var vendors = ['ms', 'moz', 'webkit', 'o'];
10+
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
11+
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
12+
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] ||
13+
window[vendors[x] + 'CancelRequestAnimationFrame'];
14+
}
15+
16+
if (!window.requestAnimationFrame) {
17+
window.requestAnimationFrame = function(callback, element) {
18+
var currTime = new Date().getTime();
19+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
20+
var id = window.setTimeout(function() {
21+
callback(currTime + timeToCall);
22+
},
23+
timeToCall);
24+
lastTime = currTime + timeToCall;
25+
return id;
26+
};
27+
}
28+
29+
if (!window.cancelAnimationFrame) {
30+
window.cancelAnimationFrame = function(id) {
31+
clearTimeout(id);
32+
};
33+
}
3034
}());
3135

3236
(function() {
33-
var canvasBindings = require("canvas/lib/bindings");
34-
window.CanvasGradient = canvasBindings.CanvasGradient;
35-
window.CanvasPattern = canvasBindings.CanvasPattern;
37+
var canvasBindings = require('canvas/lib/bindings');
38+
window.CanvasGradient = canvasBindings.CanvasGradient;
39+
window.CanvasPattern = canvasBindings.CanvasPattern;
3640
}());

Diff for: index.js

+9
Original file line numberDiff line numberDiff line change
@@ -495,3 +495,12 @@ export function apply(map, style) {
495495
}
496496
return map;
497497
}
498+
499+
export function getLayer(map, layerId) {
500+
const layers = map.getLayers().getArray();
501+
for (let i = 0, ii = layers.length; i < ii; ++i) {
502+
if (layers[i].get('mapbox-layers').indexOf(layerId) !== -1) {
503+
return layers[i];
504+
}
505+
}
506+
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"prepublish": "npm run doc",
6565
"build": "webpack-cli --config ./webpack.config.olms.js",
6666
"doc": "documentation readme -s API index.js",
67-
"lint": "eslint __test__ index.js webpack.config.js",
67+
"lint": "eslint __test__ *.js",
6868
"pretest": "npm run lint",
6969
"test": "jest",
7070
"cover": "jest --coverage"

0 commit comments

Comments
 (0)