Bug 1564555 - Enable some more ESLint rules for layout. r=Standard8,dholbert
authorRuchikaGosain <ruchikag826@gmail.com>
Thu, 18 Jul 2019 21:00:21 +0000
changeset 483421 cd8478a8a71439f37190ac74b491d11b748d2fad
parent 483420 c226956f09f97d0916b5e9471f083518a1f8160d
child 483422 86db1d535ac582d547c03b7d7049e82da94706c2
push id90373
push usermbanner@mozilla.com
push dateThu, 18 Jul 2019 21:32:32 +0000
treeherderautoland@cd8478a8a714 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, dholbert
bugs1564555
milestone70.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 1564555 - Enable some more ESLint rules for layout. r=Standard8,dholbert Differential Revision: https://phabricator.services.mozilla.com/D38007
.eslintrc.js
layout/base/tests/bug613807-1.html
layout/base/tests/selection-utils.js
layout/base/tests/test_bug399284.html
layout/generic/test/test_bug344830.html
layout/generic/test/test_dynamic_reflow_root_disallowal.html
layout/mathml/tests/test_bug553917.html
layout/mathml/tests/test_bug827713-2.html
layout/style/test/animation_utils.js
layout/style/test/bug1382568-iframe.html
layout/style/test/property_database.js
layout/style/test/test_flexbox_order.html
layout/style/test/test_flexbox_order_abspos.html
layout/style/test/test_flexbox_order_table.html
layout/style/test/test_garbage_at_end_of_declarations.html
layout/style/test/test_position_float_display.html
layout/style/test/test_root_node_display.html
layout/style/test/test_transitions.html
layout/style/test/test_transitions_events.html
layout/style/test/test_transitions_per_property.html
layout/xul/test/test_bug381167.xhtml
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -191,33 +191,28 @@ module.exports = {
     ],
     "rules": {
       "object-shorthand": "off",
       "mozilla/avoid-removeChild": "off",
       "mozilla/consistent-if-bracing": "off",
       "mozilla/reject-importGlobalProperties": "off",
       "mozilla/no-arbitrary-setTimeout": "off",
       "mozilla/no-define-cc-etc": "off",
-      "mozilla/no-useless-parameters": "off",
-      "mozilla/no-useless-run-test": "off",
       "mozilla/use-chromeutils-generateqi": "off",
-      "mozilla/use-chromeutils-import": "off",
       "mozilla/use-default-preference-values": "off",
       "mozilla/use-includes-instead-of-indexOf": "off",
       "mozilla/use-services": "off",
       "mozilla/use-ownerGlobal": "off",
       "complexity": "off",
       "consistent-return": "off",
-      "dot-notation": "off",
       "no-array-constructor": "off",
       "no-caller": "off",
       "no-cond-assign": "off",
       "no-extra-boolean-cast": "off",
       "no-eval": "off",
-      "no-else-return": "off",
       "no-func-assign": "off",
       "no-global-assign": "off",
       "no-implied-eval": "off",
       "no-lonely-if": "off",
       "no-nested-ternary": "off",
       "no-new-wrappers": "off",
       "no-redeclare": "off",
       "no-restricted-globals": "off",
--- a/layout/base/tests/bug613807-1.html
+++ b/layout/base/tests/bug613807-1.html
@@ -20,26 +20,26 @@
         } catch (e) {
           // pass
         }
       };
       rval.callStack = [];
       return rval;
     };
     function addLoadEvent(func) {
-      var existing = window["onload"];
+      var existing = window.onload;
       var regfunc = existing;
       if (!(typeof(existing) == 'function'
             && typeof(existing.callStack) == "object"
             && existing.callStack !== null)) {
         regfunc = _newCallStack("onload");
         if (typeof(existing) == 'function') {
           regfunc.callStack.push(existing);
         }
-        window["onload"] = regfunc;
+        window.onload = regfunc;
       }
       regfunc.callStack.push(func);
     };
   }
 
   addLoadEvent(function() {
     var area = document.getElementById('t');
     area.focus();
--- a/layout/base/tests/selection-utils.js
+++ b/layout/base/tests/selection-utils.js
@@ -21,25 +21,25 @@ function getNode(e, index) {
 function dragSelectPointsWithData() {
   var event = arguments[0];
   var e = arguments[1];
   var x1 = arguments[2];
   var y1 = arguments[3];
   var x2 = arguments[4];
   var y2 = arguments[5];
   dir = x2 > x1 ? 1 : -1;
-  event["type"] = "mousedown";
+  event.type = "mousedown";
   synthesizeMouse(e, x1, y1, event);
-  event["type"] = "mousemove";
+  event.type = "mousemove";
   synthesizeMouse(e, x1 + dir, y1, event);
   for (var i = 6; i < arguments.length; ++i) {
     synthesizeMouse(e, arguments[i], y1, event);
   }
   synthesizeMouse(e, x2 - dir, y2, event);
-  event["type"] = "mouseup";
+  event.type = "mouseup";
   synthesizeMouse(e, x2, y2, event);
 }
 
 function dragSelectPoints() {
   var args = Array.prototype.slice.call(arguments);
   dragSelectPointsWithData.apply(this, [{}].concat(args));
 }
 
--- a/layout/base/tests/test_bug399284.html
+++ b/layout/base/tests/test_bug399284.html
@@ -99,18 +99,17 @@ function encodeUTF16LE(string)
     }
     return encodedString;
 }
 
 function testFontSize(frame)
 {
     var iframeDoc = SpecialPowers.wrap($(frame)).contentDocument;
     var size = parseInt(iframeDoc.defaultView.
-                getComputedStyle(iframeDoc.getElementById("testPara"), 
-                                 null).
+                getComputedStyle(iframeDoc.getElementById("testPara")).
                 getPropertyValue("font-size"));
     ok(size > 0, "font size assigned for " + frame);
 }
 </script>
 </pre>
 </body>
 </html>
 
--- a/layout/generic/test/test_bug344830.html
+++ b/layout/generic/test/test_bug344830.html
@@ -17,17 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
          type="image/svg+xml"
          src="bug344830_testembed.svg">
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 344830 **/
 function getSVG() {
- var embed = document.embeds["svg1"];
+ var embed = document.embeds.svg1;
  var svgDocument = embed.getSVGDocument();
  var element = svgDocument.getElementById("g1");
  ok(embed, "document.embeds[] works with SVG");
  ok(svgDocument, "document.embeds[] works with SVG and embed.getSVGDocument()");
  ok(element, "document.embeds[] works with SVG and svgDocument.getElementById()");
  SimpleTest.finish();
 }
 addLoadEvent(getSVG);
--- a/layout/generic/test/test_dynamic_reflow_root_disallowal.html
+++ b/layout/generic/test/test_dynamic_reflow_root_disallowal.html
@@ -621,17 +621,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     gFBody.appendChild(mozBox);
 
     // Note: This "is()" check is just validating that we're testing what we
     // intend to be testing. Eventually, we'll remove support for -moz-box
     // (as part of XUL), at which point this "is" check will start failing
     // and we'll probably want to remove this test function, along with the
     // IsXULBoxFrame() check that this test function is targeting in
     // ReflowInput::InitDynamicReflowRoot.
-    is(gFWindow.getComputedStyle(mozBox, "").display, "-moz-box",
+    is(gFWindow.getComputedStyle(mozBox).display, "-moz-box",
        "'display:-moz-box' should be honored and show up in computed style");
 
     let tweakFunc = function() {
       inner.style.width = inner.style.height = "40px";
     };
     tweakAndCompareSnapshots(tweakFunc, "child-of-moz-box");
 
     mozBox.remove(); // clean up
--- a/layout/mathml/tests/test_bug553917.html
+++ b/layout/mathml/tests/test_bug553917.html
@@ -73,23 +73,21 @@ https://bugzilla.mozilla.org/show_bug.cg
                           "AttributeParsingErrorNoTag","LengthParsingError", "MMultiscriptsErrors",
                           "UnitlessValuesAreDeprecated"];
       
       function getErrorMessage(name,idx)
       {
         if (name != "MMultiscriptsErrors") {
           var formatParams = g_errorInfo[name].args[idx];
           if (formatParams.length > 0) {
-            return g_bundl.formatStringFromName(name,formatParams);
-          } else {
-            return g_bundl.GetStringFromName(name);
-          }
-        } else {
-          return g_bundl.GetStringFromName(g_errorInfo[name].args[idx]);
+              return g_bundl.formatStringFromName(name,formatParams);
+          } 
+          return g_bundl.GetStringFromName(name);
         }
+        return g_bundl.GetStringFromName(g_errorInfo[name].args[idx]);
       }
     
     /** Checks the roll call to see if all expected error messages were present. */
     function processRollCall()
     {
       for (var i=0; i<g_errorTypes.length;i++) {
         for (var j = 0; j < g_errorInfo[g_errorTypes[i]].status.length; j++) {
           ok(g_errorInfo[g_errorTypes[i]].status[j],
--- a/layout/mathml/tests/test_bug827713-2.html
+++ b/layout/mathml/tests/test_bug827713-2.html
@@ -32,19 +32,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       
       var g_errorTypes = ["InvalidChild", "MMultiscriptsErrors"];
       
       function getErrorMessage(name,idx)
       {
         if (name != "MMultiscriptsErrors") {
           return g_bundl.formatStringFromName(name,g_errorInfo[name].args[idx]);
         }
-        else {
-          return g_bundl.GetStringFromName(g_errorInfo[name].args[idx]);
-        }
+        return g_bundl.GetStringFromName(g_errorInfo[name].args[idx]);
       }
     
     /** Checks the roll call to see if all expected error messages were present. */
     function processRollCall()
     {
       for (var i=0; i<g_errorTypes.length;i++) {
         for (var j = 0; j < g_errorInfo[g_errorTypes[i]].status.length; j++) {
           ok(g_errorInfo[g_errorTypes[i]].status[j],
--- a/layout/style/test/animation_utils.js
+++ b/layout/style/test/animation_utils.js
@@ -390,21 +390,20 @@ function runOMTATest(aTestFunction, aOnS
       var next;
       try {
         next = generator.next(arg);
       } catch (e) {
         return Promise.reject(e);
       }
       if (next.done) {
         return Promise.resolve(next.value);
-      } else {
-        return Promise.resolve(next.value).then(step, function(err) {
-          throw err;
-        });
       }
+      return Promise.resolve(next.value).then(step, function(err) {
+        throw err;
+      });
     }
 
     // Put refresh driver under test control
     SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(0);
 
     // Run test
     var promise = aTestFunc();
     if (!promise.then) {
@@ -690,19 +689,18 @@ const ExpectComparisonTo = {
   //  { a: 1, ty: 23 } etc.
   window.convertTo3dMatrix = function(matrixLike) {
     if (typeof matrixLike == "string") {
       return convertStringTo3dMatrix(matrixLike);
     } else if (Array.isArray(matrixLike)) {
       return convertArrayTo3dMatrix(matrixLike);
     } else if (typeof matrixLike == "object") {
       return convertObjectTo3dMatrix(matrixLike);
-    } else {
-      return null;
     }
+    return null;
   };
 
   // In future most of these methods should be able to be replaced
   // with DOMMatrix
   window.isInvertible = function(matrix) {
     return getDeterminant(matrix) != 0;
   };
 
@@ -742,19 +740,18 @@ const ExpectComparisonTo = {
       });
     } else if (array.length == 16) {
       return [
         array.slice(0, 4),
         array.slice(4, 8),
         array.slice(8, 12),
         array.slice(12, 16),
       ];
-    } else {
-      return null;
     }
+    return null;
   }
 
   // Return the first defined value in args.
   function defined(...args) {
     return args.find(arg => typeof arg !== "undefined");
   }
 
   // Takes an object of the form { a: 1.1, e: 23 } and builds up a 3d matrix
@@ -792,27 +789,26 @@ const ExpectComparisonTo = {
           matrix[0][1],
           matrix[1][0],
           matrix[1][1],
           matrix[3][0],
           matrix[3][1],
         ].join(", ") +
         ")"
       );
-    } else {
-      return (
-        "matrix3d(" +
-        matrix
-          .reduce(function(outer, inner) {
-            return outer.concat(inner);
-          })
-          .join(", ") +
-        ")"
-      );
     }
+    return (
+      "matrix3d(" +
+      matrix
+        .reduce(function(outer, inner) {
+          return outer.concat(inner);
+        })
+        .join(", ") +
+      ")"
+    );
   }
 
   function is2d(matrix) {
     return (
       matrix[0][2] === 0 &&
       matrix[0][3] === 0 &&
       matrix[1][2] === 0 &&
       matrix[1][3] === 0 &&
--- a/layout/style/test/bug1382568-iframe.html
+++ b/layout/style/test/bug1382568-iframe.html
@@ -1,8 +1,8 @@
 <!doctype html>
 <iframe src="http://example.com/doesnt-matter-because-it-gets-blocked-due-to-mixed-content"></iframe>
 <script>
 window.addEventListener('load', function(){
   window[0].document.body.innerText;
   window.parent.postMessage({ result: "ok" }, "*");
-}, false);
+});
 </script>
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -1,9 +1,10 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* eslint-disable dot-notation */
 /* vim: set ts=2 sw=2 sts=2 et: */
 /* 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/. */
 
 // Utility function. Returns true if the given boolean pref...
 //  (a) exists and (b) is set to true.
 // Otherwise, returns false.
--- a/layout/style/test/test_flexbox_order.html
+++ b/layout/style/test/test_flexbox_order.html
@@ -170,17 +170,17 @@ function main() {
   initRefSnapshots();
 
   // un-hide the flex container's parent
   let flexContainerParent = document.getElementById("flexContainerParent");
   flexContainerParent.style.display = "block";
 
   // Initial sanity-check: should be in expected document order
   let initialSnapshot = snapshotWindow(window, false);
-  complainIfSnapshotsDiffer(initialSnapshot, gRefSnapshots["abc"],
+  complainIfSnapshotsDiffer(initialSnapshot, gRefSnapshots.abc,
                             "initial flex container rendering, " +
                             "no 'order' value yet");
 
   // OK, now we run our tests
   gOrderTestcases.forEach(runOrderTestcase);
 
   // Re-hide the flex container at the end
   flexContainerParent.style.display = "";
--- a/layout/style/test/test_flexbox_order_abspos.html
+++ b/layout/style/test/test_flexbox_order_abspos.html
@@ -193,17 +193,17 @@ function main() {
   initRefSnapshots();
 
   // un-hide the flex container's parent
   let flexContainerParent = document.getElementById("flexContainerParent");
   flexContainerParent.style.display = "block";
 
   // Initial sanity-check: should be in expected document order
   let initialSnapshot = snapshotWindow(window, false);
-  complainIfSnapshotsDiffer(initialSnapshot, gRefSnapshots["abc"],
+  complainIfSnapshotsDiffer(initialSnapshot, gRefSnapshots.abc,
                             "initial flex container rendering, " +
                             "no 'order' value yet");
 
   // OK, now we run our tests
   gOrderTestcases.forEach(runOrderTestcase);
 
   // Re-hide the flex container at the end
   flexContainerParent.style.display = "";
--- a/layout/style/test/test_flexbox_order_table.html
+++ b/layout/style/test/test_flexbox_order_table.html
@@ -174,17 +174,17 @@ function main() {
   initRefSnapshots();
 
   // un-hide the flex container's parent
   let flexContainerParent = document.getElementById("flexContainerParent");
   flexContainerParent.style.display = "block";
 
   // Initial sanity-check: should be in expected document order
   let initialSnapshot = snapshotWindow(window, false);
-  complainIfSnapshotsDiffer(initialSnapshot, gRefSnapshots["abc"],
+  complainIfSnapshotsDiffer(initialSnapshot, gRefSnapshots.abc,
                             "initial flex container rendering, " +
                             "no 'order' value yet");
 
   // OK, now we run our tests
   gOrderTestcases.forEach(runOrderTestcase);
 
   // Re-hide the flex container at the end
   flexContainerParent.style.display = "";
--- a/layout/style/test/test_garbage_at_end_of_declarations.html
+++ b/layout/style/test/test_garbage_at_end_of_declarations.html
@@ -13,18 +13,20 @@
 <div id="content" style="display: none">
 
 <div id="testnode"></div>
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
+/* eslint-disable dot-notation */
 /** Test for correct ExpectEndProperty calls in CSS parser **/
 
+
 /*
  * Inspired by review comments on bug 378217.
  *
  * The original idea was to test that ExpectEndProperty calls are made
  * in the correct places in the CSS parser so that we don't accept
  * garbage at the end of property values.
  *
  * However, there's actually other code (in ParseDeclaration) that
--- a/layout/style/test/test_position_float_display.html
+++ b/layout/style/test/test_position_float_display.html
@@ -93,16 +93,16 @@ function test_display_value(val)
         "Element display should be converted when absolutely positioned");
     is(posFixedConversion, mapping[val],
         "Element display should be converted when fixed positioned");
   } else {
     ok(false, "missing rules for display value " + val);
   }
 }
 
-var displayInfo = gCSSProperties["display"];
+var displayInfo = gCSSProperties.display;
 displayInfo.initial_values.forEach(test_display_value);
 displayInfo.other_values.forEach(test_display_value);
 
 </script>
 </pre>
 </body>
 </html>
--- a/layout/style/test/test_root_node_display.html
+++ b/layout/style/test/test_root_node_display.html
@@ -52,16 +52,16 @@ function test_display_value(val)
        "http://dev.w3.org/csswg/css-display/#transformations");
   } else {
     is(rootConversion, floatConversion,
        "root node should make 'display:" + val + "' compute to the same " +
        "value that it computes to on a floated element");
   }
 }
 
-var displayInfo = gCSSProperties["display"];
+var displayInfo = gCSSProperties.display;
 displayInfo.initial_values.forEach(test_display_value);
 displayInfo.other_values.forEach(test_display_value);
 
 </script>
 </pre>
 </body>
 </html>
--- a/layout/style/test/test_transitions.html
+++ b/layout/style/test/test_transitions.html
@@ -637,17 +637,17 @@ add_future_call(2, check_descendant_test
 add_future_call(6, check_descendant_tests);
 
 function check_descendant_tests() {
     // text-indent: transition from 50px to 150px
     // letter-spacing: transition from 10px to 5px
     var values = {};
     values["text-indent"] = [ 50, 150 ];
     values["letter-spacing"] = [ 10, 5 ];
-    let tf = timingFunctions["ease"];
+    let tf = timingFunctions.ease;
 
     var time = px_to_num(earlyrefcs.textIndent) / REF_PX_PER_SEC;
 
     for (let i in descendant_tests) {
         let test = descendant_tests[i];
 
         /* ti=text-indent, ls=letter-spacing */
         var child_ti_duration = 0;
@@ -716,17 +716,17 @@ function check_descendant_tests() {
                                    test.childCS.getPropertyValue(prop),
                                    `descendant test #${Number(i)+1}, property ${prop}`);
         }
     }
 }
 
 function check_number_tests()
 {
-    let tf = timingFunctions["ease"];
+    let tf = timingFunctions.ease;
     for (let d in number_tests) {
         let test = number_tests[d];
         let p = test.node;
 
         check_transition_value(tf, 0, 8, 100, 50,
                                getComputedStyle(p, "").marginLeft,
                                "number of transitions test for style " +
                                  test.style);
--- a/layout/style/test/test_transitions_events.html
+++ b/layout/style/test/test_transitions_events.html
@@ -237,27 +237,27 @@ started_test(); // #seven::after (listen
 $("seven").setAttribute("foo", "bar");
 
 $("five").addEventListener("transitionstart", function() {
   if (cs("five").color == "rgb(0, 255, 0)") {
     // The transition has finished already.
     did_finish_five = true;
   }
   $("five").style.transitionProperty = "margin-left";
-}, false);
+});
 
 $("six").addEventListener("transitionstart", function() {
   if (cs("six").color == "rgb(0, 255, 0)") {
     // The transition has finished already.
     did_finish_six = true;
   }
   $("six").style.transitionDuration = "0s";
   $("six").style.transitionDelay = "0s";
   $("six").style.color = "blue";
-}, false);
+});
 
 function poll_start_reversal() {
   if (cs("four").color != "rgb(0, 0, 255)") {
     // The forward transition has started.
     $("four").style.color = "blue";
   } else {
     // The forward transition has not started yet.
     setTimeout(poll_start_reversal, 20);
--- a/layout/style/test/test_transitions_per_property.html
+++ b/layout/style/test/test_transitions_per_property.html
@@ -37,16 +37,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="transformTest" style="height:100px; width:200px; background-color:blue;">
 </div>
 
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /* eslint no-shadow: ["error", {"allow": ["prop", "div"]}] */
+/* eslint-disable dot-notation */
+
 
 /** Test for Bug 435441 **/
 
 SimpleTest.requestLongerTimeout(2);
 SimpleTest.waitForExplicitFinish();
 
 function has_num(str)
 {
@@ -1825,20 +1827,19 @@ function test_shape_or_url_equals(comput
       ok(false, "expected reference box");
       return false;
     }
   }
   computedValStr = matches[0];
   if (expectedList.length == 0) {
     if (computedValStr == "") {
       return true;
-    } else {
-      ok(false, "expected basic shape");
-      return false;
-    }
+    } 
+    ok(false, "expected basic shape");
+    return false;
   }
 
   // The regular expression does not filter out the last parenthesis.
   // Remove last character for now.
   is(computedValStr.substring(computedValStr.length - 1, computedValStr.length),
                               ')', "Function should have close-paren");
   computedValStr = computedValStr.substring(0, computedValStr.length - 1);
 
--- a/layout/xul/test/test_bug381167.xhtml
+++ b/layout/xul/test/test_bug381167.xhtml
@@ -31,17 +31,17 @@ function closeit() {
                                  evt.initKeyEvent('keypress', true, true,
                                  window,
                                  true, false, false, false,
                                  'W'.charCodeAt(0), 0);
   window.dispatchEvent(evt);
 
   setTimeout(finish, 200);
 }
-window.addEventListener('load', closeit, false);
+window.addEventListener('load', closeit);
 
 function finish()
 {
   ok(true, "This is a mochikit version of a crash test. To complete is to pass.");
   SimpleTest.finish();
 }
 </script>
 </pre>