Skip to content

Commit

Permalink
Merge pull request #6916 from marcjansen/eslint-4-upgrade
Browse files Browse the repository at this point in the history
Upgrade eslint to v4.0.0
  • Loading branch information
marcjansen committed Jun 22, 2017
2 parents d32006b + feabb64 commit 9fc0fb5
Show file tree
Hide file tree
Showing 198 changed files with 1,811 additions and 1,791 deletions.
2 changes: 1 addition & 1 deletion examples/color-manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function rgb2xyz(x) {

function xyz2rgb(x) {
return 255 * (x <= 0.0031308 ?
12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
}

var raster = new ol.source.Raster({
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ var lineFeature = new ol.Feature(

var polygonFeature = new ol.Feature(
new ol.geom.Polygon([[[-3e6, -1e6], [-3e6, 1e6],
[-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]]));
[-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]]));


var map = new ol.Map({
Expand Down
2 changes: 1 addition & 1 deletion examples/feature-move-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function stopAnimation(ended) {
// if animation cancelled set the marker at the beginning
var coord = ended ? routeCoords[routeLength - 1] : routeCoords[0];
/** @type {ol.geom.Point} */ (geoMarker.getGeometry())
.setCoordinates(coord);
.setCoordinates(coord);
//remove listener
map.un('postcompose', moveFeature);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/geojson-vt.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ fetch(url).then(function(response) {
var data = tileIndex.getTile(tileCoord[0], tileCoord[1], -tileCoord[2] - 1);

var features = format.readFeatures(
JSON.stringify({
type: 'FeatureCollection',
features: data ? data.features : []
}, replacer));
JSON.stringify({
type: 'FeatureCollection',
features: data ? data.features : []
}, replacer));
tile.setLoader(function() {
tile.setFeatures(features);
tile.setProjection(tilePixels);
Expand Down
2 changes: 1 addition & 1 deletion examples/geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ positionFeature.setStyle(new ol.style.Style({
geolocation.on('change:position', function() {
var coordinates = geolocation.getPosition();
positionFeature.setGeometry(coordinates ?
new ol.geom.Point(coordinates) : null);
new ol.geom.Point(coordinates) : null);
});

new ol.layer.Vector({
Expand Down
10 changes: 5 additions & 5 deletions examples/here-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ var map = new ol.Map({

function createUrl(tpl, layerDesc) {
return tpl
.replace('{base}', layerDesc.base)
.replace('{type}', layerDesc.type)
.replace('{scheme}', layerDesc.scheme)
.replace('{app_id}', layerDesc.app_id)
.replace('{app_code}', layerDesc.app_code);
.replace('{base}', layerDesc.base)
.replace('{type}', layerDesc.type)
.replace('{scheme}', layerDesc.scheme)
.replace('{app_id}', layerDesc.app_id)
.replace('{app_code}', layerDesc.app_code);
}

var select = document.getElementById('layer-select');
Expand Down
10 changes: 5 additions & 5 deletions examples/modify-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ var geojsonObject = {
'geometry': {
'type': 'Polygon',
'coordinates': [[[-5e6, -1e6], [-4e6, 1e6],
[-3e6, -1e6], [-5e6, -1e6]], [[-4.5e6, -0.5e6],
[-3.5e6, -0.5e6], [-4e6, 0.5e6], [-4.5e6, -0.5e6]]]
[-3e6, -1e6], [-5e6, -1e6]], [[-4.5e6, -0.5e6],
[-3.5e6, -0.5e6], [-4e6, 0.5e6], [-4.5e6, -0.5e6]]]
}
}, {
'type': 'Feature',
Expand All @@ -117,11 +117,11 @@ var geojsonObject = {
'type': 'MultiPolygon',
'coordinates': [
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
[-3e6, 6e6], [-5e6, 6e6]]],
[-3e6, 6e6], [-5e6, 6e6]]],
[[[-3e6, 6e6], [-2e6, 8e6], [0, 8e6],
[0, 6e6], [-3e6, 6e6]]],
[0, 6e6], [-3e6, 6e6]]],
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
[3e6, 6e6], [1e6, 6e6]]]
[3e6, 6e6], [1e6, 6e6]]]
]
}
}, {
Expand Down
8 changes: 4 additions & 4 deletions examples/polygon-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ var geojsonObject = {
'geometry': {
'type': 'Polygon',
'coordinates': [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
[-3e6, 6e6], [-5e6, 6e6]]]
[-3e6, 6e6], [-5e6, 6e6]]]
}
}, {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6],
[0, 6e6], [-2e6, 6e6]]]
[0, 6e6], [-2e6, 6e6]]]
}
}, {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
[3e6, 6e6], [1e6, 6e6]]]
[3e6, 6e6], [1e6, 6e6]]]
}
}, {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [[[-2e6, -1e6], [-1e6, 1e6],
[0, -1e6], [-2e6, -1e6]]]
[0, -1e6], [-2e6, -1e6]]]
}
}]
};
Expand Down
4 changes: 2 additions & 2 deletions examples/raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ function plot(resolution, counts, threshold) {
var value = counts.min + (index * counts.delta);
return 'bar' + (value >= threshold ? ' selected' : '');
})
.attr('width', barWidth - 2);
.attr('width', barWidth - 2);

