[gnome-maps/wip/mattiasb/eslint-2.0-2: 5/7] Lint: Fix leaking vars in case stmts



commit 775d1d2f3390bb4f5f067735791e6745d74e6cfa
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Wed Feb 17 06:42:04 2016 +0100

    Lint: Fix leaking vars in case stmts
    
    The ESLint recommended settings disallows declaring new variables with
    let and const in case-statements. This is because a case statement
    doesn't produce a new scope, which might be confusing and be a source
    of bugs.
    
    When there is need to use variables inside a switch-statement it is just as easy to declare it outside or 
wrap the case-clause inside {}'s.

 src/mainWindow.js   |    4 ++--
 src/placeBubble.js  |    5 ++---
 src/translations.js |    6 ++++--
 3 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index afb7297..84ae794 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -364,11 +364,11 @@ const MainWindow = new Lang.Class({
             Application.notificationManager.showMessage(message);
             break;
 
-        case Geoclue.State.OFF:
+        case Geoclue.State.OFF: {
             let notification = this._getLocationServiceNotification();
             Application.notificationManager.showNotification(notification);
             break;
-
+        }
         default:
             this._mapView.gotoUserLocation(true);
             break;
diff --git a/src/placeBubble.js b/src/placeBubble.js
index be364e9..197fa75 100644
--- a/src/placeBubble.js
+++ b/src/placeBubble.js
@@ -265,9 +265,8 @@ const PlaceBubble = new Lang.Class({
 
             switch (response) {
             case OSMEditDialog.Response.UPLOADED:
-                // update place
-                let object = osmEdit.object;
-                OSMUtils.updatePlaceFromOSMObject(this._place, object);
+                OSMUtils.updatePlaceFromOSMObject(this._place,
+                                                  osmEdit.object);
                 // refresh place view
                 this._clearView();
                 this._populate(this._place);
diff --git a/src/translations.js b/src/translations.js
index 3b78e91..87b5adb 100644
--- a/src/translations.js
+++ b/src/translations.js
@@ -188,7 +188,7 @@ function _translateOpeningHoursDayInterval(string) {
     switch (splitString.length) {
         case 1:
             return _translateOpeningHoursDay(splitString[0].trim());
-        case 2:
+        case 2: {
             let from = splitString[0].trim();
             let to = splitString[1].trim();
 
@@ -198,6 +198,7 @@ function _translateOpeningHoursDayInterval(string) {
             return C_("day range", "%s-%s").format(
                 _translateOpeningHoursDay(from),
                 _translateOpeningHoursDay(to));
+        }
         default:
             // unknown format, just return the input
             return string;
@@ -236,7 +237,7 @@ function _translateOpeningHoursTimeIntervalList(string) {
     switch (splitString.length) {
         case 1:
             return _translateOpeningHoursTimeInterval(splitString[0].trim());
-        case 2:
+        case 2: {
             let interval1 = splitString[0].trim();
             let interval2 = splitString[1].trim();
 
@@ -251,6 +252,7 @@ function _translateOpeningHoursTimeIntervalList(string) {
             return C_("time interval list", "%s, %s").format(
                 _translateOpeningHoursTimeInterval(interval1),
                 _translateOpeningHoursTimeInterval(interval2));
+        }
         default:
             // for other number of components, just return the input
             return string;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]