Bug 1451659 - Enable ESLint for devtools/client/{canvasdebugger,framework,scratchpad,shadereditor}/. r=jdescottes

Disable rules with many failures for now, in a way that mentored bugs can easily pick them up.
Fix other minor issues raised by various rules.

MozReview-Commit-ID: 71OQI7jLihe

--HG--
extra : rebase_source : 7eac06299e6bbc6ae84e21b263c105555a06e757
This commit is contained in:
Mark Banner 2018-04-04 23:24:04 +01:00
parent 72de2a4acf
commit 3e2d95e5c0
22 changed files with 177 additions and 74 deletions

View file

@ -101,23 +101,11 @@ browser/extensions/mortar/**
browser/extensions/formautofill/phonenumberutils/PhoneNumberMetaData.jsm browser/extensions/formautofill/phonenumberutils/PhoneNumberMetaData.jsm
# devtools/ exclusions # 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/markup/test/doc_markup_events_*.html
devtools/client/inspector/rules/test/doc_media_queries.html devtools/client/inspector/rules/test/doc_media_queries.html
devtools/client/memory/test/chrome/*.html devtools/client/memory/test/chrome/*.html
devtools/client/performance/components/test/test_jit_optimizations_01.html devtools/client/performance/components/test/test_jit_optimizations_01.html
devtools/client/projecteditor/**
devtools/client/responsive.html/test/browser/touch.html devtools/client/responsive.html/test/browser/touch.html
devtools/client/scratchpad/**
devtools/client/shadereditor/**
devtools/client/shared/*.jsm devtools/client/shared/*.jsm
devtools/client/shared/components/reps/reps.js devtools/client/shared/components/reps/reps.js
devtools/client/shared/components/reps/test/mochitest/*.html 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/tests/mochitest/*.html
devtools/shared/webconsole/test/test_*.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 # Ignore devtools preferences files
devtools/client/preferences/** devtools/client/preferences/**
devtools/startup/devtools-startup-prefs.js devtools/startup/devtools-startup-prefs.js
@ -168,6 +165,8 @@ devtools/shared/sourcemap/*
devtools/shared/sprintfjs/* devtools/shared/sprintfjs/*
devtools/shared/qrcode/decoder/* devtools/shared/qrcode/decoder/*
devtools/shared/qrcode/encoder/* devtools/shared/qrcode/encoder/*
devtools/client/inspector/markup/test/lib_*
devtools/client/jsonview/lib/require.js
devtools/client/shared/demangle.js devtools/client/shared/demangle.js
devtools/client/shared/source-map/* devtools/client/shared/source-map/*
devtools/client/shared/vendor/* devtools/client/shared/vendor/*
@ -176,18 +175,11 @@ devtools/client/sourceeditor/codemirror/**/*.js
devtools/client/sourceeditor/tern/* devtools/client/sourceeditor/tern/*
devtools/client/sourceeditor/test/cm_mode_ruby.js devtools/client/sourceeditor/test/cm_mode_ruby.js
devtools/client/sourceeditor/test/codemirror/* devtools/client/sourceeditor/test/codemirror/*
devtools/client/inspector/markup/test/lib_*
devtools/client/jsonview/lib/require.js
devtools/server/actors/utils/automation-timeline.js devtools/server/actors/utils/automation-timeline.js
# Ignore devtools files testing sourcemaps / code style # Ignore devtools files testing sourcemaps / code style
devtools/client/debugger/test/mochitest/code_binary_search.js devtools/client/debugger/test/mochitest/code_*.js
devtools/client/debugger/test/mochitest/code_binary_search_absolute.js devtools/client/framework/test/code_*
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/inspector/markup/test/events_bundle.js devtools/client/inspector/markup/test/events_bundle.js
devtools/client/netmonitor/test/xhr_bundle.js devtools/client/netmonitor/test/xhr_bundle.js
devtools/client/webconsole/new-console-output/test/mochitest/code_bundle_nosource.js devtools/client/webconsole/new-console-output/test/mochitest/code_bundle_nosource.js

View file

@ -16,12 +16,122 @@ module.exports = {
// XXX Bug 1230193. We're still working on enabling no-undef for these test // XXX Bug 1230193. We're still working on enabling no-undef for these test
// directories. // directories.
"files": [ "files": [
"client/framework/test/**",
"client/scratchpad/**",
"server/tests/mochitest/**", "server/tests/mochitest/**",
"shared/tests/unit/**", "shared/tests/unit/**",
], ],
"rules": { "rules": {
"no-undef": "off", "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": { "rules": {
// These are the rules that have been configured so far to match the // These are the rules that have been configured so far to match the

View file

@ -367,9 +367,8 @@ var CallsListView = extend(WidgetMethods, {
let functionCall = callItem.attachment.actor; let functionCall = callItem.attachment.actor;
if (functionCall.isLoadedFromDisk) { if (functionCall.isLoadedFromDisk) {
display(functionCall.stack); display(functionCall.stack);
} } else {
// ..otherwise we need to request the function call stack from the backend. // ..otherwise we need to request the function call stack from the backend.
else {
callItem.attachment.actor.getDetails().then(fn => display(fn.stack)); callItem.attachment.actor.getDetails().then(fn => display(fn.stack));
} }
}, },

View file

@ -306,12 +306,11 @@ var SnapshotsListView = extend(WidgetMethods, {
if (actorCanStop) { if (actorCanStop) {
await gFront.stopRecordingAnimationFrame(); await gFront.stopRecordingAnimationFrame();
} } else {
// If actor does not have the method to stop recording (Fx39+), // If actor does not have the method to stop recording (Fx39+),
// manually call the record failure method. This will call a connection failure // manually call the record failure method. This will call a connection failure
// on disconnect as a result of `gFront.recordAnimationFrame()` never resolving, // on disconnect as a result of `gFront.recordAnimationFrame()` never resolving,
// but this is better than it hanging when there is no requestAnimationFrame anyway. // but this is better than it hanging when there is no requestAnimationFrame anyway.
else {
this._onRecordFailure(); this._onRecordFailure();
} }
@ -371,9 +370,10 @@ var SnapshotsListView = extend(WidgetMethods, {
console.error("Could not import recorded animation frame snapshot file."); console.error("Could not import recorded animation frame snapshot file.");
return; return;
} }
var data;
try { try {
let string = NetUtil.readInputStreamToString(inputStream, inputStream.available()); let string = NetUtil.readInputStreamToString(inputStream, inputStream.available());
var data = JSON.parse(string); data = JSON.parse(string);
} catch (e) { } catch (e) {
console.error("Could not read animation frame snapshot file."); console.error("Could not read animation frame snapshot file.");
return; return;

View file

@ -42,7 +42,9 @@ async function ifTestingSupported() {
await removeTab(target.tab); await removeTab(target.tab);
info("Start to estimate WebGL drawElements function."); 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"); navigated = once(target, "navigate");

View file

@ -68,9 +68,10 @@ function ToolSidebar(tabbox, panel, uid, options = {}) {
this._onTabBoxOverflow = this._onTabBoxOverflow.bind(this); this._onTabBoxOverflow = this._onTabBoxOverflow.bind(this);
this._onTabBoxUnderflow = this._onTabBoxUnderflow.bind(this); this._onTabBoxUnderflow = this._onTabBoxUnderflow.bind(this);
try { let width = Services.prefs.getIntPref("devtools.toolsidebar-width." + this._uid, undefined);
this._width = Services.prefs.getIntPref("devtools.toolsidebar-width." + this._uid); if (width) {
} catch (e) {} this._width = width;
}
if (!options.disableTelemetry) { if (!options.disableTelemetry) {
this._telemetry = new Telemetry(); this._telemetry = new Telemetry();

View file

@ -108,6 +108,8 @@ add_task(async function runTest() {
return Promise.resolve(true); return Promise.resolve(true);
} }
return new Promise(resolve => { return new Promise(resolve => {
// TODO: fixme.
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
setTimeout(function() { setTimeout(function() {
waitUntil(predicate, interval).then(() => resolve(true)); waitUntil(predicate, interval).then(() => resolve(true));
}, interval); }, interval);

View file

@ -24,6 +24,7 @@
function log(msg) { function log(msg) {
let output = document.getElementById("output"); let output = document.getElementById("output");
// eslint-disable-next-line no-unsanitized/property
output.innerHTML = msg; output.innerHTML = msg;
} }
</script> </script>

View file

@ -14,6 +14,7 @@
function log(msg) { function log(msg) {
let output = document.getElementById("output"); let output = document.getElementById("output");
// eslint-disable-next-line no-unsanitized/property
output.innerHTML = msg; output.innerHTML = msg;
} }
</script> </script>

View file

@ -30,6 +30,8 @@ function cleanUp(toolbox) {
off(DebuggerClient, "connect", onDebuggerClientConnect); off(DebuggerClient, "connect", onDebuggerClientConnect);
toolbox.destroy().then(function() { toolbox.destroy().then(function() {
// TODO: fixme.
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
setTimeout(() => { setTimeout(() => {
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
executeSoon(function() { executeSoon(function() {

View file

@ -23,12 +23,8 @@ function test() {
toolShortcuts.push(shortcut); toolShortcuts.push(shortcut);
// Enable disabled tools // Enable disabled tools
let pref = definition.visibilityswitch, prefValue; let pref = definition.visibilityswitch;
try { let prefValue = Services.prefs.getBoolPref(pref, false);
prefValue = Services.prefs.getBoolPref(pref);
} catch (e) {
continue;
}
if (!prefValue) { if (!prefValue) {
modifiedPrefs.push(pref); modifiedPrefs.push(pref);
Services.prefs.setBoolPref(pref, true); Services.prefs.setBoolPref(pref, true);

View file

@ -5,7 +5,6 @@
"use strict"; "use strict";
const l10n = require("gcli/l10n"); const l10n = require("gcli/l10n");
const {Cu} = require("chrome");
exports.items = [{ exports.items = [{
item: "command", item: "command",

View file

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; "use strict";
const {Cu} = require("chrome");
const EventEmitter = require("devtools/shared/event-emitter"); const EventEmitter = require("devtools/shared/event-emitter");
const promise = require("promise"); const promise = require("promise");
const defer = require("devtools/shared/defer"); const defer = require("devtools/shared/defer");

View file

@ -56,12 +56,12 @@ const { extend } = require("devtools/shared/extend");
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm"); const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
const {NetUtil} = require("resource://gre/modules/NetUtil.jsm"); const {NetUtil} = require("resource://gre/modules/NetUtil.jsm");
const {ScratchpadManager} = require("resource://devtools/client/scratchpad/scratchpad-manager.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 {OS} = require("resource://gre/modules/osfile.jsm");
const {Reflect} = require("resource://gre/modules/reflect.jsm"); const {Reflect} = require("resource://gre/modules/reflect.jsm");
// Use privileged promise in panel documents to prevent having them to freeze // Use privileged promise in panel documents to prevent having them to freeze
// during toolbox destruction. See bug 1402779. // during toolbox destruction. See bug 1402779.
// eslint-disable-next-line no-unused-vars
const Promise = require("Promise"); const Promise = require("Promise");
XPCOMUtils.defineConstant(this, "SCRATCHPAD_CONTEXT_CONTENT", SCRATCHPAD_CONTEXT_CONTENT); XPCOMUtils.defineConstant(this, "SCRATCHPAD_CONTEXT_CONTENT", SCRATCHPAD_CONTEXT_CONTENT);
@ -1079,22 +1079,22 @@ var Scratchpad = {
*/ */
_getUnicodeContent: function SP__getUnicodeContent(aContent, aCharsetArray) { _getUnicodeContent: function SP__getUnicodeContent(aContent, aCharsetArray) {
let content = null, let content = null,
converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter), converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
success = aCharsetArray.some(charset => { aCharsetArray.some(charset => {
try { try {
converter.charset = charset; converter.charset = charset;
content = converter.ConvertToUnicode(aContent); content = converter.ConvertToUnicode(aContent);
return true; return true;
} catch (e) { } catch (e) {
this.notificationBox.appendNotification( this.notificationBox.appendNotification(
this.strings.formatStringFromName("importFromFile.convert.failed", this.strings.formatStringFromName("importFromFile.convert.failed",
[ charset ], 1), [ charset ], 1),
"file-import-convert-failed", "file-import-convert-failed",
null, null,
this.notificationBox.PRIORITY_WARNING_HIGH, this.notificationBox.PRIORITY_WARNING_HIGH,
null); null);
} }
}); });
return content; return content;
}, },
@ -1281,10 +1281,9 @@ var Scratchpad = {
// It is not the most recent file. Remove it from the list, we add it as // It is not the most recent file. Remove it from the list, we add it as
// the most recent farther down. // the most recent farther down.
filePaths.splice(pathIndex, 1); filePaths.splice(pathIndex, 1);
} } else if (filesCount === maxRecent) {
// If we are not storing the file and the 'recent files'-list is full, // If we are not storing the file and the 'recent files'-list is full,
// remove the oldest file from the list. // remove the oldest file from the list.
else if (filesCount === maxRecent) {
filePaths.shift(); filePaths.shift();
} }

