diff --git a/.eslintignore b/.eslintignore index b376591ab730..3d43e26bee47 100644 --- a/.eslintignore +++ b/.eslintignore @@ -101,23 +101,11 @@ browser/extensions/mortar/** browser/extensions/formautofill/phonenumberutils/PhoneNumberMetaData.jsm # devtools/ exclusions -devtools/client/canvasdebugger/** -devtools/client/commandline/** -devtools/client/debugger/** -devtools/client/framework/** -!devtools/client/framework/devtools.js -!devtools/client/framework/devtools-browser.js -!devtools/client/framework/selection.js -!devtools/client/framework/target* -!devtools/client/framework/toolbox* devtools/client/inspector/markup/test/doc_markup_events_*.html devtools/client/inspector/rules/test/doc_media_queries.html devtools/client/memory/test/chrome/*.html devtools/client/performance/components/test/test_jit_optimizations_01.html -devtools/client/projecteditor/** devtools/client/responsive.html/test/browser/touch.html -devtools/client/scratchpad/** -devtools/client/shadereditor/** devtools/client/shared/*.jsm devtools/client/shared/components/reps/reps.js devtools/client/shared/components/reps/test/mochitest/*.html @@ -154,6 +142,15 @@ devtools/shared/qrcode/tests/mochitest/test_decode.html devtools/shared/tests/mochitest/*.html devtools/shared/webconsole/test/test_*.html +# Soon to be removed +devtools/client/commandline/** +# Soon to be removed, the new/ directory is explicitly excluded below due to +# also being an imported repository. +devtools/client/debugger/** + +# Ignore devtools imported repositories +devtools/client/debugger/new/** + # Ignore devtools preferences files devtools/client/preferences/** devtools/startup/devtools-startup-prefs.js @@ -168,6 +165,8 @@ devtools/shared/sourcemap/* devtools/shared/sprintfjs/* devtools/shared/qrcode/decoder/* devtools/shared/qrcode/encoder/* +devtools/client/inspector/markup/test/lib_* +devtools/client/jsonview/lib/require.js devtools/client/shared/demangle.js devtools/client/shared/source-map/* devtools/client/shared/vendor/* @@ -176,18 +175,11 @@ devtools/client/sourceeditor/codemirror/**/*.js devtools/client/sourceeditor/tern/* devtools/client/sourceeditor/test/cm_mode_ruby.js devtools/client/sourceeditor/test/codemirror/* -devtools/client/inspector/markup/test/lib_* -devtools/client/jsonview/lib/require.js devtools/server/actors/utils/automation-timeline.js # Ignore devtools files testing sourcemaps / code style -devtools/client/debugger/test/mochitest/code_binary_search.js -devtools/client/debugger/test/mochitest/code_binary_search_absolute.js -devtools/client/debugger/test/mochitest/code_math.min.js -devtools/client/debugger/test/mochitest/code_math_bogus_map.js -devtools/client/debugger/test/mochitest/code_ugly* -devtools/client/debugger/test/mochitest/code_worker-source-map.js -devtools/client/framework/test/code_ugly* +devtools/client/debugger/test/mochitest/code_*.js +devtools/client/framework/test/code_* devtools/client/inspector/markup/test/events_bundle.js devtools/client/netmonitor/test/xhr_bundle.js devtools/client/webconsole/new-console-output/test/mochitest/code_bundle_nosource.js diff --git a/devtools/.eslintrc.js b/devtools/.eslintrc.js index e74e3190b86d..e2fe4b090dd8 100644 --- a/devtools/.eslintrc.js +++ b/devtools/.eslintrc.js @@ -16,12 +16,122 @@ module.exports = { // XXX Bug 1230193. We're still working on enabling no-undef for these test // directories. "files": [ + "client/framework/test/**", + "client/scratchpad/**", "server/tests/mochitest/**", "shared/tests/unit/**", ], "rules": { "no-undef": "off", } + }, { + "files": [ + "client/framework/**", + ], + "rules": { + "no-return-assign": "off", + "no-unused-vars": "off", + } + }, { + "files": [ + "client/scratchpad/scratchpad-manager.jsm", + "client/scratchpad/scratchpad.js", + ], + "rules": { + "camelcase": "off", + } + }, { + "files": [ + "client/framework/**", + "client/scratchpad/**", + ], + "rules": { + "consistent-return": "off", + } + }, { + "files": [ + "client/framework/**", + "client/scratchpad/**", + ], + "rules": { + "max-nested-callbacks": "off", + } + }, { + "files": [ + "client/framework/**", + "client/scratchpad/**", + ], + "rules": { + "max-len": "off", + } + }, { + "files": [ + "client/scratchpad/test/browser_scratchpad_inspect.js", + "client/scratchpad/test/browser_scratchpad_inspect_primitives.js", + ], + "rules": { + "no-labels": "off", + } + }, { + "files": [ + "client/framework/**", + "client/scratchpad/**", + ], + "rules": { + "mozilla/no-aArgs": "off", + } + }, { + "files": [ + "client/framework/test/**", + "client/scratchpad/**", + ], + "rules": { + "mozilla/var-only-at-top-level": "off", + } + }, { + "files": [ + "client/framework/**", + "client/scratchpad/**", + ], + "rules": { + "no-shadow": "off", + } + }, { + "files": [ + "client/framework/**", + "client/scratchpad/**", + ], + "rules": { + "strict": "off", + } + }, { + "files": [ + // Note: Bug 1403938 may be removing canvasdebugger, check before + // doing more work on enabling these rules. + "client/canvasdebugger/**", + // Note: Bug 1342237 may be removing shadereditor, check before + // doing more work on enabling these rules. + "client/shadereditor/**", + ], + "rules": { + "consistent-return": "off", + "max-len": "off", + "mozilla/no-aArgs": "off", + "mozilla/var-only-at-top-level": "off", + "no-return-assign": "off", + "no-shadow": "off", + "no-undef": "off", + "no-unused-vars": "off", + "strict": "off", + } + }, { + // For all head*.js files, turn off no-unused-vars at a global level + "files": [ + "**/head*.js", + ], + "rules": { + "no-unused-vars": ["error", {"args": "none", "vars": "local"}], + } }], "rules": { // These are the rules that have been configured so far to match the diff --git a/devtools/client/canvasdebugger/callslist.js b/devtools/client/canvasdebugger/callslist.js index 1f6f18aa4a44..2d9a547882a9 100644 --- a/devtools/client/canvasdebugger/callslist.js +++ b/devtools/client/canvasdebugger/callslist.js @@ -367,9 +367,8 @@ var CallsListView = extend(WidgetMethods, { let functionCall = callItem.attachment.actor; if (functionCall.isLoadedFromDisk) { display(functionCall.stack); - } - // ..otherwise we need to request the function call stack from the backend. - else { + } else { + // ..otherwise we need to request the function call stack from the backend. callItem.attachment.actor.getDetails().then(fn => display(fn.stack)); } }, diff --git a/devtools/client/canvasdebugger/snapshotslist.js b/devtools/client/canvasdebugger/snapshotslist.js index cd29ba9fba59..05421e655b9b 100644 --- a/devtools/client/canvasdebugger/snapshotslist.js +++ b/devtools/client/canvasdebugger/snapshotslist.js @@ -306,12 +306,11 @@ var SnapshotsListView = extend(WidgetMethods, { if (actorCanStop) { await gFront.stopRecordingAnimationFrame(); - } - // If actor does not have the method to stop recording (Fx39+), - // manually call the record failure method. This will call a connection failure - // on disconnect as a result of `gFront.recordAnimationFrame()` never resolving, - // but this is better than it hanging when there is no requestAnimationFrame anyway. - else { + } else { + // If actor does not have the method to stop recording (Fx39+), + // manually call the record failure method. This will call a connection failure + // on disconnect as a result of `gFront.recordAnimationFrame()` never resolving, + // but this is better than it hanging when there is no requestAnimationFrame anyway. this._onRecordFailure(); } @@ -371,9 +370,10 @@ var SnapshotsListView = extend(WidgetMethods, { console.error("Could not import recorded animation frame snapshot file."); return; } + var data; try { let string = NetUtil.readInputStreamToString(inputStream, inputStream.available()); - var data = JSON.parse(string); + data = JSON.parse(string); } catch (e) { console.error("Could not read animation frame snapshot file."); return; diff --git a/devtools/client/canvasdebugger/test/browser_profiling-webgl.js b/devtools/client/canvasdebugger/test/browser_profiling-webgl.js index ac8b65d8b444..546869eddf77 100644 --- a/devtools/client/canvasdebugger/test/browser_profiling-webgl.js +++ b/devtools/client/canvasdebugger/test/browser_profiling-webgl.js @@ -42,7 +42,9 @@ async function ifTestingSupported() { await removeTab(target.tab); info("Start to estimate WebGL drawElements function."); - var { target, front } = await initCanvasDebuggerBackend(WEBGL_DRAW_ELEMENTS); + let result = await initCanvasDebuggerBackend(WEBGL_DRAW_ELEMENTS); + target = result.target; + front = result.front; navigated = once(target, "navigate"); diff --git a/devtools/client/framework/sidebar.js b/devtools/client/framework/sidebar.js index 870efa3207ef..58963bc6fbc5 100644 --- a/devtools/client/framework/sidebar.js +++ b/devtools/client/framework/sidebar.js @@ -68,9 +68,10 @@ function ToolSidebar(tabbox, panel, uid, options = {}) { this._onTabBoxOverflow = this._onTabBoxOverflow.bind(this); this._onTabBoxUnderflow = this._onTabBoxUnderflow.bind(this); - try { - this._width = Services.prefs.getIntPref("devtools.toolsidebar-width." + this._uid); - } catch (e) {} + let width = Services.prefs.getIntPref("devtools.toolsidebar-width." + this._uid, undefined); + if (width) { + this._width = width; + } if (!options.disableTelemetry) { this._telemetry = new Telemetry(); diff --git a/devtools/client/framework/test/browser_browser_toolbox_debugger.js b/devtools/client/framework/test/browser_browser_toolbox_debugger.js index cf93f10d4969..8052045d0eab 100644 --- a/devtools/client/framework/test/browser_browser_toolbox_debugger.js +++ b/devtools/client/framework/test/browser_browser_toolbox_debugger.js @@ -108,6 +108,8 @@ add_task(async function runTest() { return Promise.resolve(true); } return new Promise(resolve => { + // TODO: fixme. + // eslint-disable-next-line mozilla/no-arbitrary-setTimeout setTimeout(function() { waitUntil(predicate, interval).then(() => resolve(true)); }, interval); diff --git a/devtools/client/framework/test/browser_toolbox_options_disable_js.html b/devtools/client/framework/test/browser_toolbox_options_disable_js.html index f5ccb8b2619e..7bccff3ed769 100644 --- a/devtools/client/framework/test/browser_toolbox_options_disable_js.html +++ b/devtools/client/framework/test/browser_toolbox_options_disable_js.html @@ -24,6 +24,7 @@ function log(msg) { let output = document.getElementById("output"); + // eslint-disable-next-line no-unsanitized/property output.innerHTML = msg; } diff --git a/devtools/client/framework/test/browser_toolbox_options_disable_js_iframe.html b/devtools/client/framework/test/browser_toolbox_options_disable_js_iframe.html index b74651f3f5b4..7aa12e46d61f 100644 --- a/devtools/client/framework/test/browser_toolbox_options_disable_js_iframe.html +++ b/devtools/client/framework/test/browser_toolbox_options_disable_js_iframe.html @@ -14,6 +14,7 @@ function log(msg) { let output = document.getElementById("output"); + // eslint-disable-next-line no-unsanitized/property output.innerHTML = msg; } diff --git a/devtools/client/framework/test/browser_toolbox_transport_events.js b/devtools/client/framework/test/browser_toolbox_transport_events.js index 7675881de464..64096d850085 100644 --- a/devtools/client/framework/test/browser_toolbox_transport_events.js +++ b/devtools/client/framework/test/browser_toolbox_transport_events.js @@ -30,6 +30,8 @@ function cleanUp(toolbox) { off(DebuggerClient, "connect", onDebuggerClientConnect); toolbox.destroy().then(function() { + // TODO: fixme. + // eslint-disable-next-line mozilla/no-arbitrary-setTimeout setTimeout(() => { gBrowser.removeCurrentTab(); executeSoon(function() { diff --git a/devtools/client/framework/test/browser_toolbox_window_shortcuts.js b/devtools/client/framework/test/browser_toolbox_window_shortcuts.js index 6375f04d8a05..ab80433ad51f 100644 --- a/devtools/client/framework/test/browser_toolbox_window_shortcuts.js +++ b/devtools/client/framework/test/browser_toolbox_window_shortcuts.js @@ -23,12 +23,8 @@ function test() { toolShortcuts.push(shortcut); // Enable disabled tools - let pref = definition.visibilityswitch, prefValue; - try { - prefValue = Services.prefs.getBoolPref(pref); - } catch (e) { - continue; - } + let pref = definition.visibilityswitch; + let prefValue = Services.prefs.getBoolPref(pref, false); if (!prefValue) { modifiedPrefs.push(pref); Services.prefs.setBoolPref(pref, true); diff --git a/devtools/client/scratchpad/scratchpad-commands.js b/devtools/client/scratchpad/scratchpad-commands.js index b52d012c4811..c31dc42a05e3 100644 --- a/devtools/client/scratchpad/scratchpad-commands.js +++ b/devtools/client/scratchpad/scratchpad-commands.js @@ -5,7 +5,6 @@ "use strict"; const l10n = require("gcli/l10n"); -const {Cu} = require("chrome"); exports.items = [{ item: "command", diff --git a/devtools/client/scratchpad/scratchpad-panel.js b/devtools/client/scratchpad/scratchpad-panel.js index e46b05876ad6..086f247e9c8c 100644 --- a/devtools/client/scratchpad/scratchpad-panel.js +++ b/devtools/client/scratchpad/scratchpad-panel.js @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {Cu} = require("chrome"); const EventEmitter = require("devtools/shared/event-emitter"); const promise = require("promise"); const defer = require("devtools/shared/defer"); diff --git a/devtools/client/scratchpad/scratchpad.js b/devtools/client/scratchpad/scratchpad.js index ca8d009df574..7249ec07e476 100644 --- a/devtools/client/scratchpad/scratchpad.js +++ b/devtools/client/scratchpad/scratchpad.js @@ -56,12 +56,12 @@ const { extend } = require("devtools/shared/extend"); const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm"); const {NetUtil} = require("resource://gre/modules/NetUtil.jsm"); const {ScratchpadManager} = require("resource://devtools/client/scratchpad/scratchpad-manager.jsm"); -const {addDebuggerToGlobal} = require("resource://gre/modules/jsdebugger.jsm"); const {OS} = require("resource://gre/modules/osfile.jsm"); const {Reflect} = require("resource://gre/modules/reflect.jsm"); // Use privileged promise in panel documents to prevent having them to freeze // during toolbox destruction. See bug 1402779. +// eslint-disable-next-line no-unused-vars const Promise = require("Promise"); XPCOMUtils.defineConstant(this, "SCRATCHPAD_CONTEXT_CONTENT", SCRATCHPAD_CONTEXT_CONTENT); @@ -1079,22 +1079,22 @@ var Scratchpad = { */ _getUnicodeContent: function SP__getUnicodeContent(aContent, aCharsetArray) { let content = null, - converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter), - success = aCharsetArray.some(charset => { - try { - converter.charset = charset; - content = converter.ConvertToUnicode(aContent); - return true; - } catch (e) { - this.notificationBox.appendNotification( - this.strings.formatStringFromName("importFromFile.convert.failed", - [ charset ], 1), - "file-import-convert-failed", - null, - this.notificationBox.PRIORITY_WARNING_HIGH, - null); - } - }); + converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter); + aCharsetArray.some(charset => { + try { + converter.charset = charset; + content = converter.ConvertToUnicode(aContent); + return true; + } catch (e) { + this.notificationBox.appendNotification( + this.strings.formatStringFromName("importFromFile.convert.failed", + [ charset ], 1), + "file-import-convert-failed", + null, + this.notificationBox.PRIORITY_WARNING_HIGH, + null); + } + }); return content; }, @@ -1281,10 +1281,9 @@ var Scratchpad = { // It is not the most recent file. Remove it from the list, we add it as // the most recent farther down. filePaths.splice(pathIndex, 1); - } - // If we are not storing the file and the 'recent files'-list is full, - // remove the oldest file from the list. - else if (filesCount === maxRecent) { + } else if (filesCount === maxRecent) { + // If we are not storing the file and the 'recent files'-list is full, + // remove the oldest file from the list. filePaths.shift(); } diff --git a/devtools/client/scratchpad/test/browser_scratchpad_open.js b/devtools/client/scratchpad/test/browser_scratchpad_open.js index b1597afdbaa7..d1d4d55e054a 100644 --- a/devtools/client/scratchpad/test/browser_scratchpad_open.js +++ b/devtools/client/scratchpad/test/browser_scratchpad_open.js @@ -71,7 +71,7 @@ function testOpenInvalidState() { } function testOpenTestFile() { - let win = openScratchpad(function(win) { + openScratchpad(function(win) { ok(win, "scratchpad opened for file open"); try { win.Scratchpad.importFromFile( diff --git a/devtools/client/scratchpad/test/browser_scratchpad_recent_files.js b/devtools/client/scratchpad/test/browser_scratchpad_recent_files.js index 5b02a7cc5a15..0761a3a4820c 100644 --- a/devtools/client/scratchpad/test/browser_scratchpad_recent_files.js +++ b/devtools/client/scratchpad/test/browser_scratchpad_recent_files.js @@ -27,7 +27,6 @@ var gFileName03 = "file03_ForBug651942.tmp"; var gFileName04 = "file04_ForBug651942.tmp"; // Content for the temporary files. -var gFileContent; var gFileContent01 = "hello.world.01('bug651942');"; var gFileContent02 = "hello.world.02('bug651942');"; var gFileContent03 = "hello.world.03('bug651942');"; diff --git a/devtools/client/scratchpad/test/browser_scratchpad_remember_view_options.js b/devtools/client/scratchpad/test/browser_scratchpad_remember_view_options.js index d39ebda462a6..2962cef3e0b2 100644 --- a/devtools/client/scratchpad/test/browser_scratchpad_remember_view_options.js +++ b/devtools/client/scratchpad/test/browser_scratchpad_remember_view_options.js @@ -21,7 +21,6 @@ function test() { } function runTests() { - let sp = gScratchpadWindow.Scratchpad; let doc = gScratchpadWindow.document; let testData = [ diff --git a/devtools/client/scratchpad/test/browser_scratchpad_revert_to_saved.js b/devtools/client/scratchpad/test/browser_scratchpad_revert_to_saved.js index e1594f93ca88..f3a89cfe4349 100644 --- a/devtools/client/scratchpad/test/browser_scratchpad_revert_to_saved.js +++ b/devtools/client/scratchpad/test/browser_scratchpad_revert_to_saved.js @@ -15,7 +15,6 @@ var gFileName = "testFileForBug751744.tmp"; // Content for the temporary file. var gFileContent = "/* this file is already saved */\n" + "function foo() { alert('bar') }"; -var gLength = gFileContent.length; // Reference to the menu entry. var menu; diff --git a/devtools/client/scratchpad/test/head.js b/devtools/client/scratchpad/test/head.js index c3c246788066..a2e0278dfed1 100644 --- a/devtools/client/scratchpad/test/head.js +++ b/devtools/client/scratchpad/test/head.js @@ -86,6 +86,7 @@ function openScratchpad(aReadyCallback, aOptions = {}) { */ function openTabAndScratchpad(aOptions = {}) { waitForExplicitFinish(); + // eslint-disable-next-line new-cap return new promise(resolve => { gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); let {selectedBrowser} = gBrowser; diff --git a/devtools/client/shadereditor/panel.js b/devtools/client/shadereditor/panel.js index 630a2a35e5fe..4a452f0286bd 100644 --- a/devtools/client/shadereditor/panel.js +++ b/devtools/client/shadereditor/panel.js @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const { Cc, Ci, Cu, Cr } = require("chrome"); const promise = require("promise"); const EventEmitter = require("devtools/shared/event-emitter"); const { WebGLFront } = require("devtools/shared/fronts/webgl"); @@ -67,10 +66,10 @@ ShaderEditorPanel.prototype = { return this._destroyer; } - return this._destroyer = this.panelWin.shutdownShaderEditor().then(() => { + return (this._destroyer = this.panelWin.shutdownShaderEditor().then(() => { // Destroy front to ensure packet handler is removed from client this.panelWin.gFront.destroy(); this.emit("destroyed"); - }); + })); } }; diff --git a/devtools/client/shadereditor/shadereditor.js b/devtools/client/shadereditor/shadereditor.js index 7ff267001ea8..91b6da8753bc 100644 --- a/devtools/client/shadereditor/shadereditor.js +++ b/devtools/client/shadereditor/shadereditor.js @@ -3,13 +3,14 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +/* exported startupShaderEditor, shutdownShaderEditor */ + const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {}); const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm"); const {SideMenuWidget} = require("resource://devtools/client/shared/widgets/SideMenuWidget.jsm"); const promise = require("promise"); const defer = require("devtools/shared/defer"); const {Task} = require("devtools/shared/task"); -const Services = require("Services"); const EventEmitter = require("devtools/shared/event-emitter"); const Tooltip = require("devtools/client/shared/widgets/tooltip/Tooltip"); const Editor = require("devtools/client/sourceeditor/editor"); @@ -20,6 +21,7 @@ const {WidgetMethods, setNamedTimeout} = // Use privileged promise in panel documents to prevent having them to freeze // during toolbox destruction. See bug 1402779. +// eslint-disable-next-line no-unused-vars const Promise = require("Promise"); // The panel's window global is an EventEmitter firing the following events: diff --git a/devtools/client/shadereditor/test/head.js b/devtools/client/shadereditor/test/head.js index d8db76c7cb25..df738f178a0c 100644 --- a/devtools/client/shadereditor/test/head.js +++ b/devtools/client/shadereditor/test/head.js @@ -73,7 +73,7 @@ async function test() { try { await generator(); } catch (e) { - handlError(e); + handleError(e); } } @@ -115,7 +115,8 @@ function ensurePixelIs(aFront, aPosition, aColor, aWaitFlag = false, aSelector = if (aWaitFlag) { await aFront.waitForFrame(); - return ensurePixelIs(aFront, aPosition, aColor, aWaitFlag, aSelector); + await ensurePixelIs(aFront, aPosition, aColor, aWaitFlag, aSelector); + return; } ok(false, "Expected pixel was not already shown at: " + aPosition.toSource());