[Pkg-mozext-commits] [tabmixplus] 04/44: Use eslint-plugin-mozilla to lint xml files

David Prévot taffit at moszumanska.debian.org
Fri Mar 18 20:57:14 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 708f79f9fbcb7ff12b934c175ffe1a121365c1cf
Author: onemen <tabmix.onemen at gmail.com>
Date:   Thu Feb 18 13:27:00 2016 +0200

    Use eslint-plugin-mozilla to lint xml files
---
 .eslintrc                                          |  1 +
 .eslintrc_mozilla                                  |  6 ++
 chrome/content/preferences/overlay/preferences.xml |  2 +-
 chrome/content/preferences/shortcuts.xml           | 16 ++---
 .../preferences/subdialogs/pref-appearance.xml     | 46 ++++++-------
 chrome/content/tab/scrollbox.xml                   | 79 +++++++++++-----------
 chrome/content/tab/tabbrowser_4.xml                | 40 +++++------
 chrome/content/tab/text.xml                        |  2 +-
 8 files changed, 95 insertions(+), 97 deletions(-)

diff --git a/.eslintrc b/.eslintrc
index 977627d..01b0900 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -220,6 +220,7 @@
         "filenamesRegex": false,
         "MergeWindows": false,
         "getFormattedKey": false,
+        "getKeysForShortcut": false,
         "gTMPprefObserver": false,
         "gAppearancePane": false,
         "gPrefWindow": false,
diff --git a/.eslintrc_mozilla b/.eslintrc_mozilla
new file mode 100644
index 0000000..042669f
--- /dev/null
+++ b/.eslintrc_mozilla
@@ -0,0 +1,6 @@
+{
+    "plugins": ["eslint-plugin-mozilla"],
+
+    "rules": {
+    }
+}
diff --git a/chrome/content/preferences/overlay/preferences.xml b/chrome/content/preferences/overlay/preferences.xml
index 3a84c5a..06e4a4b 100644
--- a/chrome/content/preferences/overlay/preferences.xml
+++ b/chrome/content/preferences/overlay/preferences.xml
@@ -23,7 +23,7 @@
               '  if (w && where == "window" && w.Tabmix.getSingleWindowMode())\n' +
               '    where = "tab";\n'
             ).toCode();
-          } catch(ex) {
+          } catch (ex) {
             TabmixSvc.console.log(
                 "TabMix :\n" +
                 "can't change openLinkIn from preferences.xml binding\n" + ex);
diff --git a/chrome/content/preferences/shortcuts.xml b/chrome/content/preferences/shortcuts.xml
index 9312511..a90336f 100644
--- a/chrome/content/preferences/shortcuts.xml
+++ b/chrome/content/preferences/shortcuts.xml
@@ -64,7 +64,7 @@
         <body><![CDATA[
           var newValue = (aDisabled ? "d&" : "") + (aNewValue || "").replace(/^d&/, "");
           if (newValue != Shortcuts.keyStringify(this.key)) {
-            let newKey = Shortcuts.keyParse(newValue)
+            let newKey = Shortcuts.keyParse(newValue);
             newKey.disabled = aDisabled;
             this.key = newKey;
             this.setAttribute("default", !this.disabled && this.defaultPref == newValue);
@@ -109,9 +109,9 @@
             }
             if (!this.hasAttribute("used"))
               this.setAttribute("used", true);
-          }
-          else
+          } else {
             this.removeAttribute("used");
+          }
           return usedKey;
         ]]></body>
       </method>
@@ -136,7 +136,7 @@
 
           var key = {modifiers: "", key: "", keycode: ""};
           key.modifiers =
-            ["ctrl","meta","alt","shift"].filter(mod => event[mod + "Key"]).
+            ["ctrl", "meta", "alt", "shift"].filter(mod => event[mod + "Key"]).
             join(",").replace("ctrl", "control");
 
           if (!key.modifiers) {
@@ -154,11 +154,11 @@
               this.disableKey();
               return;
             }
