Bug 1481932 - Fully enable ESLint rule mozilla/reject-requires-await. r=mossop
authorMark Banner <standard8@mozilla.com>
Sat, 11 Aug 2018 07:27:35 +0000
changeset 486163 8dadac023d15cce16284e5ebb533b5b267cb552e
parent 486162 1ceb97675d5671a58ce33e9fb9be2129e24ea4a5
child 486164 ef30529d43dd59e449b31b085efef98b8891c16d
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1481932
milestone63.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 1481932 - Fully enable ESLint rule mozilla/reject-requires-await. r=mossop MozReview-Commit-ID: 7pYfD6Ax5VX Differential Revision: https://phabricator.services.mozilla.com/D2971
.eslintrc.js
toolkit/components/extensions/test/xpcshell/test_ext_debugging_utils.js
toolkit/components/extensions/test/xpcshell/test_ext_schemas_async.js
toolkit/components/normandy/test/browser/browser_AddonStudies.js
toolkit/components/normandy/test/browser/browser_BaseAction.js
toolkit/components/osfile/tests/xpcshell/test_osfile_win_async_setPermissions.js
toolkit/components/places/tests/bookmarks/test_bookmarks_update.js
toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js
toolkit/components/satchel/test/unit/test_history_api.js
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -34,20 +34,10 @@ module.exports = {
       "browser/base/content/urlbarBindings.xml",
       "browser/components/search/content/search.xml",
       "browser/components/translation/translation-infobar.xml",
       "toolkit/components/prompts/content/tabprompts.xml"
     ],
     "env": {
       "mozilla/browser-window": true
     }
-  }, {
-    // XXX Bug 1452706. These directories are still being fixed, so turn off
-    //  mozilla/require-expected-throws-or-rejects for now.
-    "files": [
-      "services/fxaccounts/**",
-      "toolkit/components/**",
-    ],
-    "rules": {
-      "mozilla/rejects-requires-await": "off",
-    }
   }]
 };
--- a/toolkit/components/extensions/test/xpcshell/test_ext_debugging_utils.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_debugging_utils.js
@@ -55,18 +55,18 @@ add_task(async function testExtensionDeb
   equal(debugBrowserPromises.size, 1, "The expected resources has been allocated");
 
   const nonExistentAddonActor = {
     addonId: "non-existent-addon@test",
   };
 
   const waitRejection = ExtensionParent.DebugUtils.getExtensionProcessBrowser(nonExistentAddonActor);
 
-  Assert.rejects(waitRejection, /Extension not found/,
-                 "Reject with the expected message for non existent addons");
+  await Assert.rejects(waitRejection, /Extension not found/,
+                       "Reject with the expected message for non existent addons");
 
   equal(debugBrowserPromises.size, 1, "No additional debugging resources has been allocated");
 
   await ExtensionParent.DebugUtils.releaseExtensionProcessBrowser(fakeAddonActor);
 
   equal(debugBrowserPromises.size, 1,
         "The addon debugging browser is cached until all the related actors have released it");
 
--- a/toolkit/components/extensions/test/xpcshell/test_ext_schemas_async.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_schemas_async.js
@@ -268,19 +268,19 @@ add_task(async function testAsyncResults
       }, {
         async_required() { return makeError("ONE"); },
         async_optional() { return makeError("TWO"); },
       });
 
       if (!isChromeCompat) { // No promises for chrome.
         await Assert.rejects(
           testnamespace.async_required(), /ONE/,
-          "should reject testnamespace.async_required()").catch(() => {});
+          "should reject testnamespace.async_required()");
         await Assert.rejects(
           testnamespace.async_optional(), /TWO/,
-          "should reject testnamespace.async_optional()").catch(() => {});
+          "should reject testnamespace.async_optional()");
       }
 
       Assert.equal(await runFailCallback(testnamespace.async_required), "ONE");
       Assert.equal(await runFailCallback(testnamespace.async_optional), "TWO");
     }
   }
 });
