Re: JSLint and JavaScript: The Good Parts.





On 13 March 2010 05:38, Dan Winship <danw gnome org> wrote:
On 03/12/2010 07:04 AM, Lex Hider wrote:
> I ran the attached perl script to get around errors reported for: let,
> const, and multiple variable assignment (e.g. [a,b] = callFunc();),
> which appear to be mozilla specific features.

yeah, there's a bug in bugzilla (against gjs) about trying to get jslint
working with the moz extensions

> Would a patch for any of the following be worthwhile?
>
> * missing terminal semi-colons.

yes

Attached patch, mainly for missing semicolons.
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index 865e1f0..6a270ec 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -455,7 +455,7 @@ SwitcherList.prototype = {
     },
 
     addSeparator: function () {
-        let box = new St.Bin({ style_class: 'separator' })
+        let box = new St.Bin({ style_class: 'separator' });
         this._separator = box;
         this._list.add_actor(box);
     },
@@ -572,10 +572,10 @@ SwitcherList.prototype = {
                 childBox.y2 = childHeight;
                 children[i].allocate(childBox, flags);
                 x += this._list.spacing + separatorWidth;
-            } else {
+            } // else {
                 // Something else, eg, AppSwitcher's arrows;
                 // we don't allocate it.
-            }
+            //}
         }
     }
 };
@@ -599,7 +599,7 @@ AppIcon.prototype = {
         this._label = new St.Label({ text: this.app.get_name() });
         this.actor.add(this._label, { x_fill: false });
     }
-}
+};
 
 function AppSwitcher(apps) {
     this._init(apps);
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index fb41bb4..b980460 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -259,9 +259,9 @@ AppSearchResultDisplay.prototype = {
             return;
         let children = this._container.get_children();
         let targetActor = children[this.selectionIndex];
-        this.provider.activateResult(targetActor._delegate.app.get_id())
+        this.provider.activateResult(targetActor._delegate.app.get_id());
     }
-}
+};
 
 function BaseAppSearchProvider() {
     this._init();
@@ -330,7 +330,7 @@ AppSearchProvider.prototype = {
     expandSearch: function(terms) {
         log("TODO expand search");
     }
-}
+};
 
 function PrefsSearchProvider() {
     this._init();
@@ -356,7 +356,7 @@ PrefsSearchProvider.prototype = {
         controlCenter.launch();
         Main.overview.hide();
     }
-}
+};
 
 function AppIcon(app) {
     this._init(app);
@@ -382,7 +382,7 @@ AppIcon.prototype = {
         this._name.clutter_text.line_alignment = Pango.Alignment.CENTER;
         box.add_actor(this._name);
     }
-}
+};
 
 function AppWellIcon(app) {
     this._init(app);
@@ -588,7 +588,7 @@ AppWellIcon.prototype = {
     getDragActorSource: function() {
         return this._icon.icon;
     }
-}
+};
 Signals.addSignalMethods(AppWellIcon.prototype);
 
 function AppIconMenu(source) {
@@ -1013,7 +1013,7 @@ WellGrid.prototype = {
     addItem: function(actor) {
         this._grid.add_actor(actor);
     }
-}
+};
 
 function AppWell() {
     this._init();
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 68ec6a9..4981d34 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -16,7 +16,7 @@ function _sameDay(dateA, dateB) {
 
 function Calendar() {
     this._init();
-};
+}
 
 Calendar.prototype = {
     _init: function() {
@@ -26,7 +26,7 @@ Calendar.prototype = {
         this._weekStart = NaN;
         let weekStartString = Gettext_gtk20.gettext("calendar:week_start:0");
         if (weekStartString.indexOf("calendar:week_start:") == 0) {
-            this._weekStart = parseInt(weekStartString.substring(20));
+            this._weekStart = parseInt(weekStartString.substring(20), 10);
         }
 
         if (isNaN(this._weekStart) || this._weekStart < 0 || this._weekStart > 6) {
diff --git a/js/ui/dash.js b/js/ui/dash.js
index d0e32c6..a5486ae 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -112,7 +112,7 @@ Pane.prototype = {
         else
             this.open();
     }
-}
+};
 Signals.addSignalMethods(Pane.prototype);
 
 function ResultArea(displayType, flags) {
@@ -131,7 +131,7 @@ ResultArea.prototype = {
         this.resultsContainer.append(this.display.actor, Big.BoxPackFlags.EXPAND);
         this.display.load();
     }
-}
+};
 
 // Utility function shared between ResultPane and the DocDisplay in the main dash.
 // Connects to the detail signal of the display, and on-demand creates a new
@@ -187,7 +187,7 @@ ResultPane.prototype = {
         }));
         return resultArea.display;
     }
