Bug 1554142 - Enable most ESLint rules for image/. r=aosmond
authorMark Banner <standard8@mozilla.com>
Fri, 24 May 2019 17:34:09 +0000
changeset 475437 6a7048b0d26a2448224e95dc8f415e6231a3cd00
parent 475436 ef6ae0e3591f45d5c29012bf8631bde8cb4f889f
child 475438 f7878bcedd304604b0b5612ded8d480756e9f3dd
push id113209
push useraciure@mozilla.com
push dateSat, 25 May 2019 09:44:12 +0000
treeherdermozilla-inbound@af54b2de7028 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond
bugs1554142
milestone69.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 1554142 - Enable most ESLint rules for image/. r=aosmond Depends on D32450 Differential Revision: https://phabricator.services.mozilla.com/D32493
.eslintignore
.eslintrc.js
image/test/mochitest/animationPolling.js
image/test/mochitest/test_animation_operators.html
image/test/mochitest/test_bug490949.html
image/test/mochitest/test_bug496292.html
image/test/mochitest/test_net_failedtoprocess.html
image/test/unit/async_load_tests.js
image/test/unit/test_encoder_png.js
image/test/unit/test_imgtools.js
image/test/unit/test_private_channel.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -9,17 +9,16 @@
 **/reftests/**
 
 # Exclude expected objdirs.
 obj*/**
 
 # We ignore all these directories by default, until we get them enabled.
 # If you are enabling a directory, please add directory specific exclusions
 # below.