-          }
-          // when current modifier is accel replcae new modifier with accel
-          // if it match ui.key.accelKey
-          else if (this.key && this.key.modifiers.indexOf("accel") > -1)
+          } else if (this.key && this.key.modifiers.indexOf("accel") > -1) {
+            // when current modifier is accel replcae new modifier with accel
+            // if it match ui.key.accelKey
             key.modifiers = key.modifiers.replace(Shortcuts.getPlatformAccel(), "accel");
+          }
 
           if (event.charCode == Ci.nsIDOMKeyEvent.DOM_VK_SPACE)
             key.keycode = "VK_SPACE";
diff --git a/chrome/content/preferences/subdialogs/pref-appearance.xml b/chrome/content/preferences/subdialogs/pref-appearance.xml
index c9ff372..cab4eaf 100644
--- a/chrome/content/preferences/subdialogs/pref-appearance.xml
+++ b/chrome/content/preferences/subdialogs/pref-appearance.xml
@@ -73,7 +73,7 @@
 
           useThis.nextSibling.value = document.getElementById("_" + this.id).label;
           // colorpicker need some time untile its ready
-          window.setTimeout(() => {this._getPrefs(this._initPrefValues);}, 0);
+          window.setTimeout(() => this._getPrefs(this._initPrefValues), 0);
         ]]>
       </constructor>
 
@@ -90,10 +90,11 @@
         onget="return this.getAttribute('disabled');">
         <setter>
           <![CDATA[
-            if(val)
+            if (val) {
               this.setAttribute("disabled", true);
-            else
+            } else {
               this.removeAttribute("disabled");
+            }
           ]]>
         </setter>
       </property>
