Bug 1544285 - tools/ automated ESLint no-throw-literal fixes. r=dbaron
authorIan Moody <moz-ian@perix.co.uk>
Tue, 16 Apr 2019 15:02:05 +0000
changeset 469812 331387fa113c0e34e5405a558161f7f0512a9973
parent 469811 64a7117d226073ad5d41bc3fd2935ceed45a2efe
child 469813 64e6baec51501e1ebab151e9d317fa68ea3d7dbd
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1544285
milestone68.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 1544285 - tools/ automated ESLint no-throw-literal fixes. r=dbaron Result of running: $ mach eslint -funix tools/ | sed -Ee 's/:.+//' - | xargs sed -E \ -e 's/throw ((["`])[^"]+\2);/throw new Error(\1);/g' \ -e 's/throw ((["`])[^"]+\2 \+ [^ ";]+);/throw new Error(\1);/g' \ -e 's/throw \(/throw new Error(/g' -i Differential Revision: https://phabricator.services.mozilla.com/D27450
.eslintrc.js
tools/leak-gauge/leak-gauge.html
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -82,17 +82,16 @@ module.exports = {
     // TODO: Bug 1515949. Enable no-undef for gfx/
     "files": "gfx/layers/apz/test/mochitest/**",
     "rules": {
       "no-undef": "off",
     }
   }, {
     // TODO: Bug 1246594. Empty this list once the rule has landed for all dirs
     "files": [
-      "tools/leak-gauge/leak-gauge.html",
       "xpcom/tests/unit/test_iniParser.js",
     ],
     "rules": {
       "no-throw-literal": "off",
     }
   }, {
     ...removeOverrides(xpcshellTestConfig),
     "files": xpcshellTestPaths.map(path => `${path}**`),
--- a/tools/leak-gauge/leak-gauge.html
+++ b/tools/leak-gauge/leak-gauge.html
@@ -39,25 +39,25 @@ function runContents(result, contents) {
                 var match = line.match(/^([0-9a-f]*) (\S*)(.*)/);
                 if (match) {
                     var addr = match[1];
                     var verb = match[2];
                     var rest = match[3];
                     if (verb == "created") {
                         let m = rest.match(/ outer=([0-9a-f]*)$/);
                         if (!m)
-                            throw "outer expected";
+                            throw new Error("outer expected");
                         this.windows[addr] = { outer: m[1] };
                         ++this.count;
                     } else if (verb == "destroyed") {
                         delete this.windows[addr];
                     } else if (verb == "SetNewDocument") {
                         let m = rest.match(/^ (.*)$/);
                         if (!m)
-                            throw "URI expected";
+                            throw new Error("URI expected");
                         this.windows[addr][m[1]] = true;
                     }
                 }
             },
             dump() {
                 for (var addr in this.windows) {
                     var winobj = this.windows[addr];
                     var outer = winobj.outer;
@@ -89,17 +89,17 @@ function runContents(result, contents) {
                         this.docs[addr] = {};
                         ++this.count;
                     } else if (verb == "destroyed") {
                         delete this.docs[addr];
                     } else if (verb == "ResetToURI" ||
                                verb == "StartDocumentLoad") {
                         var m = rest.match(/^ (.*)$/);
                         if (!m)
-                            throw "URI expected";
+                            throw new Error("URI expected");
                         var uri = m[1];
                         var doc_info = this.docs[addr];
                         doc_info[uri] = true;
                         if ("nim" in doc_info) {
                             doc_info.nim[uri] = true;
                         }
                     }
                 }
@@ -133,17 +133,17 @@ function runContents(result, contents) {
                         this.shells[addr] = {};
                         ++this.count;
                     } else if (verb == "destroyed") {
                         delete this.shells[addr];
                     } else if (verb == "InternalLoad" ||
                                verb == "SetCurrentURI") {
                         var m = rest.match(/^ (.*)$/);
                         if (!m)
-                            throw "URI expected";
+                            throw new Error("URI expected");
                         this.shells[addr][m[1]] = true;
                     }
                 }
             },
             dump() {
                 for (var addr in this.shells) {
                     var doc = this.shells[addr];
                     result += "Leaked docshell at address " + addr + ".\n";
@@ -169,17 +169,17 @@ function runContents(result, contents) {
                     if (verb == "created") {
                         this.nims[addr] = {};
                         ++this.count;
                     } else if (verb == "destroyed") {
                         delete this.nims[addr];
                     } else if (verb == "Init") {
                         var m = rest.match(/^ document=(.*)$/);
                         if (!m)
-                            throw "document pointer expected";
+                            throw new Error("document pointer expected");
                         var nim_info = this.nims[addr];
                         var doc = m[1];
                         if (doc != "0") {
                             var doc_info = handlers.DOCUMENT.docs[doc];
                             for (var uri in doc_info) {
                                 nim_info[uri] = true;
                             }
                             doc_info.nim = nim_info;