bar.transition().attr('transform', function(value, index) {
return 'translate(' + (index * barWidth) + ', ' +
(plotHeight - yScale(value)) + ')';
})
.attr('height', yScale);
.attr('height', yScale);

bar.on('mousemove', function(count, index) {
var threshold = counts.min + (index * counts.delta);
Expand Down
4 changes: 2 additions & 2 deletions examples/vector-wfs-getfeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ var featureRequest = new ol.format.WFS().writeGetFeature({
featureTypes: ['water_areas'],
outputFormat: 'application/json',
filter: ol.format.filter.and(
ol.format.filter.like('name', 'Mississippi*'),
ol.format.filter.equalTo('waterway', 'riverbank')
ol.format.filter.like('name', 'Mississippi*'),
ol.format.filter.equalTo('waterway', 'riverbank')
)
});

Expand Down
4 changes: 2 additions & 2 deletions examples/xyz-esri-4326-512.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var map = new ol.Map({
tileSize: tileSize,
tileUrlFunction: function(tileCoord) {
return urlTemplate.replace('{z}', (tileCoord[0] - 1).toString())
.replace('{x}', tileCoord[1].toString())
.replace('{y}', (-tileCoord[2] - 1).toString());
.replace('{x}', tileCoord[1].toString())
.replace('{y}', (-tileCoord[2] - 1).toString());
},
wrapX: true
})
Expand Down
20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"clean-css-cli": "4.1.4",
"coveralls": "2.13.1",
"debounce": "^1.0.0",
"eslint": "3.19.0",
"eslint": "4.0.0",
"eslint-config-openlayers": "7.0.0",
"eslint-plugin-openlayers-internal": "^3.1.0",
"expect.js": "0.3.1",
Expand Down Expand Up @@ -100,7 +100,23 @@
"openlayers-internal/one-provide": 2,
"openlayers-internal/requires-first": 2,
"openlayers-internal/valid-provide": 2,
"openlayers-internal/valid-requires": 2
"openlayers-internal/valid-requires": 2,
"indent": [2, 2, {
"VariableDeclarator": 2,
"SwitchCase": 1,
"MemberExpression": 2,
"FunctionDeclaration": {
"parameters": 2,
"body": 1
},
"FunctionExpression": {
"parameters": 2,
"body": 1
},
"CallExpression": {
"arguments": 2
}
}]
}
},
"ext": [
Expand Down
28 changes: 14 additions & 14 deletions src/ol/centerconstraint.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ goog.require('ol.math');
*/
ol.CenterConstraint.createExtent = function(extent) {
return (
/**
* @param {ol.Coordinate|undefined} center Center.
* @return {ol.Coordinate|undefined} Center.
*/
function(center) {
if (center) {
return [
ol.math.clamp(center[0], extent[0], extent[2]),
ol.math.clamp(center[1], extent[1], extent[3])
];
} else {
return undefined;
}
});
/**
* @param {ol.Coordinate|undefined} center Center.
* @return {ol.Coordinate|undefined} Center.
*/
function(center) {
if (center) {
return [
ol.math.clamp(center[0], extent[0], extent[2]),
ol.math.clamp(center[1], extent[1], extent[3])
];
} else {
return undefined;
}
});
};


