From b6c94f538f1b75a447dccf653c698df2bcd9bedf Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Tue, 5 Apr 2016 11:30:51 -0700 Subject: [PATCH] Bug 1257246: Update webextension APIs for eslint 2. r=kmag ESLint 2 now flags anonymous generator functions that don't match the generator-star-spacing rule so this mostly is fixing that. MozReview-Commit-ID: 5sLaF26sd0E --HG-- extra : rebase_source : 6008f48c94e4a8e5bd2ed2f8a95e764e4aa39cdb extra : histedit_source : 6f0151c184ee2e4288f3ec9c5a85a65e975d46e1 --- browser/components/extensions/ext-commands.js | 10 ++++----- .../test/browser/browser_ext_currentWindow.js | 4 ++-- .../test/browser/browser_ext_getViews.js | 8 +++---- .../browser/file_popup_api_injection_a.html | 1 + .../browser/file_popup_api_injection_b.html | 1 + .../extensions/test/browser/head.js | 4 +--- toolkit/components/extensions/.eslintrc | 21 ++++++------------- .../extensions/ExtensionContent.jsm | 2 +- .../test_chrome_ext_downloads_download.html | 2 +- .../test/mochitest/test_ext_webrequest.html | 4 ++-- 10 files changed, 24 insertions(+), 33 deletions(-) diff --git a/browser/components/extensions/ext-commands.js b/browser/components/extensions/ext-commands.js index 8a6228375332..c6276c9882c4 100644 --- a/browser/components/extensions/ext-commands.js +++ b/browser/components/extensions/ext-commands.js @@ -195,11 +195,11 @@ CommandList.prototype = { */ getModifiersAttribute(chromeModifiers) { let modifiersMap = { - "Alt" : "alt", - "Command" : "accel", - "Ctrl" : "accel", - "MacCtrl" : "control", - "Shift" : "shift", + "Alt": "alt", + "Command": "accel", + "Ctrl": "accel", + "MacCtrl": "control", + "Shift": "shift", }; return Array.from(chromeModifiers, modifier => { return modifiersMap[modifier]; diff --git a/browser/components/extensions/test/browser/browser_ext_currentWindow.js b/browser/components/extensions/test/browser/browser_ext_currentWindow.js index f8026235c903..8ef9df1c45a4 100644 --- a/browser/components/extensions/test/browser/browser_ext_currentWindow.js +++ b/browser/components/extensions/test/browser/browser_ext_currentWindow.js @@ -122,11 +122,11 @@ add_task(function* () { // Set focus to some other window. yield focusWindow(window); - yield triggerPopup(win1, function*() { + yield triggerPopup(win1, function* () { yield checkWindow("popup", winId1, "win1"); }); - yield triggerPopup(win2, function*() { + yield triggerPopup(win2, function* () { yield checkWindow("popup", winId2, "win2"); }); diff --git a/browser/components/extensions/test/browser/browser_ext_getViews.js b/browser/components/extensions/test/browser/browser_ext_getViews.js index 0143d3694cbd..f071a4558ebc 100644 --- a/browser/components/extensions/test/browser/browser_ext_getViews.js +++ b/browser/components/extensions/test/browser/browser_ext_getViews.js @@ -140,12 +140,12 @@ add_task(function* () { // short timeout seems to consistently fix it. yield new Promise(resolve => win1.setTimeout(resolve, 10)); - yield triggerPopup(win1, function*() { + yield triggerPopup(win1, function* () { yield checkViews("background", 2, 1); yield checkViews("popup", 2, 1); }); - yield triggerPopup(win2, function*() { + yield triggerPopup(win2, function* () { yield checkViews("background", 2, 1); yield checkViews("popup", 2, 1); }); @@ -165,7 +165,7 @@ add_task(function* () { info("opening win1 popup"); - yield triggerPopup(win1, function*() { + yield triggerPopup(win1, function* () { yield checkViews("background", 1, 1); yield checkViews("tab", 1, 1); yield checkViews("popup", 1, 1); @@ -173,7 +173,7 @@ add_task(function* () { info("opening win2 popup"); - yield triggerPopup(win2, function*() { + yield triggerPopup(win2, function* () { yield checkViews("background", 1, 1); yield checkViews("tab", 1, 1); yield checkViews("popup", 1, 1); diff --git a/browser/components/extensions/test/browser/file_popup_api_injection_a.html b/browser/components/extensions/test/browser/file_popup_api_injection_a.html index dd1632da875b..750ff1db3782 100644 --- a/browser/components/extensions/test/browser/file_popup_api_injection_a.html +++ b/browser/components/extensions/test/browser/file_popup_api_injection_a.html @@ -3,6 +3,7 @@ diff --git a/browser/components/extensions/test/browser/file_popup_api_injection_b.html b/browser/components/extensions/test/browser/file_popup_api_injection_b.html index 24d749220e03..b8c287e55c85 100644 --- a/browser/components/extensions/test/browser/file_popup_api_injection_b.html +++ b/browser/components/extensions/test/browser/file_popup_api_injection_b.html @@ -3,6 +3,7 @@ diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js index 28d048c7f608..6944d0e2dea6 100644 --- a/browser/components/extensions/test/browser/head.js +++ b/browser/components/extensions/test/browser/head.js @@ -78,10 +78,8 @@ function getBrowserActionPopup(extension, win = window) { if (group.areaType == CustomizableUI.TYPE_TOOLBAR) { return win.document.getElementById("customizationui-widget-panel"); - } else { - return win.PanelUI.panel; } - return null; + return win.PanelUI.panel; } var clickBrowserAction = Task.async(function* (extension, win = window) { diff --git a/toolkit/components/extensions/.eslintrc b/toolkit/components/extensions/.eslintrc index 5453a5c862a0..dabb3985b82f 100644 --- a/toolkit/components/extensions/.eslintrc +++ b/toolkit/components/extensions/.eslintrc @@ -84,6 +84,9 @@ // Space after colon not before in property declarations "key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "minimum"}], + // Require spaces before and after finally, catch, etc. + "keyword-spacing": 2, + // Unix linebreaks "linebreak-style": [2, "unix"], @@ -102,9 +105,6 @@ // No duplicate cases in switch statements "no-duplicate-case": 2, - // No labels - // "no-labels": 2, - // If an if block ends with a return no need for an else block // "no-else-return": 2, @@ -207,15 +207,9 @@ // Never use spaces before function parentheses "space-before-function-paren": [2, {"anonymous": "never", "named": "never"}], - // Require spaces before finally, catch, etc. - "space-before-keywords": [2, "always"], - // Require spaces around operators, except for a|0. "space-infix-ops": [2, {"int32Hint": true}], - // Require spaces after return, throw and case - "space-return-throw-case": 2, - // ++ and -- should not need spacing "space-unary-ops": [1, {"nonwords": false}], @@ -321,9 +315,6 @@ // Allow division operators explicitly at beginning of regular expression. "no-div-regex": 0, - // Disallow use of labels for anything other then loops and switches. - "no-empty-label": 2, - // Disallow use of eval(). We have other APIs to evaluate code in content. "no-eval": 2, @@ -345,6 +336,9 @@ // Allow comments inline after code. "no-inline-comments": 0, + // Disallow use of labels for anything other then loops and switches. + "no-labels": [2, { "allowLoop": true }], + // Disallow use of multiline strings (use template strings instead). "no-multi-str": 1, @@ -446,9 +440,6 @@ // Anyway, one-var is disabled. "sort-vars": 0, - // Require a space after keywords. - "space-after-keywords": [2, "always"], - // Require a space immediately following the // in a line comment. "spaced-comment": [2, "always"], diff --git a/toolkit/components/extensions/ExtensionContent.jsm b/toolkit/components/extensions/ExtensionContent.jsm index 94ec1fbee37e..63afffc31163 100644 --- a/toolkit/components/extensions/ExtensionContent.jsm +++ b/toolkit/components/extensions/ExtensionContent.jsm @@ -546,7 +546,7 @@ DocumentManager = { return promises[0]; }, - enumerateWindows: function*(docShell) { + enumerateWindows: function* (docShell) { let window = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindow); yield window; diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_download.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_download.html index 8aaead0fcc32..54f1c16e7a7d 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_download.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_download.html @@ -204,7 +204,7 @@ add_task(function* test_downloads() { }); // check for leftover files in the download directory -add_task(function*() { +add_task(function* () { let entries = downloadDir.directoryEntries; while (entries.hasMoreElements()) { let entry = entries.getNext().QueryInterface(Ci.nsIFile); diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html index 9883d563ad29..016d9448b84c 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html @@ -505,8 +505,8 @@ function* test_once(skipCompleted) { } // Run the test twice to make sure it works with caching. -add_task(function*() { yield test_once(false); }); -add_task(function*() { yield test_once(true); }); +add_task(function* () { yield test_once(false); }); +add_task(function* () { yield test_once(true); });