]> git.openstreetmap.org Git - rails.git/commitdiff
Enable a few linting rules
authorMarwin Hochfelsner <50826859+hlfan@users.noreply.github.com>
Mon, 10 Feb 2025 16:15:45 +0000 (17:15 +0100)
committerMarwin Hochfelsner <50826859+hlfan@users.noreply.github.com>
Mon, 10 Feb 2025 19:10:13 +0000 (20:10 +0100)
app/assets/javascripts/application.js
app/assets/javascripts/index/contextmenu.js
app/assets/javascripts/index/layers/data.js
app/assets/javascripts/index/query.js
app/assets/javascripts/leaflet.locate.js
app/assets/javascripts/osm.js.erb
config/eslint.js

index 86a0a0789962abcc08c9de91aaf853d3991b8cbf..2e13f69671bec7253adbe5c98887a33c105d7725 100644 (file)
@@ -113,13 +113,13 @@ $(document).ready(function () {
    */
   setTimeout(function () {
     $("header").children(":visible").each(function (i, e) {
-      headerWidth = headerWidth + $(e).outerWidth();
+      headerWidth += $(e).outerWidth();
     });
 
     $("body").addClass("compact-nav");
 
     $("header").children(":visible").each(function (i, e) {
-      compactWidth = compactWidth + $(e).outerWidth();
+      compactWidth += $(e).outerWidth();
     });
 
     $("body").removeClass("compact-nav");
index fea7e73145415ecf36bca270b53f19feab5683f3..d7e6b427da6ce585a03b8e0581ddfd793e9d9a24 100644 (file)
@@ -65,9 +65,8 @@ OSM.initializeContextMenu = function (map) {
   function getDirectionsEndpointCoordinatesFromInput(input) {
     if (input.attr("data-lat") && input.attr("data-lon")) {
       return input.attr("data-lat") + "," + input.attr("data-lon");
-    } else {
-      return $(input).val();
     }
+    return $(input).val();
   }
 
   var updateMenu = function updateMenu() {
index dc522af418d809f6e16c90ccf5b91a67bf211494..e6a7cc66684be0323361d21758156a9ee816ffb8 100644 (file)
@@ -121,7 +121,7 @@ OSM.initializeDataLayer = function (map) {
       },
       error: function (XMLHttpRequest, textStatus) {
         dataLoader = null;
-        if (textStatus === "abort") { return; }
+        if (textStatus === "abort") return;
 
         function closeError() {
           $("#browse_status").empty();
index 5c8ee88760ceb549adb01ed81efdfb2797bae47d..54d5e080fb0f5675a968bcd720f9a0373ae5e23c 100644 (file)
@@ -115,17 +115,16 @@ OSM.Query = function (map) {
       }
     }
 
-    if (tags.name) {
-      return tags.name;
-    } else if (tags.ref) {
-      return tags.ref;
-    } else if (tags["addr:housename"]) {
-      return tags["addr:housename"];
-    } else if (tags["addr:housenumber"] && tags["addr:street"]) {
+    for (const key of ["name", "ref", "addr:housename"]) {
+      if (tags[key]) {
+        return tags[key];
+      }
+    }
+
+    if (tags["addr:housenumber"] && tags["addr:street"]) {
       return tags["addr:housenumber"] + " " + tags["addr:street"];
-    } else {
-      return "#" + feature.id;
     }
+    return "#" + feature.id;
   }
 
   function featureGeometry(feature) {
@@ -285,10 +284,11 @@ OSM.Query = function (map) {
       .hide();
 
     if (marker) map.removeLayer(marker);
-    marker = L.circle(latlng, Object.assign({
+    marker = L.circle(latlng, {
       radius: radius,
-      className: "query-marker"
-    }, featureStyle)).addTo(map);
+      className: "query-marker",
+      ...featureStyle
+    }).addTo(map);
 
     runQuery(latlng, radius, nearby, $("#query-nearby"), false);
     runQuery(latlng, radius, isin, $("#query-isin"), true, compareSize);
index d43a5e458fe4e1615f445509bb32bf9c230d8839..d199292083d93bbbded0586326f6f5e09a0056dc 100644 (file)
@@ -1,5 +1,5 @@
 L.OSM.locate = function (options) {
-  var control = L.control.locate(Object.assign({
+  var control = L.control.locate({
     icon: "icon geolocate",
     iconLoading: "icon geolocate",
     strings: {
@@ -7,8 +7,9 @@ L.OSM.locate = function (options) {
       popup: function (options) {
         return I18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
       }
-    }
-  }, options));
+    },
+    ...options
+  });
 
   control.onAdd = function (map) {
     var container = Object.getPrototypeOf(this).onAdd.apply(this, [map]);
index 030c51a08e6901b0e1ce524f851e2c6430ce6466..062d537ffe8347195e8a70d588400ae725674a5a 100644 (file)
@@ -62,7 +62,8 @@ OSM = {
   },
 
   mapParams: function (search) {
-    var params = OSM.params(search), mapParams = {};
+    var params = OSM.params(search),
+        mapParams = {};
 
     if (params.mlon && params.mlat) {
       mapParams.marker = true;
index f51a1dc474b674a6282dd17ee787361d449892b4..f21c87938eeaa995b415e003ce07cc0498abb031 100644 (file)
@@ -56,6 +56,7 @@ module.exports = [
       }],
       "@stylistic/key-spacing": "error",
       "@stylistic/keyword-spacing": "error",
+      "@stylistic/max-statements-per-line": "error",
       "@stylistic/no-floating-decimal": "error",
       "@stylistic/no-mixed-operators": "error",
       "@stylistic/no-multi-spaces": "error",
@@ -65,6 +66,7 @@ module.exports = [
       "@stylistic/object-curly-newline": ["error", { consistent: true }],
       "@stylistic/object-curly-spacing": ["error", "always"],
       "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
+      "@stylistic/one-var-declaration-per-line": "error",
       "@stylistic/operator-linebreak": ["error", "after"],
       "@stylistic/padded-blocks": ["error", "never"],
       "@stylistic/quote-props": ["error", "consistent-as-needed", { keywords: true, numbers: true }],
@@ -92,6 +94,7 @@ module.exports = [
       "no-caller": "error",
       "no-console": "warn",
       "no-div-regex": "error",
+      "no-else-return": ["error", { allowElseIf: false }],
       "no-eq-null": "error",
       "no-eval": "error",
       "no-extend-native": "error",
@@ -133,6 +136,8 @@ module.exports = [
       "no-useless-return": "error",
       "no-void": "error",
       "no-warning-comments": "warn",
+      "operator-assignment": "error",
+      "prefer-object-spread": "error",
       "radix": ["error", "always"],
       "yoda": "error"
     }