-}
+};
 
 function SearchEntry() {
     this._init();
@@ -295,13 +295,14 @@ SearchEntry.prototype = {
 
                 // If we have an active search, Escape cancels it - if we
                 // haven't, the key is ignored
-                if (sym == Clutter.Escape)
+                if (sym == Clutter.Escape) {
                     if (this._isActivated()) {
                         this.reset();
                         return true;
                     } else {
                         return false;
                     }
+                }
 
                  // Ignore non-printable keys
                  if (!Clutter.keysym_to_unicode(sym))
@@ -390,7 +391,7 @@ SearchResult.prototype = {
         else
             this.provider.activateResult(this.metaInfo.id);
     }
-}
+};
 
 function OverflowSearchResults(provider) {
     this._init(provider);
@@ -440,7 +441,7 @@ OverflowSearchResults.prototype = {
         let targetActor = children[this.selectionIndex];
         targetActor._delegate.activate();
     }
-}
+};
 
 function SearchResults(searchSystem) {
     this._init(searchSystem);
@@ -607,7 +608,7 @@ SearchResults.prototype = {
         resultDisplay.activateSelected();
         Main.overview.hide();
     }
-}
+};
 
 function MoreLink() {
     this._init();
@@ -641,7 +642,7 @@ MoreLink.prototype = {
                 this._expander.style_class = 'more-link-expander open';
         }));
     }
-}
+};
 
 Signals.addSignalMethods(MoreLink.prototype);
 
@@ -655,7 +656,7 @@ BackLink.prototype = {
                                       reactive: true });
         this.actor.set_child(new St.Bin({ style_class: "section-header-back-image" }));
     }
-}
+};
 
 function SectionHeader(title, suppressBrowse) {
     this._init(title, suppressBrowse);
@@ -726,7 +727,7 @@ SectionHeader.prototype = {
             this.countText.text = countText;
         }
     }
-}
+};
 
 Signals.addSignalMethods(SectionHeader.prototype);
 
@@ -750,7 +751,7 @@ SearchSectionHeader.prototype = {
 
         this.actor.connect('clicked', onClick);
     }
-}
+};
 
 function Section(titleString, suppressBrowse) {
     this._init(titleString, suppressBrowse);
@@ -766,7 +767,7 @@ Section.prototype = {
                                            vertical: true });
         this.actor.add(this.content);
     }
