Bug 1328804 - Enable the require-await rule for eslint and fix the four errors found by the rule by removing the 'async' keyword from the functions that arne't using await. r?kmag draft
authorJared Wein <jwein@mozilla.com>
Thu, 05 Jan 2017 00:46:20 -0500
changeset 456218 1212f952dce1e13228dcc4b2efac2c1e0701e5cc
parent 456217 0f7907193b38e39dce5b1021a6638d1554727c7e
child 456219 e0a4e5e782a42121db9d737ee65e3d8661209966
push id40430
push userbmo:jaws@mozilla.com
push dateThu, 05 Jan 2017 05:46:47 +0000
reviewerskmag
bugs1328804
milestone53.0a1
Bug 1328804 - Enable the require-await rule for eslint and fix the four errors found by the rule by removing the 'async' keyword from the functions that arne't using await. r?kmag MozReview-Commit-ID: ETDQ8VdrppS
browser/components/extensions/test/browser/browser_ext_popup_sendMessage.js
toolkit/.eslintrc.js
toolkit/components/extensions/test/mochitest/test_ext_storage_content.html
toolkit/components/extensions/test/xpcshell/test_ext_storage.js
toolkit/components/places/tests/bookmarks/test_sync_fields.js
--- a/browser/components/extensions/test/browser/browser_ext_popup_sendMessage.js
+++ b/browser/components/extensions/test/browser/browser_ext_popup_sendMessage.js
@@ -16,17 +16,17 @@ add_task(function* test_popup_sendMessag
         "default_popup": "popup.html",
         "browser_style": true,
       },
     },
 
     files: {
       "popup.html": scriptPage("popup.js"),
       "popup.js": async function() {
-        browser.runtime.onMessage.addListener(async msg => {
+        browser.runtime.onMessage.addListener(msg => {
           if (msg == "popup-ping") {
             return Promise.resolve("popup-pong");
           }
         });
 
         let response = await browser.runtime.sendMessage("background-ping");
         browser.test.sendMessage("background-ping-response", response);
       },
--- a/toolkit/.eslintrc.js
+++ b/toolkit/.eslintrc.js
@@ -191,16 +191,19 @@ module.exports = {
     // "no-use-before-define": ["error", "nofunc"],
 
     // No using with
     "no-with": "error",
 
     // Require object-literal shorthand with ES6 method syntax
     "object-shorthand": ["error", "always", { "avoidQuotes": true }],
 
+    // Disallow async functions which have no await expression
+    "require-await": "error",
+
     // No spacing inside rest or spread expressions
     "rest-spread-spacing": "error",
 
     // Always require semicolon at end of statement
     // "semi": ["error", "always"],
 
     // Require space before blocks
     "space-before-blocks": "error",
--- a/toolkit/components/extensions/test/mochitest/test_ext_storage_content.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_storage_content.html
@@ -39,17 +39,17 @@ async function checkGetImpl(areaName, pr
 
   data = await storage.get([prop]);
   browser.test.assertEq(value, data[prop], `array getter worked for ${prop} in ${areaName}`);
 
   data = await storage.get({[prop]: undefined});
   browser.test.assertEq(value, data[prop], `object getter worked for ${prop} in ${areaName}`);
 }
 
-async function contentScript(checkGet) {
+function contentScript(checkGet) {
   let globalChanges, gResolve;
   function clearGlobalChanges() {
     globalChanges = new Promise(resolve => { gResolve = resolve; });
   }
   clearGlobalChanges();
   let expectedAreaName;
 
   browser.storage.onChanged.addListener((changes, areaName) => {
--- a/toolkit/components/extensions/test/xpcshell/test_ext_storage.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_storage.js
@@ -141,17 +141,17 @@ add_task(function* test_reloading_extens
   Preferences.reset(STORAGE_SYNC_PREF);
 });
 
 do_register_cleanup(() => {
   Preferences.reset(STORAGE_SYNC_PREF);
 });
 
 add_task(function* test_backgroundScript() {
-  async function backgroundScript(checkGet) {
+  function backgroundScript(checkGet) {
     let globalChanges, gResolve;
     function clearGlobalChanges() {
       globalChanges = new Promise(resolve => { gResolve = resolve; });
     }
     clearGlobalChanges();
     let expectedAreaName;
 
     browser.storage.onChanged.addListener((changes, areaName) => {
--- a/toolkit/components/places/tests/bookmarks/test_sync_fields.js
+++ b/toolkit/components/places/tests/bookmarks/test_sync_fields.js
@@ -256,17 +256,17 @@ class SyncTestCases extends TestCases {
   async removeKeyword(guid, keyword) {
     let id = await PlacesUtils.promiseItemId(guid);
     if (PlacesUtils.bookmarks.getKeywordForBookmark(id) != keyword) {
       throw new Error(`Keyword ${keyword} not set for bookmark ${guid}`);
     }
     PlacesUtils.bookmarks.setKeywordForBookmark(id, "");
   }
 
-  async tagURI(uri, tags) {
+  tagURI(uri, tags) {
     PlacesUtils.tagging.tagURI(uri, tags);
   }
 
   async reorder(parentGuid, childGuids) {
     let parentId = await PlacesUtils.promiseItemId(parentGuid);
     for (let index = 0; index < childGuids.length; ++index) {
       let id = await PlacesUtils.promiseItemId(childGuids[index]);
       PlacesUtils.bookmarks.moveItem(id, parentId, index);