@@ -109,7 +110,7 @@
         <parameter name="aEnabled"/>
         <body><![CDATA[
           Tabmix.prefs.setBoolPref(this.id, aEnabled);
-          this.disabled = !aEnabled
+          this.disabled = !aEnabled;
           if ("text" in this._prefValues)
             this.updateDisableState("text");
           this.updateDisableState("bg");
@@ -136,25 +137,24 @@
         <parameter name="aPrefString"/>
         <body><![CDATA[
           try {
-            this._prefValues = TabmixSvc.JSON.parse(aPrefString)
-          }
-          catch (er) {
+            this._prefValues = TabmixSvc.JSON.parse(aPrefString);
+          } catch (er) {
             this._resetDefault(true);
             return;
           }
 
           for (var _id in this._prefValues) {
-             var item = this._getElementById(_id);
-             if (!item)
-               continue;
-             switch (item.localName) {
-               case "checkbox":
-               case "checkbox_tmp":
-                 item.checked = this._prefValues[_id];
-                 break;
-               case "colorbox":
-                 item.color = this._prefValues[_id];
-             }
+            var item = this._getElementById(_id);
+            if (!item)
+              continue;
+            switch (item.localName) {
+              case "checkbox":
+              case "checkbox_tmp":
+                item.checked = this._prefValues[_id];
+                break;
+              case "colorbox":
+                item.color = this._prefValues[_id];
+            }
           }
 
           if ("text" in this._prefValues)
@@ -237,12 +237,12 @@
 
       <constructor>
         <![CDATA[
-          ["red","green","blue", "opacity"].forEach(function(id) {
+          ["red", "green", "blue", "opacity"].forEach(function(id) {
             this._RGB.push(document.getAnonymousElementByAttribute(this, "anonid", id));
           }, this);
 
-           this._colorpicker = document.getAnonymousElementByAttribute(this, "anonid", "color");
-           this._parent = document.getBindingParent(this);
+          this._colorpicker = document.getAnonymousElementByAttribute(this, "anonid", "color");
+          this._parent = document.getBindingParent(this);
         ]]>
       </constructor>
 
@@ -299,9 +299,9 @@
         var item = event.originalTarget;
         if (item.localName == "colorpicker") {
           // colorpicker use rgb hexadecimal format
-          let color = item.color.replace("#","");
+          let color = item.color.replace("#", "");
           for (let i = 0; i < 3; i++) {
-            let subS = color.substr(i*2, 2);
+            let subS = color.substr(i * 2, 2);
             this._RGB[i].value = parseInt(subS, 16);
           }
         }
diff --git a/chrome/content/tab/scrollbox.xml b/chrome/content/tab/scrollbox.xml
index 286f77b..af928da 100644
--- a/chrome/content/tab/scrollbox.xml
+++ b/chrome/content/tab/scrollbox.xml
@@ -231,7 +231,7 @@
           this._scrollButtonDownLeft.addEventListener("contextmenu", this._createScrollButtonContextMenu, true);
 
           Services.prefs.addObserver("toolkit.scrollbox.", this.tabmixPrefObserver, false);
-          this.firstVisible =  {tab: null, x: 0, y: 0};
+          this.firstVisible = {tab: null, x: 0, y: 0};
         ]]>
       </constructor>
 
@@ -252,19 +252,21 @@
         ]]></body>
       </method>
 
-      <field name="tabmixPrefObserver"><![CDATA[({
-        scrollbox: this,
-        observe: function (subject, topic, data) {
-          switch (data) {
-            case "toolkit.scrollbox.clickToScroll.scrollDelay":
-              this.scrollbox._scrollDelay = Services.prefs.getIntPref(data);
-              break;
-            case "toolkit.scrollbox.smoothScroll":
-              this.scrollbox.smoothScroll = Services.prefs.getBoolPref(data);
-              break;
+      <field name="tabmixPrefObserver"><![CDATA[
+        ({
+          scrollbox: this,
+          observe: function(subject, topic, data) {
+            switch (data) {
+              case "toolkit.scrollbox.clickToScroll.scrollDelay":
+                this.scrollbox._scrollDelay = Services.prefs.getIntPref(data);
+                break;
+              case "toolkit.scrollbox.smoothScroll":
+                this.scrollbox.smoothScroll = Services.prefs.getBoolPref(data);
+                break;
+            }
           }
-        }
-      });]]></field>
+        });
+      ]]></field>
 
       <!-- replace the original method -->
       <method name="scrollByPixels">
@@ -338,10 +340,10 @@
 
           // if selectedItem don't have height find other tab that does
           for (let i = 0; i < tabs.childNodes.length; i++) {
-             let tab = tabs.childNodes[i];
-             let height = tab.boxObject.height;
-             if (height)
-               return height;
+            let tab = tabs.childNodes[i];
+            let height = tab.boxObject.height;
+            if (height)
+              return height;
           }
 
           return this._scrollbox.boxObject.height;
@@ -364,7 +366,7 @@
           if (!tabs.length)
             return;
           var isFirstTabVisible = Tabmix.tabsUtils.isElementVisible(tabs[0]);
-          var isLastTabVisible = Tabmix.tabsUtils.isElementVisible(tabs[tabs.length-1]);
+          var isLastTabVisible = Tabmix.tabsUtils.isElementVisible(tabs[tabs.length - 1]);
           if (!isFirstTabVisible || !isLastTabVisible) {
             // show Newtabbutton for the first time
             // for the case last tab in row fill the all strip and the button
@@ -374,7 +376,7 @@
             let tabBar = document.getBindingParent(this);
             Tabmix.setItem(tabBar, "multibar", true);
             Tabmix.setItem("TabsToolbar", "multibar", true);
-            if (Tabmix.tabsUtils.updateVerticalTabStrip() == null)
+            if (Tabmix.tabsUtils.updateVerticalTabStrip() === null)
               TabmixTabbar._failedToEnterVerticalMode = true;
             if (blockUnderflow && this.orient == "vertical")
               this.blockUnderflow = true;
@@ -384,6 +386,7 @@
       </method>
 
       <field name="firstVisibleRow">null</field>
+
       <method name="setFirstTabInRow">
         <parameter name="scroll"/>
         <body><![CDATA[
@@ -391,8 +394,7 @@
           if (scroll) {
             if (this.firstVisibleRow == firstVisibleRow)
               return;
-          }
-          else if (this.firstVisible.tab) {
+          } else if (this.firstVisible.tab) {
             let rect = this.firstVisible.tab.getBoundingClientRect();
             if (this.firstVisible.x == rect.left && this.firstVisible.y == rect.top)
               return;
@@ -400,8 +402,8 @@
 
           this.firstVisibleRow = firstVisibleRow;
 
-///XXX check if we can set the margin with animation when we scroll
-          var end = Tabmix.ltr ? "right": "left";
+          ///XXX check if we can set the margin with animation when we scroll
+          var end = Tabmix.ltr ? "right" : "left";
           var containerEnd = this.scrollClientRect[end];
           var topY = Tabmix.tabsUtils.topTabY;
           var tabs = this._getScrollableElements();
@@ -419,7 +421,8 @@
                 tab.setAttribute("tabmix-firstTabInRow", true);
               else if (i > 0) {
                 // remove the margin when the tab have place in the previous row
-                let tabEnd = tabs[i-1].getBoundingClientRect()[end] + (Tabmix.ltr ? tab.getBoundingClientRect().width : 0);
+                let tabEnd = tabs[i - 1].getBoundingClientRect()[end] +
+                  (Tabmix.ltr ? tab.getBoundingClientRect().width : 0);
                 if (!Tabmix.compare(tabEnd, containerEnd, Tabmix.rtl)) {
                   tab.removeAttribute("tabmix-firstTabInRow");
                   continue;
@@ -431,8 +434,7 @@
                 index = ++i;
                 break;
               }
-            }
-            else if (tab.hasAttribute("tabmix-firstTabInRow"))
+            } else if (tab.hasAttribute("tabmix-firstTabInRow"))
               tab.removeAttribute("tabmix-firstTabInRow");
           }
           for (let i = index; i < tabs.length; i++) {
@@ -457,11 +459,11 @@
           // getElementsByAttribute return a live nodList
           // each time we remove the attribute we remove node from the list
           var tabBar = document.getBindingParent(this);
-          var tabs = tabBar.getElementsByAttribute("tabmix-firstTabInRow" , "*");
+          var tabs = tabBar.getElementsByAttribute("tabmix-firstTabInRow", "*");
           for (let i = 0, num = tabs.length; i < num; i++) {
             tabs[0].removeAttribute("tabmix-firstTabInRow");
           }
-          this.firstVisible =  {tab: null, x: 0, y: 0};
+          this.firstVisible = {tab: null, x: 0, y: 0};
         ]]></body>
       </method>
 
@@ -485,8 +487,7 @@
               if (childNodes && childNodes.length)
                 this.ensureElementIsVisible(childNodes[0], false);
             }
-          }
-          catch(e) {
+          } catch (e) {
             Tabmix.setItem(this, "notoverflowing", overflow || null);
           }
         ]]></body>
