[gnome-maps/wip/mattiasb/eslint-2.0-2: 6/7] Lint: Disallow custom indentation



commit 0c7390244a852b8159b370a98355285f5ff8a060
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Wed Feb 17 07:36:56 2016 +0100

    Lint: Disallow custom indentation
    
    Make ESLint throw an error for indentation other than:
     - 4 spaces per indentation level
     - just spaces (no tabs)
     - no indentation for case-statements in switches
    
    ...and fix all those errors.

 .eslintrc.yaml           |    3 +
 src/facebookBackend.js   |   16 ++---
 src/foursquareBackend.js |   16 ++---
 src/mapView.js           |    2 +-
 src/osmConnection.js     |   18 ++--
 src/osmEditDialog.js     |    2 +-
 src/place.js             |   49 +++++++------
 src/placePopover.js      |    8 +-
 src/translations.js      |  190 +++++++++++++++++++++++-----------------------
 src/utils.js             |    8 +-
 10 files changed, 156 insertions(+), 156 deletions(-)
---
diff --git a/.eslintrc.yaml b/.eslintrc.yaml
index 8319209..5890a13 100644
--- a/.eslintrc.yaml
+++ b/.eslintrc.yaml
@@ -29,3 +29,6 @@ globals:
 rules:
     no-unused-vars:
         - 0
