Bug 1532367 - Remove accessible/.eslintrc.js and use the global rules for accessible/ r=surkov
authorMark Banner <standard8@mozilla.com>
Mon, 04 Mar 2019 21:47:38 +0000
changeset 520164 d019f0762a071678ba7a280f1bdfbe5ccff02dae
parent 520163 34d5cbb640e33ad6b06af239788470118156764b
child 520165 b0b9322c7a5986af47dd41331a1ffd6c196ffc53
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1532367
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532367 - Remove accessible/.eslintrc.js and use the global rules for accessible/ r=surkov Differential Revision: https://phabricator.services.mozilla.com/D21973
accessible/.eslintrc.js
accessible/jsat/EventManager.jsm
accessible/jsat/Utils.jsm
accessible/tests/browser/shared-head.js
accessible/tests/mochitest/actions.js
accessible/tests/mochitest/common.js
accessible/tests/mochitest/events.js
accessible/tests/mochitest/events/test_coalescence.html
accessible/tests/mochitest/events/test_mutation.html
accessible/tests/mochitest/layout.js
accessible/tests/mochitest/name.js
accessible/tests/mochitest/relations.js
accessible/tests/mochitest/text.js
accessible/tests/mochitest/text/test_atcaretoffset.html
deleted file mode 100644
--- a/accessible/.eslintrc.js
+++ /dev/null
@@ -1,16 +0,0 @@
-"use strict";
-
-module.exports = {
-  "rules": {
-    // Warn about cyclomatic complexity in functions.
-    "complexity": ["error", 47],
-
-    // XXX These are rules that are enabled in the recommended configuration, but
-    // disabled here due to failures when initially implemented. They should be
-    // removed (and hence enabled) at some stage.
-    "consistent-return": "off",
-    "no-unexpected-multiline": "off",
-    "no-unsafe-finally": "off",
-    "no-useless-call": "off",
-  }
-};
--- a/accessible/jsat/EventManager.jsm
+++ b/accessible/jsat/EventManager.jsm
@@ -275,13 +275,11 @@ const AccessibilityEventObserver = {
           Logger.accessibleToString(event.accessibleDocument));
       }
       return;
     }
     try {
       eventManager.handleAccEvent(event);
     } catch (x) {
       Logger.logException(x, "Error handing accessible event");
-    } finally {
-      return;
     }
   },
 };
--- a/accessible/jsat/Utils.jsm
+++ b/accessible/jsat/Utils.jsm
@@ -121,19 +121,18 @@ var Utils = { // jshint ignore:line
             str = bundle.GetStringFromName(string);
           }
           if (count) {
             str = PluralForm.get(count, str);
             str = str.replace("#1", count);
           }
         } catch (e) {
           Logger.debug("Failed to get a string from a bundle for", string);
-        } finally {
-          return str;
         }