Expand Down
84 changes: 42 additions & 42 deletions src/ol/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,56 +72,56 @@ ol.color.fromNamed = function(color) {
* @return {ol.Color} Color.
*/
ol.color.fromString = (
function() {
function() {

// We maintain a small cache of parsed strings. To provide cheap LRU-like
// semantics, whenever the cache grows too large we simply delete an
// arbitrary 25% of the entries.
// We maintain a small cache of parsed strings. To provide cheap LRU-like
// semantics, whenever the cache grows too large we simply delete an
// arbitrary 25% of the entries.

/**
* @const
* @type {number}
*/
var MAX_CACHE_SIZE = 1024;
/**
* @const
* @type {number}
*/
var MAX_CACHE_SIZE = 1024;

/**
* @type {Object.<string, ol.Color>}
*/
var cache = {};
/**
* @type {Object.<string, ol.Color>}
*/
var cache = {};

/**
* @type {number}
*/
var cacheSize = 0;

return (
/**
* @type {number}
* @param {string} s String.
* @return {ol.Color} Color.
*/
var cacheSize = 0;

return (
/**
* @param {string} s String.
* @return {ol.Color} Color.
*/
function(s) {
var color;
if (cache.hasOwnProperty(s)) {
color = cache[s];
} else {
if (cacheSize >= MAX_CACHE_SIZE) {
var i = 0;
var key;
for (key in cache) {
if ((i++ & 3) === 0) {
delete cache[key];
--cacheSize;
}
}
function(s) {
var color;
if (cache.hasOwnProperty(s)) {
color = cache[s];
} else {
if (cacheSize >= MAX_CACHE_SIZE) {
var i = 0;
var key;
for (key in cache) {
if ((i++ & 3) === 0) {
delete cache[key];
--cacheSize;
}
color = ol.color.fromStringInternal_(s);
cache[s] = color;
++cacheSize;
}
return color;
});

})();
}
color = ol.color.fromStringInternal_(s);
cache[s] = color;
++cacheSize;
}
return color;
});

})();


/**
Expand Down
6 changes: 3 additions & 3 deletions src/ol/colorlike.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ ol.colorlike.asColorLike = function(color) {
*/
ol.colorlike.isColorLike = function(color) {
return (
typeof color === 'string' ||
color instanceof CanvasPattern ||
color instanceof CanvasGradient
typeof color === 'string' ||
color instanceof CanvasPattern ||
color instanceof CanvasGradient
);
};
2 changes: 1 addition & 1 deletion src/ol/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ol.control.defaults = function(opt_options) {
}

var attributionControl = options.attribution !== undefined ?
options.attribution : true;
options.attribution : true;
if (attributionControl) {
controls.push(new ol.control.Attribution(options.attributionOptions));
}
Expand Down
4 changes: 2 additions & 2 deletions src/ol/control/attribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ol.control.Attribution = function(opt_options) {
* @type {boolean}
*/
this.collapsible_ = options.collapsible !== undefined ?
options.collapsible : true;
options.collapsible : true;

if (!this.collapsible_) {
this.collapsed_ = false;
Expand Down Expand Up @@ -91,7 +91,7 @@ ol.control.Attribution = function(opt_options) {


var activeLabel = (this.collapsible_ && !this.collapsed_) ?
this.collapseLabel_ : this.label_;
this.collapseLabel_ : this.label_;
var button = document.createElement('button');
button.setAttribute('type', 'button');
button.title = tipLabel;
Expand Down
2 changes: 1 addition & 1 deletion src/ol/control/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ol.control.Control.prototype.setMap = function(map) {
this.map_ = map;
if (this.map_) {
var target = this.target_ ?
this.target_ : map.getOverlayContainerStopEvent();
this.target_ : map.getOverlayContainerStopEvent();
target.appendChild(this.element);
if (this.render !== ol.nullFunction) {
this.listenerKeys.push(ol.events.listen(map,
Expand Down

0 comments on commit 9fc0fb5

Please sign in to comment.