Bug 1509779 - Stop ignoring mozilla/use-cc-etc linting rule, and other linting mistakes; r=aceman
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 29 Nov 2018 12:04:38 +1300
changeset 33806 97d41ef7fee6a9ab617731c3d5519dd96f3d50c8
parent 33805 bfe80ab94c1223fecddc29073fbd1b076c10e4b1
child 33807 f43611e42a795fadea6cd6d4695929588152098b
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersaceman
bugs1509779
Bug 1509779 - Stop ignoring mozilla/use-cc-etc linting rule, and other linting mistakes; r=aceman
.eslintrc.js
calendar/.eslintrc.js
common/bindings/textbox.xml
mail/base/content/mailWidgets.xml
mail/components/extensions/parent/ext-legacy.js
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -10,19 +10,16 @@ module.exports = {
   ],
 
   // When adding items to this file please check for effects on sub-directories.
   "plugins": [
     "mozilla",
   ],
 
   "rules": {
-    // XXX We are waiting for m-c to create a script to fix these in bug 1433175.
-    // Disabling this rule as part of bug 1436605 until that is the case.
-    "mozilla/use-cc-etc": "off",
     "no-multi-spaces": ["error", {
       exceptions: {
         "ArrayExpression": true,
         "AssignmentExpression": true,
         "ObjectExpression": true,
         "VariableDeclarator": true,
       },
       ignoreEOLComments: true,
--- a/calendar/.eslintrc.js
+++ b/calendar/.eslintrc.js
@@ -1,15 +1,18 @@
 "use strict";
 
 module.exports = {
     "extends": [
         "../../toolkit/.eslintrc.js"
     ],
     "rules": {
+        // Awaiting bug 1458367.
+        "mozilla/use-cc-etc": "off",
+
         // Enforce one true brace style (opening brace on the same line)
         // Allow single line (for now) because of the vast number of changes needed
         "brace-style": [2, "1tbs", { allowSingleLine: true }],
 
         // Enforce newline at the end of file, with no multiple empty lines.
         "eol-last": 2,
 
         // Disallow using variables outside the blocks they are defined
--- a/common/bindings/textbox.xml
+++ b/common/bindings/textbox.xml
@@ -125,22 +125,21 @@
           this.inputField.setSelectionRange( aSelectionStart, aSelectionEnd );
         </body>
       </method>
 
       <method name="_setNewlineHandling">
         <body><![CDATA[
           var str = this.getAttribute("newlines");
           if (str && this.editor) {
-            const nsIPlaintextEditor = Components.interfaces.nsIPlaintextEditor;
-            for (var x in nsIPlaintextEditor) {
+            for (let x in Ci.nsIPlaintextEditor) {
               if (/^eNewlines/.test(x)) {
                 if (str == RegExp.rightContext.toLowerCase()) {
-                  this.editor.QueryInterface(nsIPlaintextEditor)
-                      .newlineHandling = nsIPlaintextEditor[x];
+                  this.editor.QueryInterface(Ci.nsIPlaintextEditor)
+                      .newlineHandling = Ci.nsIPlaintextEditor[x];
                   break;
                 }
               }
             }
           }
         ]]></body>
       </method>
 
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -1,30 +1,29 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
-<!-- globals fillInTags // mailWidgets.xml -->
 <!-- import-globals-from ../../../mailnews/base/content/dateFormat.js -->
 <!-- import-globals-from mailWindow.js -->
 <!-- import-globals-from SearchDialog.js -->
 
 <!DOCTYPE bindings [
 <!ENTITY % msgHdrViewOverlayDTD SYSTEM "chrome://messenger/locale/msgHdrViewOverlay.dtd" >
 %msgHdrViewOverlayDTD;
 <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
 %messengerDTD;
 ]>
 
-<bindings   id="mailBindings"
-            xmlns="http://www.mozilla.org/xbl"
-            xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-            xmlns:nc="http://home.netscape.com/NC-rdf#"
-            xmlns:xbl="http://www.mozilla.org/xbl">
+<bindings id="mailBindings"
+          xmlns="http://www.mozilla.org/xbl"
+          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+          xmlns:nc="http://home.netscape.com/NC-rdf#"
+          xmlns:xbl="http://www.mozilla.org/xbl">
 
   <!-- dummy widget to force this file to load -->
   <binding id="dummy" extends="xul:box"/>
 
   <binding id="attachmentlist-base" extends="chrome://global/content/bindings/richlistbox.xml#richlistbox">
     <implementation>
       <constructor><![CDATA[
         let children = Array.from(this._childNodes);
@@ -1604,125 +1603,123 @@
         </setter>
       </property>
       <property name="value" onget="return this.internalValue;">
         <setter>
           <![CDATA[
           // val is a nsIMsgSearchValue object
           this.internalValue = val;
           var attrib = this.internalAttribute;
-          var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
           var children = document.getAnonymousNodes(this);
           this.searchAttribute = attrib;
           if (isNaN(attrib)) { // a custom term
             let customHbox = document.getAnonymousNodes(this)[10];
             customHbox.setAttribute("value", val.str);
             return val;
           }
-          if (attrib == nsMsgSearchAttrib.Priority) {
+          if (attrib == Ci.nsMsgSearchAttrib.Priority) {
             var matchingPriority =
               children[1].querySelector(`[value="${val.priority}"]`);
             if (matchingPriority)
               children[1].selectedItem = matchingPriority;
-          } else if (attrib == nsMsgSearchAttrib.MsgStatus) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.MsgStatus) {
             var matchingStatus =
               children[2].querySelector(`[value="${val.status}"]`);
             if (matchingStatus)
               children[2].selectedItem = matchingStatus;
-          } else if (attrib == nsMsgSearchAttrib.AgeInDays) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.AgeInDays) {
             children[9].value = val.age;
-          } else if (attrib == nsMsgSearchAttrib.Date) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.Date) {
             children[3].value = convertPRTimeToString(val.date);
-          } else if (attrib == nsMsgSearchAttrib.Sender ||
-                     attrib == nsMsgSearchAttrib.To ||
-                     attrib == nsMsgSearchAttrib.CC ||
-                     attrib == nsMsgSearchAttrib.AllAddresses ||
-                     attrib == nsMsgSearchAttrib.ToOrCC) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.Sender ||
+                     attrib == Ci.nsMsgSearchAttrib.To ||
+                     attrib == Ci.nsMsgSearchAttrib.CC ||
+                     attrib == Ci.nsMsgSearchAttrib.AllAddresses ||
+                     attrib == Ci.nsMsgSearchAttrib.ToOrCC) {
             if (this.internalOperator == Ci.nsMsgSearchOp.IsntInAB ||
                 this.internalOperator == Ci.nsMsgSearchOp.IsInAB) {
               var abs = children[4].querySelector(`[value="${val.str}"]`);
               if (abs)
                 children[4].selectedItem = abs;
             } else {
               children[0].value = val.str;
             }
-          } else if (attrib == nsMsgSearchAttrib.Keywords) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.Keywords) {
             var keywordVal = children[5].querySelector(`[value="${val.str}"]`);
             if (keywordVal) {
               children[5].value = val.str;
               children[5].selectedItem = keywordVal;
             }
-          } else if (attrib == nsMsgSearchAttrib.JunkStatus) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.JunkStatus) {
             var junkStatus =
               children[6].querySelector(`[value="${val.junkStatus}"]`);
             if (junkStatus)
               children[6].selectedItem = junkStatus;
-          } else if (attrib == nsMsgSearchAttrib.HasAttachmentStatus) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.HasAttachmentStatus) {
             var hasAttachmentStatus =
               children[7].querySelector(`[value="${val.hasAttachmentStatus}"]`);
             if (hasAttachmentStatus)
               children[7].selectedItem = hasAttachmentStatus;
-          } else if (attrib == nsMsgSearchAttrib.JunkScoreOrigin) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.JunkScoreOrigin) {
             var junkScoreOrigin =
               children[8].querySelector(`[value="${val.str}"]`);
             if (junkScoreOrigin)
               children[8].selectedItem = junkScoreOrigin;
-          } else if (attrib == nsMsgSearchAttrib.JunkPercent) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.JunkPercent) {
             children[9].value = val.junkPercent;
-          } else if (attrib == nsMsgSearchAttrib.Size) {
+          } else if (attrib == Ci.nsMsgSearchAttrib.Size) {
             children[9].value = val.size;
           } else {
             children[0].value = val.str;
           }
           return val;
           ]]>
         </setter>
       </property>
       <method name="save">
         <body>
           <![CDATA[
             var searchValue = this.value;
             var searchAttribute = this.searchAttribute;
-            var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
             var children = document.getAnonymousNodes(this);
 
             searchValue.attrib = searchAttribute;
-            if (searchAttribute == nsMsgSearchAttrib.Priority) {
+            if (searchAttribute == Ci.nsMsgSearchAttrib.Priority) {
               searchValue.priority = children[1].selectedItem.value;
-            } else if (searchAttribute == nsMsgSearchAttrib.MsgStatus) {
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.MsgStatus) {
               searchValue.status = children[2].value;
-            } else if (searchAttribute == nsMsgSearchAttrib.AgeInDays) {
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.AgeInDays) {
               searchValue.age = children[9].value;
-            } else if (searchAttribute == nsMsgSearchAttrib.Date) {
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.Date) {
               searchValue.date = convertStringToPRTime(children[3].value);
-            } else if (searchAttribute == nsMsgSearchAttrib.Sender ||
-                       searchAttribute == nsMsgSearchAttrib.To ||
-                       searchAttribute == nsMsgSearchAttrib.CC ||
-                       searchAttribute == nsMsgSearchAttrib.AllAddresses ||
-                       searchAttribute == nsMsgSearchAttrib.ToOrCC) {
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.Sender ||
+                       searchAttribute == Ci.nsMsgSearchAttrib.To ||
+                       searchAttribute == Ci.nsMsgSearchAttrib.CC ||
+                       searchAttribute == Ci.nsMsgSearchAttrib.AllAddresses ||
+                       searchAttribute == Ci.nsMsgSearchAttrib.ToOrCC) {
               if (this.internalOperator == Ci.nsMsgSearchOp.IsntInAB ||
                   this.internalOperator == Ci.nsMsgSearchOp.IsInAB) {
                 searchValue.str = children[4].selectedItem.value;
               } else {
                 searchValue.str = children[0].value;
               }
-            } else if (searchAttribute == nsMsgSearchAttrib.Keywords) {
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.Keywords) {
               searchValue.str = children[5].value;
-            } else if (searchAttribute == nsMsgSearchAttrib.JunkStatus) {
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.JunkStatus) {
               searchValue.junkStatus = children[6].value;
-            } else if (searchAttribute == nsMsgSearchAttrib.JunkPercent) {
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.JunkPercent) {
               searchValue.junkPercent = children[9].value;
-            } else if (searchAttribute == nsMsgSearchAttrib.Size) {
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.Size) {
               searchValue.size = children[9].value;
-            } else if (searchAttribute == nsMsgSearchAttrib.HasAttachmentStatus) {
-              searchValue.status = 0x10000000;  // 0x10000000 is MSG_FLAG_ATTACHMENT;
-            } else if (searchAttribute == nsMsgSearchAttrib.JunkScoreOrigin) {
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.HasAttachmentStatus) {
+              searchValue.status = Ci.nsMsgMessageFlags.Attachment;
+            } else if (searchAttribute == Ci.nsMsgSearchAttrib.JunkScoreOrigin) {
               searchValue.str = children[8].value;
             } else if (isNaN(searchAttribute)) { // a custom term
-              searchValue.attrib = nsMsgSearchAttrib.Custom;
+              searchValue.attrib = Ci.nsMsgSearchAttrib.Custom;
               searchValue.str = children[10].getAttribute("value");
             } else {
               searchValue.str = children[0].value;
             }
           ]]>
         </body>
       </method>
       <method name="saveTo">
@@ -1791,19 +1788,18 @@
         this.initialize(document.getAnonymousNodes(this)[1], bundle);
 
         // initialize the status picker
         this.initialize(document.getAnonymousNodes(this)[2], bundle);
 
         // initialize the date picker
         var datePicker = document.getAnonymousNodes(this)[3];
         var searchAttribute = this.searchAttribute;
-        var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
         var time;
-        if (searchAttribute == nsMsgSearchAttrib.Date)
+        if (searchAttribute == Ci.nsMsgSearchAttrib.Date)
          time = datePicker.value;
         else
          time = new Date();
         // do .value instead of .setAttribute("value", xxx);
         // to work around for bug #179412
         // (caused by bug #157210)
         //
         // the searchvalue widget has two textboxes
@@ -1818,17 +1814,17 @@
 
         // initialize the has attachment status picker
         this.initialize(document.getAnonymousNodes(this)[7], bundle);
 
         // initialize the junk score origin picker
         this.initialize(document.getAnonymousNodes(this)[8], bundle);
 
         // initialize the tag list
-        fillInTags();
+        this.fillInTags();
       ]]>
       </constructor>
     </implementation>
     <handlers>
       <handler event="keypress" keycode="VK_RETURN" modifiers="accel any"
                action="onEnterInSearchTerm(event);" preventdefault="true"/>
     </handlers>
   </binding>
--- a/mail/components/extensions/parent/ext-legacy.js
+++ b/mail/components/extensions/parent/ext-legacy.js
@@ -109,19 +109,19 @@ this.legacy = class extends ExtensionAPI
     // Fire profile-after-change notifications, because we are past that event by now
     console.log("Firing profile-after-change listeners for", this.extension.id);
     let profileAfterChange = chromeManifest.category.get("profile-after-change");
     for (let contractid of profileAfterChange.values()) {
       let service = contractid.startsWith("service,");
       let instance;
       try {
         if (service) {
-          instance = Components.classes[contractid.substr(8)].getService(Ci.nsIObserver);
+          instance = Cc[contractid.substr(8)].getService(Ci.nsIObserver);
         } else {
-          instance = Components.classes[contractid].createInstance(Ci.nsIObserver);
+          instance = Cc[contractid].createInstance(Ci.nsIObserver);
         }
 
         instance.observe(null, "profile-after-change", null);
       } catch (e) {
         console.error("Error firing profile-after-change listener for", contractid);
       }
     }