+        return str;
       },
     };
     return this.stringBundle;
   },
 
   getMessageManager: function getMessageManager(aBrowser) {
     let browser = aBrowser || this.getCurrentBrowser();
     try {
@@ -270,16 +269,17 @@ var Utils = { // jshint ignore:line
 
   matchAttributeValue: function matchAttributeValue(aAttributeValue, values) {
     let attrSet = new Set(aAttributeValue.split(" "));
     for (let value of values) {
       if (attrSet.has(value)) {
         return value;
       }
     }
+    return undefined;
   },
 
   getLandmarkName: function getLandmarkName(aAccessible) {
     return this.matchRoles(aAccessible, [
       "banner",
       "complementary",
       "contentinfo",
       "main",
@@ -303,17 +303,17 @@ var Utils = { // jshint ignore:line
       "superscript",
       "underscript",
     ]);
   },
 
   matchRoles: function matchRoles(aAccessible, aRoles) {
     let roles = this.getAttributes(aAccessible)["xml-roles"];
     if (!roles) {
-      return;
+      return undefined;
     }
 
     // Looking up a role that would match any in the provided roles.
     return this.matchAttributeValue(roles, aRoles);
   },
 
   getEmbeddedControl: function getEmbeddedControl(aLabel) {
     if (aLabel) {
--- a/accessible/tests/browser/shared-head.js
+++ b/accessible/tests/browser/shared-head.js
@@ -330,16 +330,17 @@ function findAccessibleChildByID(accessi
     return queryInterfaces(accessible, interfaces);
   }
   for (let i = 0; i < accessible.children.length; ++i) {
     let found = findAccessibleChildByID(accessible.getChildAt(i), id);
     if (found) {
       return queryInterfaces(found, interfaces);
     }
   }
+  return null;
 }
 
 function queryInterfaces(accessible, interfaces) {
   if (!interfaces) {
     return accessible;
   }
 
   for (let iface of interfaces.filter(i => !(accessible instanceof i))) {
--- a/accessible/tests/mochitest/actions.js
+++ b/accessible/tests/mochitest/actions.js
@@ -127,16 +127,17 @@ function actionInvoker(aAccOrElmOrId, aA
        "Wrong action name of the accessible for " + prettyName(aAccOrElmOrId));
 
     try {
       acc.doAction(aActionIndex);
     } catch (e) {
       ok(false, "doAction(" + aActionIndex + ") failed with: " + e.name);
       return INVOKER_ACTION_FAILED;
     }
+    return null;
   };
 
   this.eventSeq = aEventSeq;
 
   this.getID = function actionInvoker_getID() {
     return "invoke an action " + aActionName + " at index " + aActionIndex +
       " on " + prettyName(aAccOrElmOrId);
   };
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -152,18 +152,20 @@ function dumpTree(aId, aMsg) {
 function addA11yLoadEvent(aFunc, aWindow) {
   function waitForDocLoad() {
     window.setTimeout(
       function() {
         var targetDocument = aWindow ? aWindow.document : document;
         var accDoc = getAccessible(targetDocument);
         var state = {};
         accDoc.getState(state, {});
-        if (state.value & STATE_BUSY)
-          return waitForDocLoad();
+        if (state.value & STATE_BUSY) {
+          waitForDocLoad();
+          return;
+        }
 
         window.setTimeout(aFunc, 0);
       },
       0
     );
   }
 
   if (aWindow &&
@@ -383,16 +385,17 @@ const kSkipTreeFullCheck = 1;
  *                         accessible object. Additionally special properties
  *                         are presented:
  *                          children - an array of JS objects representing
  *                                      children of accessible
  *                          states   - an object having states and extraStates
  *                                      fields
  * @param aFlags          [in, optional] flags, see constants above
  */
+// eslint-disable-next-line complexity
 function testAccessibleTree(aAccOrElmOrID, aAccTree, aFlags) {
   var acc = getAccessible(aAccOrElmOrID);
   if (!acc)
     return;
 
   var accTree = aAccTree;
 
   // Support of simplified accessible tree object.
@@ -740,16 +743,17 @@ function getAccessibleDOMNodeID(accessib
     return accessible.DOMNode.id;
   } catch (e) { /* This will fail if DOMNode is in different process. */ }
   try {
     // When e10s is enabled, accessible will have an "id" property if its
     // corresponding DOMNode has an id. If accessible is a document, its "id"
     // property corresponds to the "id" of its body element.
     return accessible.id;
   } catch (e) { /* This will fail if accessible is not a proxy. */ }
+  return null;
 }
 
 /**
  * Return pretty name for identifier, it may be ID, DOM node or accessible.
  */
 function prettyName(aIdentifier) {
   if (aIdentifier instanceof Array) {
     let msg = "";
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -152,18 +152,20 @@ function waveOverImageMap(aImageMapID) {
 
 /**
  * Call the given function when the tree of the given image map is built.
  */
 function waitForImageMap(aImageMapID, aTestFunc) {
   waveOverImageMap(aImageMapID);
 
   var imageMapAcc = getAccessible(aImageMapID);
-  if (imageMapAcc.firstChild)
-    return aTestFunc();
+  if (imageMapAcc.firstChild) {
+    aTestFunc();
+    return;
+  }
 
   waitForEvent(EVENT_REORDER, imageMapAcc, aTestFunc);
 }
 
 /**
  * Register accessibility event listener.
  *
  * @param aEventType     the accessible event type (see nsIAccessibleEvent for
@@ -314,16 +316,17 @@ function eventQueue(aEventType) {
   this.onFinish = function eventQueue_finish() {
   };
 
   // private
 
   /**
    * Process next invoker.
    */
+  // eslint-disable-next-line complexity
   this.processNextInvoker = function eventQueue_processNextInvoker() {
     // Some scenario was matched, we wait on next invoker processing.
     if (this.mNextInvokerStatus == kInvokerCanceled) {
       this.setInvokerStatus(kInvokerNotScheduled,
                             "scenario was matched, wait for next invoker activation");
       return;
     }
 
@@ -481,16 +484,17 @@ function eventQueue(aEventType) {
     // Check in timeout invoker didn't fire registered events.
     window.setTimeout(function(aQueue) { aQueue.processNextInvoker(); }, 300,
                       this);
   };
 
   /**
    * Handle events for the current invoker.
    */
+  // eslint-disable-next-line complexity
   this.handleEvent = function eventQueue_handleEvent(aEvent) {
     var invoker = this.getInvoker();
     if (!invoker) // skip events before test was started
       return;
 
     if (!this.mScenarios) {
       // Bad invoker object, error will be reported before processing of next
       // invoker in the queue.
@@ -1948,16 +1952,17 @@ function selAddSeq(aSelectedID) {
 // //////////////////////////////////////////////////////////////////////////////
 // General
 
 var gA11yEventListeners = {};
 var gA11yEventApplicantsCount = 0;
 
 var gA11yEventObserver =
 {
+  // eslint-disable-next-line complexity
   observe: function observe(aSubject, aTopic, aData) {
     if (aTopic != "accessible-event")
       return;
 
     var event;
     try {
       event = aSubject.QueryInterface(nsIAccessibleEvent);
     } catch (ex) {
--- a/accessible/tests/mochitest/events/test_coalescence.html
+++ b/accessible/tests/mochitest/events/test_coalescence.html
@@ -85,25 +85,28 @@
 
           case kShowElm:
             aNode.style.display = "block";
             break;
 
           default:
             return INVOKER_ACTION_FAILED;
         }
+        // 0 means the action succeeded.
+        return 0;
       };
 
       this.getEventType = function coalescenceBase_getEventType(aAction) {
         switch (aAction) {
           case kRemoveElm: case kHideElm:
             return EVENT_HIDE;
           case kAddElm: case kShowElm:
             return EVENT_SHOW;
         }
+        return 0;
       };
 
       this.getActionName = function coalescenceBase_getActionName(aAction) {
         switch (aAction) {
           case kRemoveElm:
             return "remove";
           case kHideElm:
             return "hide";
--- a/accessible/tests/mochitest/events/test_mutation.html
+++ b/accessible/tests/mochitest/events/test_mutation.html
@@ -81,16 +81,18 @@
         if (aEventType == kReorderEvent)
           return nsIAccessibleEvent.EVENT_REORDER;
 
         if (aEventType == kHideEvent)
           return nsIAccessibleEvent.EVENT_HIDE;
 
         if (aEventType == kShowEvent)
           return nsIAccessibleEvent.EVENT_SHOW;
+
+        return 0;
       };
 
       this.getEventSeq = function mutateA11yTree_getEventSeq() {
         return this.doNotExpectEvents ? this.unexpectedEventSeq : this.eventSeq;
       };
 
       if (aEventTypes & kHideEvent) {
         let checker = new invokerChecker(this.getA11yEventType(kHideEvent),
@@ -154,21 +156,21 @@
       this.__proto__ = new mutateA11yTree(aNodeOrID, eventTypes,
                                           doNotExpectEvents);
 
       this.invoke = function cloneAndAppendToDOM_invoke() {
         var newElm = this.DOMNode.cloneNode(true);
         newElm.removeAttribute("id");
 
         var targets = aTargetsFunc ?
-          aTargetsFunc.call(null, newElm) : [newElm];
+          aTargetsFunc(newElm) : [newElm];
         this.setTargets(kShowEvent, targets);
 
         if (aReorderTargetFunc) {
-          var reorderTarget = aReorderTargetFunc.call(null, this.DOMNode);
+          var reorderTarget = aReorderTargetFunc(this.DOMNode);
           this.setTarget(kReorderEvent, reorderTarget);
         }
 
         this.DOMNode.parentNode.appendChild(newElm);
       };
 
       this.getID = function cloneAndAppendToDOM_getID() {
         return aNodeOrID + " clone and append to DOM.";
@@ -190,21 +192,20 @@
         this.DOMNode.remove();
       };
 
       this.getID = function removeFromDOM_getID() {
         return prettyName(aNodeOrID) + " remove from DOM.";
       };
 
       if (aTargetsFunc && (eventTypes & kHideEvent))
-        this.setTargets(kHideEvent, aTargetsFunc.call(null, this.DOMNode));
+        this.setTargets(kHideEvent, aTargetsFunc(this.DOMNode));
 
       if (aReorderTargetFunc && (eventTypes & kReorderEvent))
-        this.setTarget(kReorderEvent,
-                       aReorderTargetFunc.call(null, this.DOMNode));
+        this.setTarget(kReorderEvent, aReorderTargetFunc(this.DOMNode));
     }
 
     /**
      * Clone the node and replace the original node by cloned one.
      */
     function cloneAndReplaceInDOM(aNodeOrID) {
       this.__proto__ = new mutateA11yTree(aNodeOrID, kHideAndShowEvents,
                                           false);
--- a/accessible/tests/mochitest/layout.js
+++ b/accessible/tests/mochitest/layout.js
@@ -83,17 +83,17 @@ function setResolution(aDocument, aZoom)
  * @param aY                 [in] y coordinate of the point relative accessible
  * @param aFindDeepestChild  [in] points whether deepest or nearest child should
  *                           be returned
  * @return                   the child accessible at the given point
  */
 function getChildAtPoint(aIdentifier, aX, aY, aFindDeepestChild) {
   var acc = getAccessible(aIdentifier);
   if (!acc)
-    return;
+    return null;
 
   var [screenX, screenY] = getBoundsForDOMElm(acc.DOMNode);
 
   var x = screenX + aX;
   var y = screenY + aY;
 
   try {
     if (aFindDeepestChild)
--- a/accessible/tests/mochitest/name.js
+++ b/accessible/tests/mochitest/name.js
@@ -1,17 +1,17 @@
 /**
  * Test accessible name for the given accessible identifier.
  */
 function testName(aAccOrElmOrID, aName, aMsg, aTodo) {
   var msg = aMsg ? aMsg : "";
 
   var acc = getAccessible(aAccOrElmOrID);
   if (!acc)
-    return;
+    return "";
 
   var func = aTodo ? todo_is : is;
   var txtID = prettyName(aAccOrElmOrID);
   try {
     func(acc.name, aName, msg + "Wrong name of the accessible for " + txtID);
   } catch (e) {
     ok(false, msg + "Can't get name of the accessible for " + txtID);
   }
--- a/accessible/tests/mochitest/relations.js
+++ b/accessible/tests/mochitest/relations.js
@@ -151,17 +151,17 @@ function testAbsentRelation(aIdentifier,
  *
  * @param aIdentifier  [in] identifier to get an accessible, may be ID attribute
  *                     or DOM element or accessible object
  * @param aRelType     [in] relation type (see constants above)
  */
 function getRelationByType(aIdentifier, aRelType) {
   var acc = getAccessible(aIdentifier);
   if (!acc)
-    return;
+    return null;
 
   var relation = null;
   try {
     relation = acc.getRelationByType(aRelType);
   } catch (e) {
     ok(false, "Can't get" + getRelationErrorMsg(aIdentifier, aRelType));
   }
 
--- a/accessible/tests/mochitest/text.js
+++ b/accessible/tests/mochitest/text.js
@@ -602,9 +602,10 @@ function boundaryToString(aBoundaryType)
       return "word start";
     case BOUNDARY_WORD_END:
       return "word end";
     case BOUNDARY_LINE_START:
       return "line start";
     case BOUNDARY_LINE_END:
       return "line end";
   }
+  return "unknown";
 }
--- a/accessible/tests/mochitest/text/test_atcaretoffset.html
+++ b/accessible/tests/mochitest/text/test_atcaretoffset.html
@@ -339,18 +339,18 @@
             var failure = this.failures[fIdx];
             if (func.name.includes(failure[0]) && boundary == failure[1]) {
               isOk1 = failure[2];
               isOk2 = failure[3];
               isOk3 = failure[4];
             }
           }
 
-          func.call(null, kCaretOffset, boundary, text, startOffset, endOffset,
-                    aID, isOk1, isOk2, isOk3);
+          func(kCaretOffset, boundary, text, startOffset, endOffset,
+               aID, isOk1, isOk2, isOk3);
         }
       };
 
       this.getID = function genericMoveTo_getID() {
         return "move to " + this.offsetDescr;
       };
 
       this.noTests = function tmpl_moveTo_noTests() {