-}
+};
 
 function Dash() {
     this._init();
diff --git a/js/ui/genericDisplay.js b/js/ui/genericDisplay.js
index b220740..fe8d3fd 100644
--- a/js/ui/genericDisplay.js
+++ b/js/ui/genericDisplay.js
@@ -240,7 +240,7 @@ Signals.addSignalMethods(GenericDisplayItem.prototype);
 
 const GenericDisplayFlags = {
     DISABLE_VSCROLLING: 1 << 0
-}
+};
 
 /* This is a virtual class that represents a display containing a collection of items
  * that can be filtered with a search string.
@@ -697,8 +697,9 @@ GenericDisplay.prototype = {
         }
 
         this._selectedIndex = index;
-        if (index < 0)
-            return
+        if (index < 0) {
+            return;
+        }
 
         // Mark the new item as selected and create its details pane
         let item = this._findDisplayedByIndex(index);
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 08d191b..2836c0c 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -136,7 +136,7 @@ Notebook.prototype = {
         let vAdjust = tabData.scrollView.vscroll.adjustment;
         vAdjust.value = vAdjust.upper - vAdjust.page_size;
     }
-}
+};
 Signals.addSignalMethods(Notebook.prototype);
 
 function Result(command, o, index) {
@@ -164,7 +164,7 @@ Result.prototype = {
         padBin.add_actor(line);
         this.actor.append(padBin, Big.BoxPackFlags.NONE);
     }
-}
+};
 
 function ActorHierarchy() {
     this._init();
@@ -215,7 +215,7 @@ ActorHierarchy.prototype = {
         let link = children[idx];
         this.emit('selection', actor);
     }
-}
+};
 Signals.addSignalMethods(ActorHierarchy.prototype);
 
 function PropertyInspector() {
@@ -249,7 +249,7 @@ PropertyInspector.prototype = {
             this.actor.add_actor(propDisplay);
         }
     }
-}
+};
 
 function Inspector() {
     this._init();
@@ -311,7 +311,7 @@ Inspector.prototype = {
         }));
         Clutter.grab_pointer(eventHandler);
     }
-}
+};
 
 Signals.addSignalMethods(Inspector.prototype);
 
@@ -329,13 +329,13 @@ ErrorLog.prototype = {
     },
 
     _formatTime: function(d){
-        function pad(n) { return n < 10 ? '0' + n : n };
-        return d.getUTCFullYear()+'-'
-            + pad(d.getUTCMonth()+1)+'-'
-            + pad(d.getUTCDate())+'T'
-            + pad(d.getUTCHours())+':'
-            + pad(d.getUTCMinutes())+':'
-            + pad(d.getUTCSeconds())+'Z'
+        function pad(n) { return n < 10 ? '0' + n : n; }
+        return d.getUTCFullYear()+'-'   +
+            pad(d.getUTCMonth()+1)+'-'  +
+            pad(d.getUTCDate())+'T'     +
+            pad(d.getUTCHours())+':'    +
+            pad(d.getUTCMinutes())+':'  +
+            pad(d.getUTCSeconds())+'Z';
     },
 
     _renderText: function() {
@@ -349,7 +349,7 @@ ErrorLog.prototype = {
         }
         this.text.text = text;
     }
-}
+};
 
 function Extensions() {
     this._init();
@@ -596,9 +596,9 @@ LookingGlass.prototype = {
         let fontDesc = Pango.Font.description_from_string(fontName);
         // We ignore everything but size and style; you'd be crazy to set your system-wide
         // monospace font to be bold/oblique/etc. Could easily be added here.
-        this.actor.style =
-            'font-size: ' + fontDesc.get_size() / 1024. + (fontDesc.get_size_is_absolute() ? 'px' : 'pt') + ';'
-            + 'font-family: "' + fontDesc.get_family() + '";';
+        this.actor.style = 'font-size: ' + fontDesc.get_size() / 1024. +
+                (fontDesc.get_size_is_absolute() ? 'px' : 'pt') + ';' +
+                'font-family: "' + fontDesc.get_family() + '";';
     },
 
     _readHistory: function () {
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 63d0d5d..63c0fc7 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -490,9 +490,10 @@ MessageTray.prototype = {
     },
 
     removeSourceByApp: function(app) {
-        for (let source in this._sources)
+        for (let source in this._sources) {
             if (this._sources[source].app == app)
                 this.removeSource(this._sources[source]);
+        }
     },
 
     removeNotification: function(notification) {
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index c3cb270..367152e 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -21,17 +21,17 @@ const BusIface = {
     methods: [{ name: 'GetConnectionUnixProcessID',
                 inSignature: 's',
                 outSignature: 'i' }]
-}
+};
 
 const Bus = function () {
     this._init();
-}
+};
 
 Bus.prototype = {
      _init: function() {
          DBus.session.proxifyObject(this, 'org.freedesktop.DBus', '/org/freedesktop/DBus');
      }
-}
+};
 
 DBus.proxifyPrototype(Bus.prototype, BusIface);
 
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 92847b1..c8a8a36 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -323,12 +323,12 @@ Overview.prototype = {
         let workspaceColumnsUsed = wideScreen ? COLUMNS_FOR_WORKSPACES_WIDE_SCREEN : COLUMNS_FOR_WORKSPACES_REGULAR_SCREEN;
         let workspaceRowsUsed = wideScreen ? ROWS_FOR_WORKSPACES_WIDE_SCREEN : ROWS_FOR_WORKSPACES_REGULAR_SCREEN;
 
-        this._workspacesWidth = displayGridColumnWidth * workspaceColumnsUsed
-                                  - WORKSPACE_GRID_PADDING * 2;
+        this._workspacesWidth = displayGridColumnWidth * workspaceColumnsUsed -
+                                  WORKSPACE_GRID_PADDING * 2;
         // We scale the vertical padding by (primary.height / primary.width)
         // so that the workspace preserves its aspect ratio.
-        this._workspacesHeight = Math.floor(displayGridRowHeight * workspaceRowsUsed
-                                   - WORKSPACE_GRID_PADDING * (primary.height / primary.width) * 2);
+        this._workspacesHeight = Math.floor(displayGridRowHeight * workspaceRowsUsed -
+                                   WORKSPACE_GRID_PADDING * (primary.height / primary.width) * 2);
 
         if (rtl) {
             this._workspacesX = WORKSPACE_GRID_PADDING;
@@ -398,8 +398,8 @@ Overview.prototype = {
                         return false;
                     if (event.type() == Clutter.EventType.BUTTON_PRESS)
                         this._paneReady = true;
-                    if (event.type() == Clutter.EventType.BUTTON_RELEASE
-                        && this._paneReady)
+                    if (event.type() == Clutter.EventType.BUTTON_RELEASE &&
+                                                                this._paneReady)
                         this._activeDisplayPane.close();
                     return true;
                 }));
@@ -423,8 +423,8 @@ Overview.prototype = {
     // dragged over the Overview, i.e. as soon as it starts being dragged.
     // This allows the user to place the item on any workspace.
     handleDragOver : function(source, actor, x, y, time) {
-        if (source instanceof GenericDisplay.GenericDisplayItem
-            || source instanceof AppDisplay.AppIcon) {
+        if (source instanceof GenericDisplay.GenericDisplayItem ||
+            source instanceof AppDisplay.AppIcon) {
             if (this._activeDisplayPane != null)
                 this._activeDisplayPane.close();
             return true;
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 6cce4c6..1715050 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -39,7 +39,7 @@ const TRAY_BORDER_WIDTH = 0;
 
 const HOT_CORNER_ACTIVATION_TIMEOUT = 0.5;
 
-const STANDARD_TRAY_ICON_ORDER = ['keyboard', 'volume', 'bluetooth', 'network', 'battery']
+const STANDARD_TRAY_ICON_ORDER = ['keyboard', 'volume', 'bluetooth', 'network', 'battery'];
 const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
     'bluetooth-applet': 'bluetooth',
     'gnome-volume-control-applet': 'volume',
@@ -130,7 +130,7 @@ TextShadower.prototype = {
             child.allocate(childBox, flags);
         }
     }
-}
+};
 
 /**
  * AppPanelMenu:
@@ -256,10 +256,10 @@ AppPanelMenu.prototype = {
 
         // If the currently focused app hasn't changed and the current
         // startup sequence hasn't changed, we have nothing to do
-        if (focusedApp == this._focusedApp
-            && ((lastSequence == null && this._activeSequence == null)
-                || (lastSequence != null && this._activeSequence != null
-                    && lastSequence.get_id() == this._activeSequence.get_id())))
+        if (focusedApp == this._focusedApp &&
+            ((lastSequence == null && this._activeSequence == null) ||
+                (lastSequence != null && this._activeSequence != null &&
+                    lastSequence.get_id() == this._activeSequence.get_id())))
             return;
 
         this._focusedApp = focusedApp;
@@ -301,7 +301,7 @@ AppPanelMenu.prototype = {
 
         this.emit('changed');
     }
-}
+};
 
 Signals.addSignalMethods(AppPanelMenu.prototype);
 
diff --git a/js/ui/placeDisplay.js b/js/ui/placeDisplay.js
index da7fe03..9e3ed87 100644
--- a/js/ui/placeDisplay.js
+++ b/js/ui/placeDisplay.js
@@ -59,7 +59,7 @@ PlaceInfo.prototype = {
     isRemovable: function() {
         return false;
     }
-}
+};
 
 function PlaceDeviceInfo(mount) {
     this._init(mount);
@@ -99,7 +99,7 @@ PlaceDeviceInfo.prototype = {
     _removeFinish: function(o, res, data) {
         this._mount.unmount_finish(res);
     }
-}
+};
 
 
 function PlacesManager() {
@@ -581,4 +581,4 @@ PlaceSearchProvider.prototype = {
         let places = previousResults.map(function (id) { return Main.placesManager.lookupPlaceById(id); });
         return this._searchPlaces(places, terms);
     }
-}
+};
diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js
index e1c26eb..7808780 100644
--- a/js/ui/runDialog.js
+++ b/js/ui/runDialog.js
@@ -168,7 +168,7 @@ CommandCompleter.prototype = {
 
 function RunDialog() {
     this._init();
-};
+}
 
 RunDialog.prototype = {
     _init : function() {
diff --git a/js/ui/search.js b/js/ui/search.js
index c25e02d..bacf336 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -207,7 +207,7 @@ SearchProvider.prototype = {
     expandSearch: function(terms) {
         throw new Error("not implemented");
     }
-}
+};
 Signals.addSignalMethods(SearchProvider.prototype);
 
 function SearchSystem() {
@@ -275,5 +275,5 @@ SearchSystem.prototype = {
 
         return results;
     }
-}
+};
 Signals.addSignalMethods(SearchSystem.prototype);
diff --git a/js/ui/widget.js b/js/ui/widget.js
index d6fe8fe..1cb740f 100644
--- a/js/ui/widget.js
+++ b/js/ui/widget.js
@@ -302,7 +302,7 @@ AppsWidgetInfo.prototype = {
     launch : function() {
         this._info.launch();
     }
-}
+};
 
 function AppsWidget() {
     this._init.apply(this, arguments);
diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js
index 8e0228b..4172570 100644
--- a/js/ui/windowAttentionHandler.js
+++ b/js/ui/windowAttentionHandler.js
@@ -71,18 +71,20 @@ WindowAttentionHandler.prototype = {
             source.connect('clicked', Lang.bind(this, function() { source.destroy(); }));
         }
 
-        let notification = new MessageTray.Notification(window.get_startup_id(), source, this._getTitle(app, window), this._getBanner(app, window), true);
+        let notification = new MessageTray.Notification(window.get_startup_id(), source,
+                        this._getTitle(app, window), this._getBanner(app, window), true);
         source.notify(notification);
 
-        window.connect('notify::title', Lang.bind(this, function(win) {
-                                                            notification.update(this._getTitle(app, win), this._getBanner(app, win), false);
-                                                        }));
-        window.connect('notify::demands-attention', Lang.bind(this, function() { source.destroy() }));
-        window.connect('focus', Lang.bind(this, function() { source.destroy() }));
-        window.connect('unmanaged', Lang.bind(this, function() { source.destroy() }));
+        window.connect('notify::title',
+                Lang.bind(this, function(win) {
+                    notification.update(this._getTitle(app, win), this._getBanner(app, win), false);
+                }));
+        window.connect('notify::demands-attention', Lang.bind(this, function() { source.destroy(); }));
+        window.connect('focus', Lang.bind(this, function() { source.destroy(); }));
+        window.connect('unmanaged', Lang.bind(this, function() { source.destroy(); }));
 
     }
-}
+};
 
 function Source(sourceId, app, window) {
     this._init(sourceId, app, window);
@@ -106,4 +108,4 @@ Source.prototype = {
         MessageTray.Source.prototype.clicked.call(this);
     }
 
-}
+};
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 4d9bf30..57461f2 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -565,15 +565,13 @@ WindowOverlay.prototype = {
     _onStyleChanged: function() {
         let titleNode = this.title.get_theme_node();
 
-        let [success, len] = titleNode.get_length('-shell-caption-spacing',
-                                                  false);
+        let [success, len] = titleNode.get_length('-shell-caption-spacing', false);
         if (success)
             this.title._spacing = len;
 
         let closeNode = this.closeButton.get_theme_node();
 
-        [success, len] = closeNode.get_length('-shell-close-overlap',
-                                              false);
+        [success, len] = closeNode.get_length('-shell-close-overlap', false);
         if (success)
             this.closeButton._overlap = len;
 
@@ -1429,7 +1427,7 @@ Workspace.prototype = {
 
     // Tests if @win should be shown in the Overview
     _isOverviewWindow : function (win) {
-        let tracker = Shell.WindowTracker.get_default()
+        let tracker = Shell.WindowTracker.get_default();
         return tracker.is_window_interesting(win.get_meta_window());
     },
 
diff --git a/js/ui/workspaceSwitcherPopup.js b/js/ui/workspaceSwitcherPopup.js
index 31e380f..3970265 100644
--- a/js/ui/workspaceSwitcherPopup.js
+++ b/js/ui/workspaceSwitcherPopup.js
@@ -97,7 +97,7 @@ WorkspaceSwitcherPopup.prototype = {
         Tweener.addTween(this._container, { opacity: 0.0,
                                             time: ANIMATION_TIME,
                                             transition: "easeOutQuad",
-                                            onComplete: function() { this.actor.hide() },
+                                            onComplete: function() { this.actor.hide(); },
                                             onCompleteScope: this
                                            });
     }
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index f87211c..64d444d 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -262,7 +262,7 @@ GenericWorkspacesView.prototype = {
     _addWorkspaceActor: function() {
         throw new Error("Not implemented");
     }
-}
+};
 
 function MosaicView(width, height, x, y, animate) {
     this._init(width, height, x, y, animate);


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