-image/**
 layout/**
 netwerk/cookie/test/browser/**
 netwerk/test/browser/**
 netwerk/test/mochitests/**
 netwerk/test/unit*/**
 startupcache/**
 
 # We currently have no js files in these directories, so we ignore them by
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -153,13 +153,45 @@ module.exports = {
       "no-tabs": "off",
       "no-mixed-spaces-and-tabs": "off",
       "no-multi-spaces": "off",
       "no-trailing-spaces": "off",
       "padded-blocks": "off",
       "quotes": "off",
       "semi": "off",
       "space-infix-ops": "off",
+    }
+  }, {
+    "files": [
+      "image/**",
+    ],
+    "rules": {
+      "mozilla/consistent-if-bracing": "off",
+      "mozilla/use-chromeutils-generateqi": "off",
+      "mozilla/use-services": "off",
+      "no-array-constructor": "off",
+      "no-implied-eval": "off",
+      "no-redeclare": "off",
+      "no-self-assign": "off",
+      "no-throw-literal": "off",
+      "no-undef": "off",
+      "no-unneeded-ternary": "off",
+      "no-unused-vars": "off",
 
-
+      // Not enabling the rules below for now pending prettier roll-out.
+      "brace-style": "off",
+      "comma-dangle": "off",
+      "comma-spacing": "off",
+      "key-spacing": "off",
+      "keyword-spacing": "off",
+      "no-extra-semi": "off",
+      "no-tabs": "off",
+      "no-mixed-spaces-and-tabs": "off",
+      "no-multi-spaces": "off",
+      "no-trailing-spaces": "off",
+      "padded-blocks": "off",
+      "quotes": "off",
+      "semi": "off",
+      "space-before-function-paren": "off",
+      "space-infix-ops": "off",
     }
   }]
 };
--- a/image/test/mochitest/animationPolling.js
+++ b/image/test/mochitest/animationPolling.js
@@ -224,24 +224,22 @@ AnimationTest.prototype.setupPolledImage
 
     if (result[0]) {
       // SUCCESS!
       ok(true, "Animated image looks correct, at poll #"
          + this.pollCounter);
 
       this.cleanUpAndFinish();
     }
-  } else {
-    if (!gIsRefImageLoaded) {
+  } else if (!gIsRefImageLoaded) {
       this.myImage = new Image();
       this.myImage.onload = reuseImageCallback;
       document.getElementById(this.imageElementId).setAttribute('src',
         this.referenceElementId);
     }
-  }
 }
 
 AnimationTest.prototype.checkImage = function ()
 {
   if (this.isTestFinished) {
     return;
   }
 
--- a/image/test/mochitest/test_animation_operators.html
+++ b/image/test/mochitest/test_animation_operators.html
@@ -133,17 +133,17 @@ function startTest(i)
       }
     }
     function report(result)
     {
       ok(result, "(" + i + ") " +
                  testData.op + " " + testData.test + " " + testData.reference);
       RemoveFinishDependency();
     }
-    var iframe = { element: element, loaded: false };
+    var iframe = { element, loaded: false };
 
     return iframe;
   }
 
   AddFinishDependency();
   var test = startIframe(testData.test);
   var reference = startIframe(testData.reference);
 }
--- a/image/test/mochitest/test_bug490949.html
+++ b/image/test/mochitest/test_bug490949.html
@@ -39,33 +39,33 @@ RemoteCanvas.prototype.load = function(c
     iframe.id = "test-iframe";
     iframe.height = "10px";
     iframe.width = windowWidth + "px";
     iframe.style.visibility = "hidden";
     iframe.src = this.url;
     // Here is where the magic happens... add a listener to the
     // frame's onload event - it will call handleEvent
     iframe.addEventListener("load", this, true);
-    //append to the end of the page
+    // append to the end of the page
     window.document.body.appendChild(iframe);
 };
 
 RemoteCanvas.prototype.reload = function(cb, force) {
     this.cb = cb;
     window.frames[0].location.reload(force);
 }
 
 RemoteCanvas.prototype.handleEvent = function() {
     // Look back up the iframe by id
     var ldrFrame = document.getElementById("test-iframe");
     // Get a reference to the window object you need for the
     // SpecialPowers.snapshotRect method
     var remoteWindow = ldrFrame.contentWindow;
 
-    //Draw canvas
+    // Draw canvas
     canvas.style.width = RemoteCanvas.CANVAS_WIDTH + "px";
     canvas.style.height = RemoteCanvas.CANVAS_HEIGHT + "px";
     canvas.width = RemoteCanvas.CANVAS_WIDTH;
     canvas.height = RemoteCanvas.CANVAS_HEIGHT;
     var windowWidth = window.innerWidth - 25;
     var windowHeight = window.innerHeight;
 
     var rect = { left: 0, top: 0, width: windowWidth, height: windowHeight };
--- a/image/test/mochitest/test_bug496292.html
+++ b/image/test/mochitest/test_bug496292.html
@@ -39,33 +39,33 @@ RemoteCanvas.prototype.load = function(c
     iframe.id = "test-iframe-" + this.url;
     iframe.height = "10px";
     iframe.width = windowWidth + "px";
     iframe.style.visibility = "hidden";
     iframe.src = this.url;
     // Here is where the magic happens... add a listener to the
     // frame's onload event - it will call handleEvent
     iframe.addEventListener("load", this, true);
-    //append to the end of the page
+    // append to the end of the page
     window.document.body.appendChild(iframe);
 };
 
 RemoteCanvas.prototype.reload = function(cb, force) {
     this.cb = cb;
     window.frames[0].location.reload(force);
 }
 
 RemoteCanvas.prototype.handleEvent = function() {
     // Look back up the iframe by id
     var ldrFrame = document.getElementById("test-iframe-" + this.url);
     // Get a reference to the window object you need for the canvas
     // SpecialPowers.snapshotRect method
     var remoteWindow = ldrFrame.contentWindow;
 
-    //Draw canvas
+    // Draw canvas
     canvas.style.width = RemoteCanvas.CANVAS_WIDTH + "px";
     canvas.style.height = RemoteCanvas.CANVAS_HEIGHT + "px";
     canvas.width = RemoteCanvas.CANVAS_WIDTH;
     canvas.height = RemoteCanvas.CANVAS_HEIGHT;
     var windowWidth = window.innerWidth - 25;
     var windowHeight = window.innerHeight;
 
     var rect = { left: 0, top: 0, width: windowWidth, height: windowHeight };
--- a/image/test/mochitest/test_net_failedtoprocess.html
+++ b/image/test/mochitest/test_net_failedtoprocess.html
@@ -18,24 +18,24 @@ observer event with the nsIURI of the fa
 SimpleTest.waitForExplicitFinish();
 
 const Ci = SpecialPowers.Ci;
 const Cc = SpecialPowers.Cc;
 var obs = Cc["@mozilla.org/observer-service;1"].getService();
 obs = obs.QueryInterface(Ci.nsIObserverService);
 
 var observer = {
-  QueryInterface: function (aIID) {
+  QueryInterface (aIID) {
     if (aIID.equals(Ci.nsISupports) ||
         aIID.equals(Ci.nsIObserver))
       return this;
     throw Cr.NS_ERROR_NO_INTERFACE;
   },
 
-  observe: function(subject, topic, data) {
+  observe(subject, topic, data) {
     ok(topic == "net:failed-to-process-uri-content", "wrong topic");
     subject = subject.QueryInterface(Ci.nsIURI);
     is(subject.asciiSpec, "http://mochi.test:8888/tests/image/test/mochitest/invalid.jpg", "wrong subject");
 
     obs.removeObserver(this, "net:failed-to-process-uri-content");
 
     SimpleTest.finish();
   }
--- a/image/test/unit/async_load_tests.js
+++ b/image/test/unit/async_load_tests.js
@@ -35,17 +35,17 @@ function getCloneStopCallback(original_l
 
 // Make sure that cloned requests get all the same callbacks as the original,
 // but they aren't synchronous right now.
 function checkClone(other_listener, aRequest)
 {
   do_test_pending();
 
   // For as long as clone notification is synchronous, we can't test the clone state reliably.
-  var listener = new ImageListener(null, function(foo, bar) { do_test_finished(); } /*getCloneStopCallback(other_listener)*/);
+  var listener = new ImageListener(null, function(foo, bar) { do_test_finished(); } /* getCloneStopCallback(other_listener)*/);
   listener.synchronous = false;
   var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
                 .createScriptedObserver(listener);
   var clone = aRequest.clone(outer);
   requests.push({ request: clone, locked: false });
 }
 
 // Ensure that all the callbacks were called on aRequest.
