Bug 1371293 - Fix various devtools warnings after upgrading to ESLint 4. r?miker
ESLint 4 will turn on all rules after an eslint-enable with no arguments. Therefore be more specific about which rules are being disabled.
MozReview-Commit-ID: IoPBG72zySm
--- a/devtools/server/tests/unit/test_blackboxing-02.js
+++ b/devtools/server/tests/unit/test_blackboxing-02.js
@@ -1,14 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
-/* eslint-disable no-shadow */
"use strict";
+/* eslint-disable no-shadow */
+
/**
* Test that we don't hit breakpoints in black boxed sources, and that when we
* unblack box the source again, the breakpoint hasn't disappeared and we will
* hit it again.
*/
var gDebuggee;
var gClient;
@@ -46,17 +47,17 @@ function test_black_box() {
line: 2
}, function (response) {
do_check_true(!response.error, "Should be able to set breakpoint.");
gThreadClient.resume(test_black_box_breakpoint);
});
}
});
- /* eslint-disable */
+ /* eslint-disable no-multi-spaces */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
let arg = 15; // line 2 - Break here
k(arg); // line 3
}, // line 4
gDebuggee,
"1.8",
BLACK_BOXED_URL,
@@ -72,17 +73,17 @@ function test_black_box() {
); // line 7
} // line 8
+ "\n debugger;", // line 9
gDebuggee,
"1.8",
SOURCE_URL,
1
);
- /* eslint-enable */
+ /* eslint-enable no-multi-spaces */
}
function test_black_box_breakpoint() {
gThreadClient.getSources(function ({error, sources}) {
do_check_true(!error, "Should not get an error: " + error);
let sourceClient = gThreadClient.source(
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
--- a/devtools/server/tests/unit/test_blackboxing-03.js
+++ b/devtools/server/tests/unit/test_blackboxing-03.js
@@ -37,17 +37,17 @@ function test_black_box() {
line: 4
}, function ({error}, bpClient) {
gBpClient = bpClient;
do_check_true(!error, "Should not get an error: " + error);
gThreadClient.resume(test_black_box_dbg_statement);
});
});
- /* eslint-disable */
+ /* eslint-disable no-multi-spaces */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
debugger; // line 2 - Break here
k(100); // line 3
}, // line 4
gDebuggee,
"1.8",
BLACK_BOXED_URL,
@@ -63,17 +63,17 @@ function test_black_box() {
); // line 6
} // line 7
+ "\n debugger;", // line 8
gDebuggee,
"1.8",
SOURCE_URL,
1
);
- /* eslint-enable */
+ /* eslint-enable no-multi-spaces */
}
function test_black_box_dbg_statement() {
gThreadClient.getSources(function ({error, sources}) {
do_check_true(!error, "Should not get an error: " + error);
let sourceClient = gThreadClient.source(
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
--- a/devtools/server/tests/unit/test_blackboxing-04.js
+++ b/devtools/server/tests/unit/test_blackboxing-04.js
@@ -44,17 +44,17 @@ function test_black_box() {
line: 2
}, function (response) {
do_check_true(!response.error, "Should be able to set breakpoint.");
test_black_box_paused();
});
}
});
- /* eslint-disable */
+ /* eslint-disable no-multi-spaces */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
debugger; // line 2
k(100); // line 3
}, // line 4
gDebuggee,
"1.8",
BLACK_BOXED_URL,
@@ -70,17 +70,17 @@ function test_black_box() {
); // line 6
} // line 7
+ "\n runTest();", // line 8
gDebuggee,
"1.8",
SOURCE_URL,
1
);
- /* eslint-enable */
+ /* eslint-enable no-multi-spaces */
}
function test_black_box_paused() {
gThreadClient.getSources(function ({error, sources}) {
do_check_true(!error, "Should not get an error: " + error);
let sourceClient = gThreadClient.source(
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
--- a/devtools/server/tests/unit/test_blackboxing-05.js
+++ b/devtools/server/tests/unit/test_blackboxing-05.js
@@ -33,17 +33,17 @@ function run_test() {
}
const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
const SOURCE_URL = "http://example.com/source.js";
function test_black_box() {
gClient.addOneTimeListener("paused", test_black_box_exception);
- /* eslint-disable */
+ /* eslint-disable no-multi-spaces, no-unreachable */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
throw new Error("wu tang clan ain't nuthin' ta fuck wit"); // line 2
k(100); // line 3
}, // line 4
gDebuggee,
"1.8",
BLACK_BOXED_URL,
@@ -60,17 +60,17 @@ function test_black_box() {
} // line 7
+ "\ndebugger;\n" // line 8
+ "try { runTest() } catch (ex) { }", // line 9
gDebuggee,
"1.8",
SOURCE_URL,
1
);
- /* eslint-enable */
+ /* eslint-enable no-multi-spaces */
}
function test_black_box_exception() {
gThreadClient.getSources(function ({error, sources}) {
do_check_true(!error, "Should not get an error: " + error);
let sourceClient = gThreadClient.source(
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
--- a/devtools/server/tests/unit/test_blackboxing-06.js
+++ b/devtools/server/tests/unit/test_blackboxing-06.js
@@ -35,17 +35,17 @@ function run_test() {
finishClient(gClient);
});
});
});
do_test_pending();
}
function setup_code() {
- /* eslint-disable */
+ /* eslint-disable no-multi-spaces */
let { code, map } = (new SourceNode(null, null, null, [
new SourceNode(1, 0, "a.js", "" + function a() {
return b();
}),
"\n",
new SourceNode(1, 0, "b.js", "" + function b() {
debugger; // Don't want to stop here.
return c();
@@ -54,17 +54,17 @@ function setup_code() {
new SourceNode(1, 0, "c.js", "" + function c() {
debugger; // Want to stop here.
}),
"\n"
])).toStringWithSourceMap({
file: "abc.js",
sourceRoot: "http://example.com/"
});
- /* eslint-enable */
+ /* eslint-enable no-multi-spaces */
code += "//# sourceMappingURL=data:text/json," + map.toString();
Components.utils.evalInSandbox(code,
gDebuggee,
"1.8",
"http://example.com/abc.js");
}
--- a/devtools/server/tests/unit/test_breakpoint-12.js
+++ b/devtools/server/tests/unit/test_breakpoint-12.js
@@ -50,27 +50,27 @@ function test_child_skip_breakpoint() {
do_check_eq(response.actualLocation.line, location.line + 1);
gBpActor = response.actor;
// Set more breakpoints at the same location.
set_breakpoints(source, location);
});
});
- /* eslint-disable */
+ /* eslint-disable no-multi-spaces */
Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
"function foo() {\n" + // line0 + 1
" this.a = 1;\n" + // line0 + 2
" // A comment.\n" + // line0 + 3
" this.b = 2;\n" + // line0 + 4
"}\n" + // line0 + 5
"debugger;\n" + // line0 + 6
"foo();\n", // line0 + 7
gDebuggee);
- /* eslint-enable */
+ /* eslint-enable no-multi-spaces */
}
// Set many breakpoints at the same location.
function set_breakpoints(source, location) {
do_check_neq(gCount, NUM_BREAKPOINTS);
source.setBreakpoint(location, function (response, bpClient) {
// Check that the breakpoint has properly skipped forward one line.
do_check_eq(response.actualLocation.source.actor, source.actor);
--- a/devtools/shared/webconsole/js-property-provider.js
+++ b/devtools/shared/webconsole/js-property-provider.js
@@ -409,16 +409,17 @@ function getMatchedPropsImpl(obj, match,
continue;
}
if (prop.indexOf("-") > -1) {
continue;
}
// If it is an array index, we can't take it.
// This uses a trick: converting a string to a number yields NaN if
// the operation failed, and NaN is not equal to itself.
+ // eslint-disable-next-line no-self-compare
if (+prop != +prop) {
matches.add(prop);
}
if (matches.size >= MAX_AUTOCOMPLETIONS) {
break;
}
}