+    indent:
+        - 2
+        - 4
diff --git a/src/facebookBackend.js b/src/facebookBackend.js
index 785c78c..b05c31e 100644
--- a/src/facebookBackend.js
+++ b/src/facebookBackend.js
@@ -76,11 +76,9 @@ const FacebookBackend = new Lang.Class({
         this.callAsync(authorizer,
                        'POST',
                        'me/feed',
-                       {
-                           'message': checkIn.message,
-                           'place': checkIn.place.id,
-                           'privacy_value': checkIn.privacy
-                       },
+                       { 'message': checkIn.message,
+                         'place': checkIn.place.id,
+                         'privacy_value': checkIn.privacy },
                        callback,
                        cancellable);
     },
@@ -89,11 +87,9 @@ const FacebookBackend = new Lang.Class({
         this.callAsync(authorizer,
                        'GET',
                        'search',
-                       {
-                           'type': 'place',
-                           'center': latitude + ',' + longitude,
-                           'distance': distance
-                       },
+                       { 'type': 'place',
+                         'center': latitude + ',' + longitude,
+                         'distance': distance },
                        callback,
                        cancellable);
     },
diff --git a/src/foursquareBackend.js b/src/foursquareBackend.js
index 0a69c80..96ecff3 100644
--- a/src/foursquareBackend.js
+++ b/src/foursquareBackend.js
@@ -79,11 +79,9 @@ const FoursquareBackend = new Lang.Class({
         this.callAsync(authorizer,
                        'POST',
                        'checkins/add',
-                       {
-                           'shout': checkIn.message,
-                           'venueId': checkIn.place.id,
-                           'broadcast': broadcast
-                       },
+                       { 'shout': checkIn.message,
+                         'venueId': checkIn.place.id,
+                         'broadcast': broadcast },
                        callback,
                        cancellable);
     },
@@ -92,11 +90,9 @@ const FoursquareBackend = new Lang.Class({
         this.callAsync(authorizer,
                        'GET',
                        'venues/search',
-                       {
-                           'll': latitude + ',' + longitude,
-                           'radius': distance,
-                           'intent': 'checkin'
-                       },
+                       { 'll': latitude + ',' + longitude,
+                         'radius': distance,
+                         'intent': 'checkin' },
                        callback,
                        cancellable);
     },
diff --git a/src/mapView.js b/src/mapView.js
index 2bf8f04..6f8e6a5 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -181,7 +181,7 @@ const MapView = new Lang.Class({
         }).bind(this));
 
         query.connect('notify', (function() {
-                this.routeVisible = query.isValid();
+            this.routeVisible = query.isValid();
         }).bind(this));
     },
 
diff --git a/src/osmConnection.js b/src/osmConnection.js
index 0303ac4..66b105a 100644
--- a/src/osmConnection.js
+++ b/src/osmConnection.js
@@ -128,8 +128,8 @@ const OSMConnection = new Lang.Class({
         call.set_function('/changeset/create');
 
         call.invoke_async(null, (function(call, res, userdata) {
-                    this._onChangesetOpened(call, callback);
-                                }).bind(this));
+            this._onChangesetOpened(call, callback);
+        }).bind(this));
     },
 
     _onChangesetOpened: function(call, callback) {
@@ -152,8 +152,8 @@ const OSMConnection = new Lang.Class({
         call.set_function(this._getCreateOrUpdateFunction(object, type));
 
         call.invoke_async(null, (function(call, res, userdata) {
-                    this._onObjectUploaded(call, callback);
-                                }).bind(this));
+            this._onObjectUploaded(call, callback);
+        }).bind(this));
     },
 
     _onObjectUploaded: function(call, callback) {
@@ -175,8 +175,8 @@ const OSMConnection = new Lang.Class({
         call.set_function(this._getDeleteFunction(object, type));
 
         call.invoke_async(null, (function(call, res, userdata) {
-                    this._onObjectDeleted(call, callback);
-                                }).bind(this));
+            this._onObjectDeleted(call, callback);
+        }).bind(this));
     },
 
     _onObjectDeleted: function(call, callback) {
@@ -194,8 +194,8 @@ const OSMConnection = new Lang.Class({
         call.set_function(this._getCloseChangesetFunction(changesetId));
 
         call.invoke_async(null, (function(call, res, userdata) {
-                    this._onChangesetClosed(call, callback);
-                                }).bind(this));
+            this._onChangesetClosed(call, callback);
+        }).bind(this));
     },
 
     _onChangesetClosed: function(call, callback) {
@@ -363,7 +363,7 @@ const OSMConnection = new Lang.Class({
                               this._oauthProxy.token + ":" +
                               this._oauthProxy.token_secret, null,
                               function(source, result, userData) {
-                                this._onPasswordStored(result, callback);
+                                  this._onPasswordStored(result, callback);
                               }.bind(this));
     },
 
diff --git a/src/osmEditDialog.js b/src/osmEditDialog.js
index 31cf210..3308b32 100644
--- a/src/osmEditDialog.js
+++ b/src/osmEditDialog.js
@@ -593,7 +593,7 @@ const OSMEditDialog = new Lang.Class({
         combobox.active_id = value;
         combobox.hexpand = true;
         combobox.connect('changed', (function() {
-        this._osmObject.set_tag(fieldSpec.tag, combobox.active_id);
+            this._osmObject.set_tag(fieldSpec.tag, combobox.active_id);
             this._nextButton.sensitive = true;
         }).bind(this, fieldSpec.tag, combobox));
 
diff --git a/src/place.js b/src/place.js
index ad22b7d..18dd065 100644
--- a/src/place.js
+++ b/src/place.js
@@ -171,32 +171,37 @@ const Place = new Lang.Class({
 
     _translateWheelchair: function(string) {
         switch(string) {
+        case 'yes':
             /* Translators:
              * This means wheelchairs have full unrestricted access.
              */
-            case 'yes': return _("yes");
+            return _("yes");
 
+        case 'limited':
             /* Translators:
              * This means wheelchairs have partial access (e.g some areas
              * can be accessed and others not, areas requiring assistance
              * by someone pushing up a steep gradient).
              */
-            case 'limited': return _("limited");
+            return _("limited");
 
+        case 'no':
             /* Translators:
              * This means wheelchairs have no unrestricted access
              * (e.g. stair only access).
              */
-            case 'no': return _("no");
+            return _("no");
 
+        case 'designated':
             /* Translators:
              * This means that the way or area is designated or purpose built
              * for wheelchairs (e.g. elevators designed for wheelchair access
              * only). This is rarely used.
              */
-            case 'designated': return _("designated");
+            return _("designated");
 
-            default: return null;
+        default:
+            return null;
         }
     },
 
@@ -270,23 +275,23 @@ Place.fromJSON = function(obj) {
         let prop = obj[key];
 
         switch(key) {
-            case 'id':
-                props.osm_id = prop;
-                break;
-
-            case 'location':
-                props.location = new Location.Location(prop);
-                break;
-
-            case 'bounding_box':
-                if (prop)
-                    props.bounding_box = new Geocode.BoundingBox(prop);
-                break;
-
-            default:
-                if (prop !== null && prop !== undefined)
-                    props[key] = prop;
-                break;
+        case 'id':
+            props.osm_id = prop;
+            break;
+
+        case 'location':
+            props.location = new Location.Location(prop);
+            break;
+
+        case 'bounding_box':
+            if (prop)
+                props.bounding_box = new Geocode.BoundingBox(prop);
+            break;
+
+        default:
+            if (prop !== null && prop !== undefined)
+                props[key] = prop;
+            break;
         }
     }
     return new Place(props);
diff --git a/src/placePopover.js b/src/placePopover.js
index fbe94fb..e65fb11 100644
--- a/src/placePopover.js
+++ b/src/placePopover.js
@@ -67,10 +67,10 @@ const PlacePopover = new Lang.Class({
             this._mode = Mode.ACTIVATED;
         }).bind(this));
 
-         this._list.connect('row-activated', (function(list, row) {
-             if (row)
-                 this.emit('selected', row.place);
-         }).bind(this));
+        this._list.connect('row-activated', (function(list, row) {
+            if (row)
+                this.emit('selected', row.place);
+        }).bind(this));
 
         // Make sure we clear all selected rows when the search string change
         this._entry.connect('changed',
diff --git a/src/translations.js b/src/translations.js
index 87b5adb..020023e 100644
--- a/src/translations.js
+++ b/src/translations.js
@@ -63,35 +63,35 @@ function translateOpeningHours(string) {
         let part1, part2, part3;
 
         switch (splitParts.length) {
-            case 1:
-                return _translateOpeningHoursPart(splitParts[0].trim());
-            case 2:
-                part1 = _translateOpeningHoursPart(splitParts[0].trim());
-                part2 = _translateOpeningHoursPart(splitParts[1].trim());
-
-                /* Translators:
-                 * This is a format string with two separate time ranges
-                 * such as "Mo-Fr 10:00-19:00 Sa 12:00-16:00"
-                 * The space between the format place holders could be
-                 * substituted with the appropriate separator.
-                 */
-                return C_("time range list", "%s %s").format(part1, part2);
-            case 3:
-                part1 = _translateOpeningHoursPart(splitParts[0].trim());
-                part2 = _translateOpeningHoursPart(splitParts[1].trim());
-                part3 = _translateOpeningHoursPart(splitParts[2].trim());
-
-                /* Translators:
-                 * This is a format string with three separate time ranges
-                 * such as "Mo-Fr 10:00-19:00 Sa 10:00-17:00 Su 12:00-16:00"
-                 * The space between the format place holders could be
-                 * substituted with the appropriate separator.
-                 */
+        case 1:
+            return _translateOpeningHoursPart(splitParts[0].trim());
+        case 2:
+            part1 = _translateOpeningHoursPart(splitParts[0].trim());
+            part2 = _translateOpeningHoursPart(splitParts[1].trim());
+
+            /* Translators:
+             * This is a format string with two separate time ranges
+             * such as "Mo-Fr 10:00-19:00 Sa 12:00-16:00"
+             * The space between the format place holders could be
+             * substituted with the appropriate separator.
+             */
+            return C_("time range list", "%s %s").format(part1, part2);
+        case 3:
+            part1 = _translateOpeningHoursPart(splitParts[0].trim());
+            part2 = _translateOpeningHoursPart(splitParts[1].trim());
+            part3 = _translateOpeningHoursPart(splitParts[2].trim());
+
+            /* Translators:
+             * This is a format string with three separate time ranges
+             * such as "Mo-Fr 10:00-19:00 Sa 10:00-17:00 Su 12:00-16:00"
+             * The space between the format place holders could be
+             * substituted with the appropriate separator.
+             */
             return C_("time range list", "%s %s %s").format(part1,
                                                             part2,
                                                             part3);
-            default:
-                return string;
+        default:
+            return string;
         }
     }
 
@@ -136,39 +136,39 @@ function _translateOpeningHoursDayIntervalList(string) {
     let interval1, interval2, interval3;
 
     switch (splitParts.length) {
-        case 1:
-            return _translateOpeningHoursDayInterval(splitParts[0].trim());
-        case 2:
-            interval1 = _translateOpeningHoursDayInterval(splitParts[0].trim());
-            interval2 = _translateOpeningHoursDayInterval(splitParts[1].trim());
-            /* Translators:
-             * This represents a format string consisting of two day interval
-             * specifications.
-             * For example:
-             * Mo-Fr,Sa
-             * where the "Mo-Fr" and "Sa" parts are replaced by the %s
-             * place holder.
-             * The separator (,) could be replaced with a translated variant or
-             * a phrase if appropriate. */
-            return C_("day interval list", "%s,%s").format(interval1, interval2);
-        case 3:
-            interval1 = _translateOpeningHoursDayInterval(splitParts[0].trim());
-            interval2 = _translateOpeningHoursDayInterval(splitParts[1].trim());
-            interval3 = _translateOpeningHoursDayInterval(splitParts[2].trim());
-            /* Translators:
-             * This represents a format string consisting of three day interval
-             * specifications.
-             * For example:
-             * Mo-We,Fr,Su
-             * where the "Mo-We", "Fr", and "Su" parts are replaced by the
-             * %s place holder.
-             * The separator (,) could be replaced with a translated variant or
-             * a phrase if appropriate. */
-            return C_("day interval list", "%s,%s,%s").
-                format(interval1, interval2, interval3);
-        default:
-            // for other formats, just return the raw string
-            return string;
+    case 1:
+        return _translateOpeningHoursDayInterval(splitParts[0].trim());
+    case 2:
+        interval1 = _translateOpeningHoursDayInterval(splitParts[0].trim());
+        interval2 = _translateOpeningHoursDayInterval(splitParts[1].trim());
+        /* Translators:
+         * This represents a format string consisting of two day interval
+         * specifications.
+         * For example:
+         * Mo-Fr,Sa
+         * where the "Mo-Fr" and "Sa" parts are replaced by the %s
+         * place holder.
+         * The separator (,) could be replaced with a translated variant or
+         * a phrase if appropriate. */
+        return C_("day interval list", "%s,%s").format(interval1, interval2);
+    case 3:
+        interval1 = _translateOpeningHoursDayInterval(splitParts[0].trim());
+        interval2 = _translateOpeningHoursDayInterval(splitParts[1].trim());
+        interval3 = _translateOpeningHoursDayInterval(splitParts[2].trim());
+        /* Translators:
+         * This represents a format string consisting of three day interval
+         * specifications.
+         * For example:
+         * Mo-We,Fr,Su
+         * where the "Mo-We", "Fr", and "Su" parts are replaced by the
+         * %s place holder.
+         * The separator (,) could be replaced with a translated variant or
+         * a phrase if appropriate. */
+        return C_("day interval list", "%s,%s,%s").
+            format(interval1, interval2, interval3);
+    default:
+        // for other formats, just return the raw string
+        return string;
     }
 }
 
@@ -186,22 +186,22 @@ function _translateOpeningHoursDayInterval(string) {
         return _("every day");
 
     switch (splitString.length) {
-        case 1:
-            return _translateOpeningHoursDay(splitString[0].trim());
-        case 2: {
-            let from = splitString[0].trim();
-            let to = splitString[1].trim();
+    case 1:
+        return _translateOpeningHoursDay(splitString[0].trim());
+    case 2: {
+        let from = splitString[0].trim();
+        let to = splitString[1].trim();
 
-            /* Translators:
-             * This represents a range of days with a starting and ending day.
-             */
-            return C_("day range", "%s-%s").format(
-                _translateOpeningHoursDay(from),
-                _translateOpeningHoursDay(to));
-        }
-        default:
-            // unknown format, just return the input
-            return string;
+        /* Translators:
+         * This represents a range of days with a starting and ending day.
+         */
+        return C_("day range", "%s-%s").format(
+            _translateOpeningHoursDay(from),
+            _translateOpeningHoursDay(to));
+    }
+    default:
+        // unknown format, just return the input
+        return string;
     }
 }
 
@@ -235,27 +235,27 @@ function _translateOpeningHoursTimeIntervalList(string) {
     let splitString = string.split(',');
 
     switch (splitString.length) {
-        case 1:
-            return _translateOpeningHoursTimeInterval(splitString[0].trim());
-        case 2: {
-            let interval1 = splitString[0].trim();
-            let interval2 = splitString[1].trim();
+    case 1:
+        return _translateOpeningHoursTimeInterval(splitString[0].trim());
+    case 2: {
+        let interval1 = splitString[0].trim();
+        let interval2 = splitString[1].trim();
 
-            /* Translators:
-             * This is a list with two time intervals, such as:
-             * 09:00-12:00, 13:00-14:00
-             * The intervals are represented by the %s place holders and
-             * appropriate white space or connected phrase could be modified by
-             * the translation. The order of the arguments can be rearranged
-             * using the %n$s syntax.
-             */
-            return C_("time interval list", "%s, %s").format(
-                _translateOpeningHoursTimeInterval(interval1),
-                _translateOpeningHoursTimeInterval(interval2));
-        }
-        default:
-            // for other number of components, just return the input
-            return string;
+        /* Translators:
+         * This is a list with two time intervals, such as:
+         * 09:00-12:00, 13:00-14:00
+         * The intervals are represented by the %s place holders and
+         * appropriate white space or connected phrase could be modified by
+         * the translation. The order of the arguments can be rearranged
+         * using the %n$s syntax.
+         */
+        return C_("time interval list", "%s, %s").format(
+            _translateOpeningHoursTimeInterval(interval1),
+            _translateOpeningHoursTimeInterval(interval2));
+    }
+    default:
+        // for other number of components, just return the input
+        return string;
     }
 }
 
@@ -300,7 +300,7 @@ function _translateOpeningHoursTime(string) {
 
         // if the parts aren't numbers
         if (h % 1 !== 0 || min % 1 !== 0)
-           return string;
+            return string;
 
         // if the hours or minute components are out of range
         if (h > 24 || h < 0 || min > 59 || min < 0)
diff --git a/src/utils.js b/src/utils.js
index e20e4e1..8143c7b 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -314,10 +314,10 @@ function _load_themed_icon(icon, size, loadCompleteCallback) {
 
 function osmTypeToString(osmType) {
     switch(osmType) {
-        case Geocode.PlaceOsmType.NODE: return 'node';
-        case Geocode.PlaceOsmType.RELATION: return 'relation';
-        case Geocode.PlaceOsmType.WAY: return 'way';
-        default: return 'node';
+    case Geocode.PlaceOsmType.NODE: return 'node';
+    case Geocode.PlaceOsmType.RELATION: return 'relation';
+    case Geocode.PlaceOsmType.WAY: return 'way';
+    default: return 'node';
     }
 }
 


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