@@ -506,11 +507,9 @@
             this.blockUnderflow = false;
             return;
           }
-        }
-        else {
+        } else if (event.detail == 0) {
           // horizontal scrollbox - Ignore vertical events
-          if (event.detail == 0)
-            return;
+          return;
         }
 
         var tabs = document.getBindingParent(this);
@@ -521,9 +520,9 @@
               (!Tabmix.visibleTabs.last.hasAttribute("showbutton") &&
                !Tabmix.visibleTabs.last.hasAttribute("showbutton_removed")))
             Tabmix.tabsUtils.updateVerticalTabStrip();
-        }
-        else
+        } else {
           Tabmix.tabsUtils.overflow = false;
+        }
       ]]></handler>
 
       <handler event="overflow"><![CDATA[
@@ -531,15 +530,13 @@
         if (event.originalTarget != this._scrollbox)
           return;
 
-        var tabs = document.getBindingParent(this);
         if (this.orient == "vertical") {
           // vertical scrollbox - Ignore horizontal events
           if (event.detail == 1 || this.blockOverflow) {
             this.blockOverflow = false;
             return;
           }
-        }
-        else {
+        } else {
           // horizontal scrollbox - Ignore vertical events
           if (event.detail == 0)
             return;
@@ -562,9 +559,9 @@
           if (!TabmixSvc.isLinux || TabmixTabbar.visibleRows == 1 ||
               !Tabmix.visibleTabs.last.hasAttribute("showbutton"))
             Tabmix.tabsUtils.updateVerticalTabStrip();
-        }
-        else
+        } else {
           Tabmix.tabsUtils.overflow = true;
+        }
       ]]></handler>
 
       <handler event="scroll"><![CDATA[
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index 002e464..d58f7bd 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -131,8 +131,7 @@
       <getter><![CDATA[
         try {
           return Tabmix.prefs.getBoolPref("mouseOverSelect");
-        }
-        catch(e) {
+        } catch (e) {
           return false;
         }
       ]]></getter>
@@ -141,8 +140,7 @@
       <getter><![CDATA[
         try {
           return Tabmix.prefs.getBoolPref("selectTabOnMouseDown");
-        }
-        catch(e) {
+        } catch (e) {
           return false;
         }
       ]]></getter>
@@ -151,8 +149,7 @@
       <getter><![CDATA[
         try {
           return Tabmix.prefs.getIntPref("mouseOverSelectDelay");
-        }
-        catch(e) {
+        } catch (e) {
           return 250;
         }
       ]]></getter>
@@ -161,9 +158,8 @@
       <getter><![CDATA[
         try {
           return Tabmix.prefs.getIntPref("tabs.closeButtons.delay");
-        }
-        catch(e) {
-        return 0;
+        } catch (e) {
+          return 0;
         }
       ]]></getter>
     </property>
@@ -181,10 +177,10 @@
           this.mFocusId = window.setTimeout(this.doMouseHoverSelect, this.mouseHoverSelectDelay, this);
 
         if (TabmixSvc.australis) {
-          this.tabmix_mouseover = window.setTimeout(function(self) {
-            clearTimeout(self.tabmix_mouseover);
+          this.tabmix_mouseover = window.setTimeout(() => {
+            clearTimeout(this.tabmix_mouseover);
             TabmixTabbar.updateBeforeAndAfter(true);
-          }, 0, this);
+          }, 0);
         }
       ]]></body>
     </method>