View file

@ -71,7 +71,7 @@ function testOpenInvalidState() {
} }
function testOpenTestFile() { function testOpenTestFile() {
let win = openScratchpad(function(win) { openScratchpad(function(win) {
ok(win, "scratchpad opened for file open"); ok(win, "scratchpad opened for file open");
try { try {
win.Scratchpad.importFromFile( win.Scratchpad.importFromFile(

View file

@ -27,7 +27,6 @@ var gFileName03 = "file03_ForBug651942.tmp";
var gFileName04 = "file04_ForBug651942.tmp"; var gFileName04 = "file04_ForBug651942.tmp";
// Content for the temporary files. // Content for the temporary files.
var gFileContent;
var gFileContent01 = "hello.world.01('bug651942');"; var gFileContent01 = "hello.world.01('bug651942');";
var gFileContent02 = "hello.world.02('bug651942');"; var gFileContent02 = "hello.world.02('bug651942');";
var gFileContent03 = "hello.world.03('bug651942');"; var gFileContent03 = "hello.world.03('bug651942');";

View file

@ -21,7 +21,6 @@ function test() {
} }
function runTests() { function runTests() {
let sp = gScratchpadWindow.Scratchpad;
let doc = gScratchpadWindow.document; let doc = gScratchpadWindow.document;
let testData = [ let testData = [

View file

@ -15,7 +15,6 @@ var gFileName = "testFileForBug751744.tmp";
// Content for the temporary file. // Content for the temporary file.
var gFileContent = "/* this file is already saved */\n" + var gFileContent = "/* this file is already saved */\n" +
"function foo() { alert('bar') }"; "function foo() { alert('bar') }";
var gLength = gFileContent.length;
// Reference to the menu entry. // Reference to the menu entry.
var menu; var menu;

View file

@ -86,6 +86,7 @@ function openScratchpad(aReadyCallback, aOptions = {}) {
*/ */
function openTabAndScratchpad(aOptions = {}) { function openTabAndScratchpad(aOptions = {}) {
waitForExplicitFinish(); waitForExplicitFinish();
// eslint-disable-next-line new-cap
return new promise(resolve => { return new promise(resolve => {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
let {selectedBrowser} = gBrowser; let {selectedBrowser} = gBrowser;

View file

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; "use strict";
const { Cc, Ci, Cu, Cr } = require("chrome");
const promise = require("promise"); const promise = require("promise");
const EventEmitter = require("devtools/shared/event-emitter"); const EventEmitter = require("devtools/shared/event-emitter");
const { WebGLFront } = require("devtools/shared/fronts/webgl"); const { WebGLFront } = require("devtools/shared/fronts/webgl");
@ -67,10 +66,10 @@ ShaderEditorPanel.prototype = {
return this._destroyer; 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 // Destroy front to ensure packet handler is removed from client
this.panelWin.gFront.destroy(); this.panelWin.gFront.destroy();
this.emit("destroyed"); this.emit("destroyed");
}); }));
} }
}; };

View file

@ -3,13 +3,14 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; "use strict";
/* exported startupShaderEditor, shutdownShaderEditor */
const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {}); const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm"); const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
const {SideMenuWidget} = require("resource://devtools/client/shared/widgets/SideMenuWidget.jsm"); const {SideMenuWidget} = require("resource://devtools/client/shared/widgets/SideMenuWidget.jsm");
const promise = require("promise"); const promise = require("promise");
const defer = require("devtools/shared/defer"); const defer = require("devtools/shared/defer");
const {Task} = require("devtools/shared/task"); const {Task} = require("devtools/shared/task");
const Services = require("Services");
const EventEmitter = require("devtools/shared/event-emitter"); const EventEmitter = require("devtools/shared/event-emitter");
const Tooltip = require("devtools/client/shared/widgets/tooltip/Tooltip"); const Tooltip = require("devtools/client/shared/widgets/tooltip/Tooltip");
const Editor = require("devtools/client/sourceeditor/editor"); 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 // Use privileged promise in panel documents to prevent having them to freeze
// during toolbox destruction. See bug 1402779. // during toolbox destruction. See bug 1402779.
// eslint-disable-next-line no-unused-vars
const Promise = require("Promise"); const Promise = require("Promise");
// The panel's window global is an EventEmitter firing the following events: // The panel's window global is an EventEmitter firing the following events:

View file

@ -73,7 +73,7 @@ async function test() {
try { try {
await generator(); await generator();
} catch (e) { } catch (e) {
handlError(e); handleError(e);
} }
} }
@ -115,7 +115,8 @@ function ensurePixelIs(aFront, aPosition, aColor, aWaitFlag = false, aSelector =
if (aWaitFlag) { if (aWaitFlag) {
await aFront.waitForFrame(); 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()); ok(false, "Expected pixel was not already shown at: " + aPosition.toSource());