--- a/toolkit/components/normandy/test/browser/browser_AddonStudies.js
+++ b/toolkit/components/normandy/test/browser/browser_AddonStudies.js
@@ -114,30 +114,30 @@ decorate_task(
   }
 );
 
 add_task(async function testStartRequiredArguments() {
   const requiredArguments = startArgsFactory();
   for (const key in requiredArguments) {
     const args = Object.assign({}, requiredArguments);
     delete args[key];
-    Assert.rejects(
+    await Assert.rejects(
       AddonStudies.start(args),
       /Required arguments/,
       `start rejects when missing required argument ${key}.`
     );
   }
 });
 
 decorate_task(
   AddonStudies.withStudies([
     studyFactory(),
   ]),
   async function testStartExisting([study]) {
-    Assert.rejects(
+    await Assert.rejects(
       AddonStudies.start(startArgsFactory({recipeId: study.recipeId})),
       /already exists/,
       "start rejects when a study exists with the given recipeId already."
     );
   }
 );
 
 decorate_task(
--- a/toolkit/components/normandy/test/browser/browser_BaseAction.js
+++ b/toolkit/components/normandy/test/browser/browser_BaseAction.js
@@ -101,17 +101,17 @@ decorate_task(
   async function(reportRecipeStub) {
     const action = new NoopAction();
     const recipe1 = recipeFactory();
     const recipe2 = recipeFactory();
 
     await action.runRecipe(recipe1);
     await action.finalize();
 
-    Assert.rejects(
+    await Assert.rejects(
       action.runRecipe(recipe2),
       /^Error: Action has already been finalized$/,
       "running recipes after finalization is an error",
     );
 
     Assert.deepEqual(
       reportRecipeStub.args,
       [[recipe1.id, Uptake.RECIPE_SUCCESS]],
--- a/toolkit/components/osfile/tests/xpcshell/test_osfile_win_async_setPermissions.js
+++ b/toolkit/components/osfile/tests/xpcshell/test_osfile_win_async_setPermissions.js
@@ -82,29 +82,29 @@ add_task(async function test_file_setPer
     await OS.File.remove(path);
   }
 });
 
 // Test application to Check setPermissions on a non-existant file path.
 add_task(async function test_non_existant_file_path_setPermissions() {
   let path = OS.Path.join(OS.Constants.Path.tmpDir,
                           "test_osfile_win_async_setPermissions_path.tmp");
-  Assert.rejects(OS.File.setPermissions(path, {winAttributes: {readOnly: true}}),
-                 /The system cannot find the file specified/,
-                 "setPermissions failed as expected on a non-existant file path");
+  await Assert.rejects(OS.File.setPermissions(path, {winAttributes: {readOnly: true}}),
+                       /The system cannot find the file specified/,
+                       "setPermissions failed as expected on a non-existant file path");
 });
 
 // Test application to Check setPermissions on a invalid file handle.
 add_task(async function test_closed_file_handle_setPermissions() {
   let path = OS.Path.join(OS.Constants.Path.tmpDir,
                           "test_osfile_win_async_setPermissions_path.tmp");
   await OS.File.writeAtomic(path, new Uint8Array(1));
 
   try {
     let fd = await OS.File.open(path, { write: true });
     await fd.close();
-    Assert.rejects(fd.setPermissions(path, {winAttributes: {readOnly: true}}),
-                   /The handle is invalid/,
-                   "setPermissions failed as expected on a invalid file handle");
+    await Assert.rejects(fd.setPermissions(path, {winAttributes: {readOnly: true}}),
+                         /The handle is invalid/,
+                         "setPermissions failed as expected on a invalid file handle");
   } finally {
     await OS.File.remove(path);
   }
 });
--- a/toolkit/components/places/tests/bookmarks/test_bookmarks_update.js
+++ b/toolkit/components/places/tests/bookmarks/test_bookmarks_update.js
@@ -80,17 +80,17 @@ add_task(async function invalid_input_th
 
 add_task(async function move_roots_fail() {
   let guids = [PlacesUtils.bookmarks.unfiledGuid,
                PlacesUtils.bookmarks.menuGuid,
                PlacesUtils.bookmarks.toolbarGuid,
                PlacesUtils.bookmarks.tagsGuid,
                PlacesUtils.bookmarks.mobileGuid];
   for (let guid of guids) {
-    Assert.rejects(PlacesUtils.bookmarks.update({
+    await Assert.rejects(PlacesUtils.bookmarks.update({
       guid,
       index: -1,
       parentGuid: PlacesUtils.bookmarks.unfiledGuid,
     }), /It's not possible to move Places root folders\./,
     `Should reject when attempting to move ${guid}`);
   }
 });
 
--- a/toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js
+++ b/toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js
@@ -223,17 +223,17 @@ add_task(async function test_html_restor
     data:       NSIOBSERVER_DATA_HTML,
     folderId:   null
   };
   let expectPromises = registerObservers(false);
 
   info("HTML restore: nonexistent file should fail");
   let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
   file.append("this file doesn't exist because nobody created it 2");
-  Assert.rejects(BookmarkHTMLUtils.importFromFile(file.path),
+  await Assert.rejects(BookmarkHTMLUtils.importFromFile(file.path),
     /Cannot import from nonexisting html file/, "Restore should reject for a non-existent file.");
 
   await checkObservers(expectPromises, expectedData);
   await teardown(file);
 });
 
 add_task(async function test_html_init_restore_normal() {
   let expectedData = {
@@ -283,14 +283,14 @@ add_task(async function test_html_init_r
     data:       NSIOBSERVER_DATA_HTML_INIT,
     folderId:   null
   };
   let expectPromises = registerObservers(false);
 
   info("HTML initial restore: nonexistent file should fail");
   let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
   file.append("this file doesn't exist because nobody created it 3");
-  Assert.rejects(BookmarkHTMLUtils.importFromFile(file.path, { replace: true }),
+  await Assert.rejects(BookmarkHTMLUtils.importFromFile(file.path, { replace: true }),
     /Cannot import from nonexisting html file/, "Restore should reject for a non-existent file.");
 
   await checkObservers(expectPromises, expectedData);
   await teardown(file);
 });
--- a/toolkit/components/satchel/test/unit/test_history_api.js
+++ b/toolkit/components/satchel/test/unit/test_history_api.js
@@ -378,36 +378,36 @@ add_task(async function() {
 
     // ===== 21 =====
     // Check update fails if form history is disabled and the operation is not a
     // pure removal.
     testnum++;
     Services.prefs.setBoolPref("browser.formfill.enable", false);
 
     // Cannot use arrow functions, see bug 1237961.
-    Assert.rejects(promiseUpdate(
+    await Assert.rejects(promiseUpdate(
       { op: "bump", fieldname: "field5", value: "value5" }),
-                   function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
-                   "bumping when form history is disabled should fail");
-    Assert.rejects(promiseUpdate(
+                         function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
+                         "bumping when form history is disabled should fail");
+    await Assert.rejects(promiseUpdate(
       { op: "add", fieldname: "field5", value: "value5" }),
-                   function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
-                   "Adding when form history is disabled should fail");
-    Assert.rejects(promiseUpdate([
+                         function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
+                         "Adding when form history is disabled should fail");
+    await Assert.rejects(promiseUpdate([
       { op: "update", fieldname: "field5", value: "value5" },
       { op: "remove", fieldname: "field5", value: "value5" },
     ]),
-                   function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
-                   "mixed operations when form history is disabled should fail");
-    Assert.rejects(promiseUpdate([
+                         function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
+                         "mixed operations when form history is disabled should fail");
+    await Assert.rejects(promiseUpdate([
       null, undefined, "", 1, {},
       { op: "remove", fieldname: "field5", value: "value5" },
     ]),
-                   function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
-                   "Invalid entries when form history is disabled should fail");
+                         function(err) { return err.result == Ci.mozIStorageError.MISUSE; },
+                         "Invalid entries when form history is disabled should fail");
 
     // Remove should work though.
     await promiseUpdate([{ op: "remove", fieldname: "field5", value: null },
       { op: "remove", fieldname: null, value: null }]);
     Services.prefs.clearUserPref("browser.formfill.enable");
   } catch (e) {
     throw new Error(`FAILED in test #${testnum} -- ${e}`);
   } finally {