@@ -197,9 +193,9 @@
 
         var b = aTab.parentNode.tabbrowser;
         if (b.hasAttribute("preventMouseHoverSelect"))
-            b.removeAttribute("preventMouseHoverSelect");
+          b.removeAttribute("preventMouseHoverSelect");
         else if (aTab.mIsHover)
-           aTab.parentNode.selectedItem = aTab;
+          aTab.parentNode.selectedItem = aTab;
       ]]></body>
     </method>
 
@@ -272,7 +268,7 @@
           // we use this in Linux to prevent underflow
           // that trigger by hidding the close button
           aTab.setAttribute("showbutton_removed", true);
-          setTimeout(function(tab) {tab.removeAttribute("showbutton_removed");}, 50, aTab);
+          setTimeout(tab => tab.removeAttribute("showbutton_removed"), 50, aTab);
           if (aTab == aTab.parentNode.__showbuttonTab)
             delete aTab.parentNode.__showbuttonTab;
         }
@@ -344,17 +340,15 @@
       <![CDATA[
         if (this.selected) {
           this.style.MozUserFocus = 'ignore';
-          this.clientTop; // just using this to flush style updates
+          void this.clientTop; // just using this to flush style updates
         }
         // prevent chrome://global/content/bindings/tabbox.xml#tab mousedown handler
         if (this.mOverCloseButton || this._overPlayingIcon) {
           event.stopPropagation();
-        }
-        else {
-          if (this.mouseDownSelect)
-            this.onMouseCommand(event);
-          else
-            event.stopPropagation();
+        } else if (this.mouseDownSelect) {
+          this.onMouseCommand(event);
+        } else {
+          event.stopPropagation();
         }
       ]]>
       </handler>
@@ -423,7 +417,7 @@
 
           if (!this._animateElement.hasAttribute("notifybgtab")) {
             this._animateElement.setAttribute("notifybgtab", "true");
-            setTimeout(function (ele) {
+            setTimeout(ele => {
               ele.removeAttribute("notifybgtab");
             }, 150, this._animateElement);
           }
diff --git a/chrome/content/tab/text.xml b/chrome/content/tab/text.xml
index d4d6456..0fe022d 100644
--- a/chrome/content/tab/text.xml
+++ b/chrome/content/tab/text.xml
@@ -12,7 +12,7 @@
            var topWin = Services.wm.getMostRecentWindow("navigator:browser");
            if (!topWin || topWin.Tabmix.isVersion(200))
              return;
-           eval("this.open ="+this.open.toString().replace(
+           eval("this.open =" + this.open.toString().replace(
              'if (uri)',
              'if (typeof win.Tabmix_openURL != "function") win.Tabmix_openURL = Tabmix.getTopWin().Tabmix.openURL.bind(Tabmix); if (uri)'
            ).replace(

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list