diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 86a0a0789..2e13f6967 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -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"); diff --git a/app/assets/javascripts/index/contextmenu.js b/app/assets/javascripts/index/contextmenu.js index fea7e7314..d7e6b427d 100644 --- a/app/assets/javascripts/index/contextmenu.js +++ b/app/assets/javascripts/index/contextmenu.js @@ -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() { diff --git a/app/assets/javascripts/index/layers/data.js b/app/assets/javascripts/index/layers/data.js index dc522af41..e6a7cc666 100644 --- a/app/assets/javascripts/index/layers/data.js +++ b/app/assets/javascripts/index/layers/data.js @@ -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(); diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 5c8ee8876..54d5e080f 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -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"]) { - return tags["addr:housenumber"] + " " + tags["addr:street"]; - } else { - return "#" + feature.id; + 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"]; + } + 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); diff --git a/app/assets/javascripts/leaflet.locate.js b/app/assets/javascripts/leaflet.locate.js index d43a5e458..d19929208 100644 --- a/app/assets/javascripts/leaflet.locate.js +++ b/app/assets/javascripts/leaflet.locate.js @@ -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]); diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index 030c51a08..062d537ff 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -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; diff --git a/config/eslint.js b/config/eslint.js index 1bf65695b..2dcd0d5a1 100644 --- a/config/eslint.js +++ b/config/eslint.js @@ -43,6 +43,7 @@ module.exports = [ reportUnusedDisableDirectives: "off" }, rules: { + /* eslint sort-keys: ["warn"] */ "@stylistic/array-bracket-newline": ["error", "consistent"], "@stylistic/array-bracket-spacing": "error", "@stylistic/block-spacing": "error", @@ -55,23 +56,25 @@ module.exports = [ "@stylistic/eol-last": "error", "@stylistic/func-call-spacing": "error", "@stylistic/indent": ["error", 2, { - SwitchCase: 1, - VariableDeclarator: "first", + CallExpression: { arguments: "first" }, FunctionDeclaration: { parameters: "first" }, FunctionExpression: { parameters: "first" }, - CallExpression: { arguments: "first" } + SwitchCase: 1, + VariableDeclarator: "first" }], "@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-multiple-empty-lines": "error", "@stylistic/no-multi-spaces": "error", + "@stylistic/no-multiple-empty-lines": "error", "@stylistic/no-trailing-spaces": "error", "@stylistic/no-whitespace-before-property": "error", "@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 }], @@ -99,6 +102,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", @@ -109,8 +113,8 @@ module.exports = [ "no-implied-eval": "error", "no-invalid-this": "error", "no-iterator": "error", - "no-labels": "error", "no-label-var": "error", + "no-labels": "error", "no-lone-blocks": "error", "no-lonely-if": "error", "no-loop-func": "error", @@ -134,12 +138,14 @@ module.exports = [ "no-unneeded-ternary": "error", "no-unused-expressions": "off", "no-unused-vars": ["error", { caughtErrors: "none" }], + "no-use-before-define": ["error", { functions: false }], "no-useless-call": "error", "no-useless-concat": "error", "no-useless-return": "error", - "no-use-before-define": ["error", { functions: false }], "no-void": "error", "no-warning-comments": "warn", + "operator-assignment": "error", + "prefer-object-spread": "error", "radix": ["error", "always"], "yoda": "error" }