more strict eslinting
This commit is contained in:
parent
bcde047f09
commit
301473ad4d
46
.eslintrc
46
.eslintrc
@ -1,42 +1,18 @@
|
||||
{
|
||||
"rules": {
|
||||
"eqeqeq": 2,
|
||||
"consistent-return": 2,
|
||||
"no-loop-func": 2,
|
||||
"no-use-before-define": [2, "nofunc"],
|
||||
"no-lonely-if": 2,
|
||||
"no-else-return": 2,
|
||||
"no-new": 2,
|
||||
"no-throw-literal": 2,
|
||||
"no-self-compare": 2,
|
||||
"no-void": 2,
|
||||
"no-eq-null": 2,
|
||||
|
||||
"quotes": [2, "single"],
|
||||
"camelcase": 2,
|
||||
"comma-style": 2,
|
||||
"comma-spacing": 2,
|
||||
"new-cap": 2,
|
||||
"no-empty": 2,
|
||||
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
|
||||
"space-in-parens": 2,
|
||||
"space-before-blocks": 2,
|
||||
"space-after-keywords": 2,
|
||||
"space-infix-ops": 2,
|
||||
"space-unary-ops": 2,
|
||||
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
|
||||
"array-bracket-spacing": 2,
|
||||
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
|
||||
|
||||
"no-constant-condition": 0
|
||||
},
|
||||
"globals": {
|
||||
"L": true,
|
||||
"module": false,
|
||||
"define": false
|
||||
},
|
||||
"env": {
|
||||
"browser": true
|
||||
"commonjs": true,
|
||||
"amd": true,
|
||||
"node": false
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
"extends": "mourner",
|
||||
"rules": {
|
||||
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
|
||||
"indent": [2, "tab", {"VariableDeclarator": 0}],
|
||||
"strict": 0,
|
||||
"wrap-iife": 0,
|
||||
"key-spacing": 0
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,8 @@
|
||||
"description": "JavaScript library for mobile-friendly interactive maps",
|
||||
"devDependencies": {
|
||||
"copyfiles": "0.2.1",
|
||||
"eslint": "^1.3.1",
|
||||
"eslint": "^1.5.1",
|
||||
"eslint-config-mourner": "^1.0.0",
|
||||
"happen": "~0.2.0",
|
||||
"jake": "~8.0.12",
|
||||
"karma": "~0.13.9",
|
||||
|
@ -4,21 +4,15 @@
|
||||
"quotes": 0,
|
||||
"no-shadow": 0,
|
||||
"no-irregular-whitespace": 0,
|
||||
"no-console": 0
|
||||
},
|
||||
"globals": {
|
||||
"L": true,
|
||||
"module": false,
|
||||
"define": false,
|
||||
"expect": false,
|
||||
"it": false,
|
||||
"describe": false,
|
||||
"sinon": false,
|
||||
"happen": false,
|
||||
"beforeEach": false,
|
||||
"afterEach": false
|
||||
"no-console": 0,
|
||||
"indent": 0
|
||||
},
|
||||
"env": {
|
||||
"browser": true
|
||||
"mocha": true
|
||||
},
|
||||
"globals": {
|
||||
"expect": false,
|
||||
"sinon": false,
|
||||
"happen": false
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ describe("CRS.Simple", function () {
|
||||
|
||||
describe("CRS", function () {
|
||||
var crs = L.CRS;
|
||||
|
||||
|
||||
describe("#zoom && #scale", function () {
|
||||
it("convert zoom to scale and viceversa and return the same values", function () {
|
||||
var zoom = 2.5;
|
||||
@ -188,7 +188,7 @@ describe("CRS.ZoomNotPowerOfTwo", function () {
|
||||
expect(crs.zoom(1.5 * scale)).to.eql(zoom + 1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("#zoom && #scale", function () {
|
||||
it("convert zoom to scale and viceversa and return the same values", function () {
|
||||
var zoom = 2;
|
||||
@ -196,4 +196,4 @@ describe("CRS.ZoomNotPowerOfTwo", function () {
|
||||
expect(crs.zoom(scale)).to.eql(zoom);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -746,7 +746,7 @@ describe("Map", function () {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('#getScaleZoom && #getZoomScale', function () {
|
||||
it("convert zoom to scale and viceversa and return the same values", function () {
|
||||
var toZoom = 6.25;
|
||||
|
@ -262,7 +262,7 @@ L.Control.Layers = L.Control.extend({
|
||||
L.DomUtil.addClass(this._form, 'leaflet-control-layers-scrollbar');
|
||||
this._form.style.height = acceptableHeight + 'px';
|
||||
} else {
|
||||
L.DomUtil.removeClass(this._form, 'leaflet-control-layers-scrollbar');
|
||||
L.DomUtil.removeClass(this._form, 'leaflet-control-layers-scrollbar');
|
||||
}
|
||||
this._checkDisabledLayers();
|
||||
},
|
||||
|
@ -72,7 +72,7 @@ L.Control.Zoom = L.Control.extend({
|
||||
|
||||
_updateDisabled: function () {
|
||||
var map = this._map,
|
||||
className = 'leaflet-disabled';
|
||||
className = 'leaflet-disabled';
|
||||
|
||||
L.DomUtil.removeClass(this._zoomInButton, className);
|
||||
L.DomUtil.removeClass(this._zoomOutButton, className);
|
||||
|
@ -37,7 +37,7 @@ L.extend(L.DomEvent, {
|
||||
if (L.Browser.pointer) {
|
||||
// work around .type being readonly with MSPointer* events
|
||||
var newTouch = {},
|
||||
prop, i;
|
||||
prop, i;
|
||||
|
||||
for (i in touch) {
|
||||
prop = touch[i];
|
||||
|
@ -230,7 +230,7 @@ L.DomEvent = {
|
||||
// this is a horrible workaround for a bug in Android where a single touch triggers two click events
|
||||
_filterClick: function (e, handler) {
|
||||
var timeStamp = (e.timeStamp || e.originalEvent.timeStamp),
|
||||
elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);
|
||||
elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);
|
||||
|
||||
// are they closer together than 500ms yet more than 100ms?
|
||||
// Android typically triggers them ~300ms apart while multiple listeners
|
||||
|
@ -143,7 +143,10 @@ L.DomUtil = {
|
||||
var pos = offset || new L.Point(0, 0);
|
||||
|
||||
el.style[L.DomUtil.TRANSFORM] =
|
||||
(L.Browser.ie3d ? 'translate(' + pos.x + 'px,' + pos.y + 'px' + ')' : 'translate3d(' + pos.x + 'px,' + pos.y + 'px' + ',0)') + (scale ? ' scale(' + scale + ')' : '');
|
||||
(L.Browser.ie3d ?
|
||||
'translate(' + pos.x + 'px,' + pos.y + 'px)' :
|
||||
'translate3d(' + pos.x + 'px,' + pos.y + 'px,0)') +
|
||||
(scale ? ' scale(' + scale + ')' : '');
|
||||
},
|
||||
|
||||
setPosition: function (el, point) { // (HTMLElement, Point[, Boolean])
|
||||
|
@ -44,7 +44,7 @@ L.LatLng.prototype = {
|
||||
|
||||
toBounds: function (sizeInMeters) {
|
||||
var latAccuracy = 180 * sizeInMeters / 40075017,
|
||||
lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
|
||||
lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
|
||||
|
||||
return L.latLngBounds(
|
||||
[this.lat - latAccuracy, this.lng - lngAccuracy],
|
||||
|
@ -17,8 +17,8 @@ L.LatLngBounds.prototype = {
|
||||
// extend the bounds to contain the given point or bounds
|
||||
extend: function (obj) { // (LatLng) or (LatLngBounds)
|
||||
var sw = this._southWest,
|
||||
ne = this._northEast,
|
||||
sw2, ne2;
|
||||
ne = this._northEast,
|
||||
sw2, ne2;
|
||||
|
||||
if (obj instanceof L.LatLng) {
|
||||
sw2 = obj;
|
||||
|
@ -33,7 +33,7 @@ L.CRS = {
|
||||
scale: function (zoom) {
|
||||
return 256 * Math.pow(2, zoom);
|
||||
},
|
||||
|
||||
|
||||
zoom: function (scale) {
|
||||
return Math.log(scale / 256) / Math.LN2;
|
||||
},
|
||||
|
@ -250,7 +250,7 @@ L.LayerGroup.include({
|
||||
}
|
||||
|
||||
var isGeometryCollection = type === 'GeometryCollection',
|
||||
jsons = [];
|
||||
jsons = [];
|
||||
|
||||
this.eachLayer(function (layer) {
|
||||
if (layer.toGeoJSON) {
|
||||
|
@ -138,7 +138,7 @@ L.ImageOverlay = L.Layer.extend({
|
||||
|
||||
_animateZoom: function (e) {
|
||||
var scale = this._map.getZoomScale(e.zoom),
|
||||
offset = this._map._latLngToNewLayerPoint(this._bounds.getNorthWest(), e.zoom, e.center);
|
||||
offset = this._map._latLngToNewLayerPoint(this._bounds.getNorthWest(), e.zoom, e.center);
|
||||
|
||||
L.DomUtil.setTransform(this._image, offset, scale);
|
||||
},
|
||||
|
@ -144,8 +144,8 @@ L.Map.include({
|
||||
|
||||
_updateZoomLevels: function () {
|
||||
var minZoom = Infinity,
|
||||
maxZoom = -Infinity,
|
||||
oldZoomSpan = this._getZoomSpan();
|
||||
maxZoom = -Infinity,
|
||||
oldZoomSpan = this._getZoomSpan();
|
||||
|
||||
for (var i in this._zoomBoundLayers) {
|
||||
var options = this._zoomBoundLayers[i].options;
|
||||
|
@ -106,7 +106,7 @@ L.Marker = L.Layer.extend({
|
||||
classToAdd = 'leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide');
|
||||
|
||||
var icon = options.icon.createIcon(this._icon),
|
||||
addIcon = false;
|
||||
addIcon = false;
|
||||
|
||||
// if we're not reusing the icon, remove the old one and init new one
|
||||
if (icon !== this._icon) {
|
||||
@ -139,7 +139,7 @@ L.Marker = L.Layer.extend({
|
||||
}
|
||||
|
||||
var newShadow = options.icon.createShadow(this._shadow),
|
||||
addShadow = false;
|
||||
addShadow = false;
|
||||
|
||||
if (newShadow !== this._shadow) {
|
||||
this._removeShadow();
|
||||
@ -170,7 +170,7 @@ L.Marker = L.Layer.extend({
|
||||
if (this.options.riseOnHover) {
|
||||
this.off({
|
||||
mouseover: this._bringToFront,
|
||||
mouseout: this._resetZIndex
|
||||
mouseout: this._resetZIndex
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -165,8 +165,8 @@ L.GridLayer = L.Layer.extend({
|
||||
L.DomUtil.setOpacity(this._container, this.options.opacity);
|
||||
|
||||
var now = +new Date(),
|
||||
nextFrame = false,
|
||||
willPrune = false;
|
||||
nextFrame = false,
|
||||
willPrune = false;
|
||||
|
||||
for (var key in this._tiles) {
|
||||
var tile = this._tiles[key];
|
||||
@ -207,7 +207,7 @@ L.GridLayer = L.Layer.extend({
|
||||
_updateLevels: function () {
|
||||
|
||||
var zoom = this._tileZoom,
|
||||
maxZoom = this.options.maxZoom;
|
||||
maxZoom = this.options.maxZoom;
|
||||
|
||||
for (var z in this._levels) {
|
||||
if (this._levels[z].el.children.length || z === zoom) {
|
||||
@ -289,11 +289,11 @@ L.GridLayer = L.Layer.extend({
|
||||
|
||||
_retainParent: function (x, y, z, minZoom) {
|
||||
var x2 = Math.floor(x / 2),
|
||||
y2 = Math.floor(y / 2),
|
||||
z2 = z - 1;
|
||||
y2 = Math.floor(y / 2),
|
||||
z2 = z - 1;
|
||||
|
||||
var key = x2 + ':' + y2 + ':' + z2,
|
||||
tile = this._tiles[key];
|
||||
tile = this._tiles[key];
|
||||
|
||||
if (tile && tile.active) {
|
||||
tile.retain = true;
|
||||
@ -316,7 +316,7 @@ L.GridLayer = L.Layer.extend({
|
||||
for (var j = 2 * y; j < 2 * y + 2; j++) {
|
||||
|
||||
var key = i + ':' + j + ':' + (z + 1),
|
||||
tile = this._tiles[key];
|
||||
tile = this._tiles[key];
|
||||
|
||||
if (tile && tile.active) {
|
||||
tile.retain = true;
|
||||
@ -424,11 +424,10 @@ L.GridLayer = L.Layer.extend({
|
||||
},
|
||||
|
||||
_getTiledPixelBounds: function (center, zoom, tileZoom) {
|
||||
var map = this._map;
|
||||
|
||||
var scale = map.getZoomScale(zoom, tileZoom),
|
||||
pixelCenter = map.project(center, tileZoom).floor(),
|
||||
halfSize = map.getSize().divideBy(scale * 2);
|
||||
var map = this._map,
|
||||
scale = map.getZoomScale(zoom, tileZoom),
|
||||
pixelCenter = map.project(center, tileZoom).floor(),
|
||||
halfSize = map.getSize().divideBy(scale * 2);
|
||||
|
||||
return new L.Bounds(pixelCenter.subtract(halfSize), pixelCenter.add(halfSize));
|
||||
},
|
||||
@ -442,11 +441,10 @@ L.GridLayer = L.Layer.extend({
|
||||
if (center === undefined) { center = map.getCenter(); }
|
||||
if (this._tileZoom === undefined) { return; } // if out of minzoom/maxzoom
|
||||
|
||||
var pixelBounds = this._getTiledPixelBounds(center, zoom, this._tileZoom);
|
||||
|
||||
var tileRange = this._pxBoundsToTileRange(pixelBounds),
|
||||
tileCenter = tileRange.getCenter(),
|
||||
queue = [];
|
||||
var pixelBounds = this._getTiledPixelBounds(center, zoom, this._tileZoom),
|
||||
tileRange = this._pxBoundsToTileRange(pixelBounds),
|
||||
tileCenter = tileRange.getCenter(),
|
||||
queue = [];
|
||||
|
||||
for (var key in this._tiles) {
|
||||
this._tiles[key].current = false;
|
||||
@ -540,7 +538,7 @@ L.GridLayer = L.Layer.extend({
|
||||
// converts tile cache key to coordinates
|
||||
_keyToTileCoords: function (key) {
|
||||
var k = key.split(':'),
|
||||
coords = new L.Point(+k[0], +k[1]);
|
||||
coords = new L.Point(+k[0], +k[1]);
|
||||
coords.z = +k[2];
|
||||
return coords;
|
||||
},
|
||||
|
@ -82,7 +82,7 @@ L.Canvas = L.Renderer.extend({
|
||||
|
||||
var padding = (layer.options.weight || 0) + 1;
|
||||
this._redrawBounds = this._redrawBounds || new L.Bounds();
|
||||
this._redrawBounds.extend(layer._pxBounds.min.subtract([padding, padding]))
|
||||
this._redrawBounds.extend(layer._pxBounds.min.subtract([padding, padding]));
|
||||
this._redrawBounds.extend(layer._pxBounds.max.add([padding, padding]));
|
||||
|
||||
this._redrawRequest = this._redrawRequest || L.Util.requestAnimFrame(this._redraw, this);
|
||||
|
@ -134,7 +134,7 @@ L.Polyline = L.Path.extend({
|
||||
|
||||
// project bounds as well to use later for Canvas hit detection/etc.
|
||||
var w = this._clickTolerance(),
|
||||
p = new L.Point(w, -w);
|
||||
p = new L.Point(w, -w);
|
||||
|
||||
if (this._bounds.isValid()) {
|
||||
this._pxBounds = new L.Bounds(
|
||||
@ -203,7 +203,7 @@ L.Polyline = L.Path.extend({
|
||||
// simplify each clipped part of the polyline for performance
|
||||
_simplifyPoints: function () {
|
||||
var parts = this._parts,
|
||||
tolerance = this.options.smoothFactor;
|
||||
tolerance = this.options.smoothFactor;
|
||||
|
||||
for (var i = 0, len = parts.length; i < len; i++) {
|
||||
parts[i] = L.LineUtil.simplify(parts[i], tolerance);
|
||||
|
@ -68,7 +68,7 @@ L.SVG = L.Renderer.extend({
|
||||
|
||||
_updateStyle: function (layer) {
|
||||
var path = layer._path,
|
||||
options = layer.options;
|
||||
options = layer.options;
|
||||
|
||||
if (!path) { return; }
|
||||
|
||||
@ -147,7 +147,7 @@ L.extend(L.SVG, {
|
||||
// generates SVG path string for multiple rings, with each ring turning into "M..L..L.." instructions
|
||||
pointsToPath: function (rings, closed) {
|
||||
var str = '',
|
||||
i, j, len, len2, points, p;
|
||||
i, j, len, len2, points, p;
|
||||
|
||||
for (i = 0, len = rings.length; i < len; i++) {
|
||||
points = rings[i];
|
||||
|
@ -177,7 +177,7 @@ L.Map = L.Evented.extend({
|
||||
|
||||
panInsideBounds: function (bounds, options) {
|
||||
var center = this.getCenter(),
|
||||
newCenter = this._limitCenter(center, this._zoom, L.latLngBounds(bounds));
|
||||
newCenter = this._limitCenter(center, this._zoom, L.latLngBounds(bounds));
|
||||
|
||||
if (center.equals(newCenter)) { return this; }
|
||||
|
||||
@ -709,8 +709,8 @@ L.Map = L.Evented.extend({
|
||||
|
||||
for (var i = 0; i < targets.length; i++) {
|
||||
targets[i].fire(type, data, true);
|
||||
if (data.originalEvent._stopped
|
||||
|| (targets[i].options.nonBubblingEvents && L.Util.indexOf(targets[i].options.nonBubblingEvents, type) !== -1)) { return; }
|
||||
if (data.originalEvent._stopped ||
|
||||
(targets[i].options.nonBubblingEvents && L.Util.indexOf(targets[i].options.nonBubblingEvents, type) !== -1)) { return; }
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -35,7 +35,7 @@ L.Map.include(!zoomAnimated ? {} : {
|
||||
|
||||
this.on('zoomanim', function (e) {
|
||||
var prop = L.DomUtil.TRANSFORM,
|
||||
transform = proxy.style[prop];
|
||||
transform = proxy.style[prop];
|
||||
|
||||
L.DomUtil.setTransform(proxy, this.project(e.center, e.zoom), this.getZoomScale(e.zoom, 1));
|
||||
|
||||
@ -47,7 +47,7 @@ L.Map.include(!zoomAnimated ? {} : {
|
||||
|
||||
this.on('load moveend', function () {
|
||||
var c = this.getCenter(),
|
||||
z = this.getZoom();
|
||||
z = this.getZoom();
|
||||
L.DomUtil.setTransform(proxy, this.project(c, z), this.getZoomScale(z, 1));
|
||||
}, this);
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ L.Map.include({
|
||||
}
|
||||
|
||||
var onResponse = L.bind(this._handleGeolocationResponse, this),
|
||||
onError = L.bind(this._handleGeolocationError, this);
|
||||
onError = L.bind(this._handleGeolocationError, this);
|
||||
|
||||
if (options.watch) {
|
||||
this._locationWatchId =
|
||||
|
Loading…
Reference in New Issue
Block a user