@@ -118,17 +118,17 @@ function getChannelLoadImageStopCallback
   }
 }
 
 // Load the request a second time. This should come from the image cache, and
 // therefore would be at most risk of being served synchronously.
 function checkSecondChannelLoad()
 {
   do_test_pending();
-  var channel = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
+  var channel = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true});
   var channellistener = new ChannelListener();
   channel.asyncOpen(channellistener);
 
   var listener = new ImageListener(null,
                                    getChannelLoadImageStopCallback(channellistener,
                                                                    all_done_callback));
   var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
                 .createScriptedObserver(listener);
@@ -143,17 +143,17 @@ function checkSecondChannelLoad()
 }
 
 function run_loadImageWithChannel_tests()
 {
   // To ensure we're testing what we expect to, create a new loader and cache.
   gCurrentLoader = Cc["@mozilla.org/image/loader;1"].createInstance(Ci.imgILoader);
 
   do_test_pending();
-  var channel =  NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
+  var channel =  NetUtil.newChannel({uri, loadUsingSystemPrincipal: true});
   var channellistener = new ChannelListener();
   channel.asyncOpen(channellistener);
 
   var listener = new ImageListener(null,
                                    getChannelLoadImageStopCallback(channellistener,
                                                                    checkSecondChannelLoad));
   var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
                 .createScriptedObserver(listener);
--- a/image/test/unit/test_encoder_png.js
+++ b/image/test/unit/test_encoder_png.js
@@ -188,17 +188,17 @@ function makeDataURLFromAsync(encoder, m
 
         var bytes = [];
 
         var binarystream = Cc["@mozilla.org/binaryinputstream;1"].createInstance();
         binarystream.QueryInterface(Ci.nsIBinaryInputStream);
 
         var asyncReader =
         {
-            onInputStreamReady: function(stream)
+            onInputStreamReady(stream)
             {
                 binarystream.setInputStream(stream);
                 var available = 0;
                 try {
                   available = stream.available();
                 } catch(e) { }
 
                 if (available > 0)
--- a/image/test/unit/test_imgtools.js
+++ b/image/test/unit/test_imgtools.js
@@ -641,37 +641,37 @@ var testData =
      {preImage: "image1.png",
       preImageMimeType: "image/png",
       refImage: "image1png64x64.jpg",
       refImageMimeType: "image/jpeg"}];
 
 for(var i=0; i<testData.length; ++i) {
     var dict = testData[i];
 
-    var imgFile = do_get_file(dict["refImage"]);
+    var imgFile = do_get_file(dict.refImage);
     var istream = getFileInputStream(imgFile);
     var refBytes = streamToArray(istream);
 
-    imgFile = do_get_file(dict["preImage"]);
+    imgFile = do_get_file(dict.preImage);
     istream = getFileInputStream(imgFile);
 
     var buffer = NetUtil.readInputStreamToString(istream, istream.available());
     var container = imgTools.decodeImageFromBuffer(buffer, buffer.length,
-                                                   dict["preImageMimeType"]);
+                                                   dict.preImageMimeType);
 
-    istream = imgTools.encodeImage(container, dict["refImageMimeType"]);
+    istream = imgTools.encodeImage(container, dict.refImageMimeType);
 
     var sstream = Cc["@mozilla.org/storagestream;1"].
 	          createInstance(Ci.nsIStorageStream);
     sstream.init(4096, 4294967295, null);
     var ostream = sstream.getOutputStream(0);
     var bostream = Cc["@mozilla.org/network/buffered-output-stream;1"].
 	           createInstance(Ci.nsIBufferedOutputStream);
 
-    //use a tiny buffer to make sure the image data doesn't fully fit in it
+    // use a tiny buffer to make sure the image data doesn't fully fit in it
     bostream.init(ostream, 8);
 
     bostream.writeFrom(istream, istream.available());
     bostream.flush(); bostream.close();
 
     var encBytes = streamToArray(sstream.newInputStream(0));
 
     compareArrays(refBytes, encBytes);
--- a/image/test/unit/test_private_channel.js
+++ b/image/test/unit/test_private_channel.js
@@ -32,18 +32,18 @@ var listeners = [];
 
 var gImgPath = 'http://localhost:' + server.identity.primaryPort + '/image.png';
 
 function setup_chan(path, isPrivate, callback) {
   var uri = NetUtil.newURI(gImgPath);
   var securityFlags = Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
   var principal = Services.scriptSecurityManager
                           .createCodebasePrincipal(uri, {privateBrowsingId: isPrivate ? 1 : 0});
-  var chan =  NetUtil.newChannel({uri: uri, loadingPrincipal: principal,
-                                  securityFlags: securityFlags,
+  var chan =  NetUtil.newChannel({uri, loadingPrincipal: principal,
+                                  securityFlags,
                                   contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE});
   chan.notificationCallbacks = isPrivate ? privateLoadContext
                                          : nonPrivateLoadContext;
   var channelListener = new ChannelListener();
   chan.asyncOpen(channelListener);
 
   var listener = new ImageListener(null, callback);
   var outlistener = {};