]> git.openstreetmap.org Git - rails.git/commitdiff
Enable a few more eslint checks
authorTom Hughes <tom@compton.nu>
Sun, 14 Jul 2019 11:08:02 +0000 (12:08 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 14 Jul 2019 11:08:02 +0000 (12:08 +0100)
app/assets/javascripts/index.js
app/assets/javascripts/index/directions.js
app/assets/javascripts/index/history.js
app/assets/javascripts/index/notes.js
app/assets/javascripts/index/query.js
app/assets/javascripts/leaflet.map.js
app/assets/javascripts/router.js
config/eslint.json

index fd707e566e2902f42873bcbd49bc5dce8dc33b58..935889acee7fc3629290c2eacfdbc61f43abf90d 100644 (file)
@@ -32,6 +32,8 @@ $(document).ready(function () {
   });
 
   OSM.loadSidebarContent = function (path, callback) {
+    var content_path = path;
+
     map.setSidebarOverlaid(false);
 
     clearTimeout(loaderTimeout);
@@ -42,17 +44,17 @@ $(document).ready(function () {
 
     // IE<10 doesn't respect Vary: X-Requested-With header, so
     // prevent caching the XHR response as a full-page URL.
-    if (path.indexOf("?") >= 0) {
-      path += "&xhr=1";
+    if (content_path.indexOf("?") >= 0) {
+      content_path += "&xhr=1";
     } else {
-      path += "?xhr=1";
+      content_path += "?xhr=1";
     }
 
     $("#sidebar_content")
       .empty();
 
     $.ajax({
-      url: path,
+      url: content_path,
       dataType: "html",
       complete: function (xhr) {
         clearTimeout(loaderTimeout);
index b14c05e29a3e1781af700a6e459af2b6a294fdf8..4f65acdea96afcf420ca57eb6eb49d2275df4f08 100644 (file)
@@ -3,7 +3,7 @@
 
 OSM.Directions = function (map) {
   var awaitingGeocode; // true if the user has requested a route, but we're waiting on a geocode result
-  var awaitingRoute;   // true if we've asked the engine for a route and are waiting to hear back
+  var awaitingRoute; // true if we've asked the engine for a route and are waiting to hear back
   var chosenEngine;
 
   var popup = L.popup({ autoPanPadding: [100, 100] });
@@ -31,9 +31,9 @@ OSM.Directions = function (map) {
   var engines = OSM.Directions.engines;
 
   engines.sort(function (a, b) {
-    a = I18n.t("javascripts.directions.engines." + a.id);
-    b = I18n.t("javascripts.directions.engines." + b.id);
-    return a.localeCompare(b);
+    var localised_a = I18n.t("javascripts.directions.engines." + a.id),
+        localised_b = I18n.t("javascripts.directions.engines." + b.id);
+    return localised_a.localeCompare(localised_b);
   });
 
   var select = $("select.routing_engines");
@@ -260,11 +260,11 @@ OSM.Directions = function (map) {
 
       // Add each row
       route.steps.forEach(function (step) {
-        var ll          = step[0],
-            direction   = step[1],
+        var ll = step[0],
+            direction = step[1],
             instruction = step[2],
-            dist        = step[3],
-            lineseg     = step[4];
+            dist = step[3],
+            lineseg = step[4];
 
         if (dist < 5) {
           dist = "";
@@ -360,7 +360,7 @@ OSM.Directions = function (map) {
       var oe = e.originalEvent;
       var dragData = JSON.parse(oe.dataTransfer.getData("text"));
       var type = dragData.type;
-      var pt = L.DomEvent.getMousePosition(oe, map.getContainer());  // co-ordinates of the mouse pointer at present
+      var pt = L.DomEvent.getMousePosition(oe, map.getContainer()); // co-ordinates of the mouse pointer at present
       pt.y += 20;
       var ll = map.containerPointToLatLng(pt);
       endpoints[type === "from" ? 0 : 1].setLatLng(ll);
index ed0ff3d9aada28cdcd4652aab4512ec6d4367695..80fb68444f6469ee4e41e03d2f09654a337dfe12 100644 (file)
@@ -101,7 +101,7 @@ OSM.History = function (map) {
           topRight = map.project(L.latLng(changeset.bbox.maxlat, changeset.bbox.maxlon)),
           width = topRight.x - bottomLeft.x,
           height = bottomLeft.y - topRight.y,
-          minSize = 20;  // Min width/height of changeset in pixels
+          minSize = 20; // Min width/height of changeset in pixels
 
       if (width < minSize) {
         bottomLeft.x -= ((minSize - width) / 2);
index 4890a2687d1a86a69811ad46d54a1a870227c1a4..5d553e970c4be49aa9a05f0c6984c1e0361429d3 100644 (file)
@@ -39,7 +39,8 @@ OSM.initializeNotes = function (map) {
     }
   });
 
-  function updateMarker(marker, feature) {
+  function updateMarker(old_marker, feature) {
+    var marker = old_marker;
     if (marker) {
       marker.setIcon(noteIcons[feature.properties.status]);
     } else {
index 8583c805a1c52bffb10b127a59e9a1739964b860..8a190a90ab3f7c1356d3c5c3c642fae0f3086fc9 100644 (file)
@@ -153,7 +153,7 @@ OSM.Query = function (map) {
       }), featureStyle);
     } else if (feature.type === "relation" && feature.members) {
       geometry = L.featureGroup(feature.members.map(featureGeometry).filter(function (geometry) {
-        return geometry !== undefined;
+        return typeof geometry !== "undefined";
       }));
     }
 
index 4d42030bc251b9fadfa1892189a3bc6294a0f469..4d9fbac8e35167e951f96f8cfd26bc15225cb9b9 100644 (file)
@@ -71,11 +71,11 @@ L.OSM.Map = L.Map.extend({
   },
 
   updateLayers: function (layerParam) {
-    layerParam = layerParam || "M";
-    var layersAdded = "";
+    var layers = layerParam || "M",
+        layersAdded = "";
 
     for (var i = this.baseLayers.length - 1; i >= 0; i--) {
-      if (layerParam.indexOf(this.baseLayers[i].options.code) >= 0) {
+      if (layers.indexOf(this.baseLayers[i].options.code) >= 0) {
         this.addLayer(this.baseLayers[i]);
         layersAdded = layersAdded + this.baseLayers[i].options.code;
       } else if (i === 0 && layersAdded === "") {
@@ -152,15 +152,17 @@ L.OSM.Map = L.Map.extend({
 
     // Called to interlace the bits in x and y, making a Morton code.
     function interlace(x, y) {
-      x = (x | (x << 8)) & 0x00ff00ff;
-      x = (x | (x << 4)) & 0x0f0f0f0f;
-      x = (x | (x << 2)) & 0x33333333;
-      x = (x | (x << 1)) & 0x55555555;
-      y = (y | (y << 8)) & 0x00ff00ff;
-      y = (y | (y << 4)) & 0x0f0f0f0f;
-      y = (y | (y << 2)) & 0x33333333;
-      y = (y | (y << 1)) & 0x55555555;
-      return (x << 1) | y;
+      var interlaced_x = x,
+          interlaced_y = y;
+      interlaced_x = (interlaced_x | (interlaced_x << 8)) & 0x00ff00ff;
+      interlaced_x = (interlaced_x | (interlaced_x << 4)) & 0x0f0f0f0f;
+      interlaced_x = (interlaced_x | (interlaced_x << 2)) & 0x33333333;
+      interlaced_x = (interlaced_x | (interlaced_x << 1)) & 0x55555555;
+      interlaced_y = (interlaced_y | (interlaced_y << 8)) & 0x00ff00ff;
+      interlaced_y = (interlaced_y | (interlaced_y << 4)) & 0x0f0f0f0f;
+      interlaced_y = (interlaced_y | (interlaced_y << 2)) & 0x33333333;
+      interlaced_y = (interlaced_y | (interlaced_y << 1)) & 0x55555555;
+      return (interlaced_x << 1) | interlaced_y;
     }
 
     var params = {};
index 7bd2aabb981abf7548b4270989249aa98135ff9e..c397a44ec4de3eeeb0e338aceaeca557f3a6865c 100644 (file)
    move the map without the hash changing.
  */
 OSM.Router = function (map, rts) {
-  var escapeRegExp  = /[-{}[\]+?.,\\^$|#\s]/g;
+  var escapeRegExp = /[-{}[\]+?.,\\^$|#\s]/g;
   var optionalParam = /\((.*?)\)/g;
-  var namedParam    = /(\(\?)?:\w+/g;
-  var splatParam    = /\*\w+/g;
+  var namedParam = /(\(\?)?:\w+/g;
+  var splatParam = /\*\w+/g;
 
   function Route(path, controller) {
     var regexp = new RegExp("^" +
index 090b3f238382a4ba77a99181278f3cc958cdd5e6..2e9567a4ebba88369fee71bdf9034415f108af77 100644 (file)
@@ -29,6 +29,7 @@
     "comma-style": "error",
     "computed-property-spacing": "error",
     "curly": ["error", "multi-line", "consistent"],
+    "dot-location": ["error", "property"],
     "dot-notation": "error",
     "eol-last": "error",
     "eqeqeq": ["error", "smart"],
@@ -45,7 +46,9 @@
     "no-alert": "warn",
     "no-array-constructor": "error",
     "no-caller": "error",
+    "no-console": "warn",
     "no-div-regex": "error",
+    "no-eq-null": "error",
     "no-eval": "error",
     "no-extend-native": "error",
     "no-extra-bind": "error",
@@ -54,6 +57,7 @@
     "no-implicit-coercion": "warn",
     "no-implicit-globals": "warn",
     "no-implied-eval": "error",
+    "no-invalid-this": "error",
     "no-iterator": "error",
     "no-labels": "error",
     "no-label-var": "error",
@@ -62,6 +66,7 @@
     "no-loop-func": "error",
     "no-mixed-operators": "error",
     "no-multiple-empty-lines": "error",
+    "no-multi-spaces": "error",
     "no-multi-str": "error",
     "no-negated-condition": "error",
     "no-nested-ternary": "error",
     "no-new-object": "error",
     "no-new-wrappers": "error",
     "no-octal-escape": "error",
+    "no-param-reassign": "error",
     "no-process-env": "error",
     "no-proto": "error",
     "no-script-url": "error",
     "no-self-compare": "error",
     "no-sequences": "error",
-    "no-shadow-restricted-names": "error",
     "no-throw-literal": "error",
     "no-trailing-spaces": "error",
+    "no-undef-init": "error",
+    "no-undefined": "error",
     "no-unmodified-loop-condition": "error",
     "no-unneeded-ternary": "error",
     "no-unused-expressions": "off",
@@ -89,7 +96,6 @@
     "no-void": "error",
     "no-warning-comments": "warn",
     "no-whitespace-before-property": "error",
-    "no-with": "error",
     "object-curly-newline": ["error", { "consistent": true }],
     "object-curly-spacing": ["error", "always"],
     "object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }],