Bug 1589333 - Enable ESLint for all of devtools/client/shared/ (manual changes). r=Standard8,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D50637

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Richard O. Gregory 2019-11-04 18:05:14 +00:00
parent e6f8e04a02
commit 8640fa2942
32 changed files with 91 additions and 28 deletions

View file

@ -56,9 +56,6 @@ browser/extensions/formautofill/phonenumberutils/PhoneNumberMetaData.jsm
# devtools/ exclusions # devtools/ exclusions
devtools/client/inspector/markup/test/doc_markup_events_*.html devtools/client/inspector/markup/test/doc_markup_events_*.html
devtools/client/performance/components/test/test_jit_optimizations_01.html devtools/client/performance/components/test/test_jit_optimizations_01.html
devtools/client/shared/test/*.html
devtools/client/shared/components/test/mochitest/*.html
!devtools/client/shared/components/test/mochitest/test_stack-trace.html
devtools/server/tests/browser/storage-*.html devtools/server/tests/browser/storage-*.html
!devtools/server/tests/browser/storage-unsecured-iframe.html !devtools/server/tests/browser/storage-unsecured-iframe.html
devtools/server/tests/browser/stylesheets-nested-iframes.html devtools/server/tests/browser/stylesheets-nested-iframes.html

View file

@ -75,6 +75,9 @@
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
const FUDGE_FACTOR = .5; const FUDGE_FACTOR = .5;
function aboutEq(a, b) { function aboutEq(a, b) {
dumpn(`Checking ${a} ~= ${b}`); dumpn(`Checking ${a} ~= ${b}`);
@ -93,7 +96,7 @@ window.onload = async function () {
const resizedA = []; const resizedA = [];
const resizedD = []; const resizedD = [];
const scene = ReactDOM.render([ ReactDOM.render([
dom.header({}, "header"), dom.header({}, "header"),
dom.aside({className: "a"}, "A"), dom.aside({className: "a"}, "A"),
GridElementWidthResizer({ GridElementWidthResizer({

View file

@ -76,6 +76,9 @@
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
const FUDGE_FACTOR = .5; const FUDGE_FACTOR = .5;
function aboutEq(a, b) { function aboutEq(a, b) {
dumpn(`Checking ${a} ~= ${b}`); dumpn(`Checking ${a} ~= ${b}`);
@ -94,7 +97,7 @@ window.onload = async function () {
const resizedA = []; const resizedA = [];
const resizedD = []; const resizedD = [];
const scene = ReactDOM.render([ ReactDOM.render([
dom.header({}, "header"), dom.header({}, "header"),
dom.aside({className: "a"}, "A"), dom.aside({className: "a"}, "A"),
GridElementWidthResizer({ GridElementWidthResizer({

View file

@ -24,6 +24,9 @@ Basic tests for the HSplitBox component.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
const FUDGE_FACTOR = .1; const FUDGE_FACTOR = .1;
function aboutEq(a, b) { function aboutEq(a, b) {
dumpn(`Checking ${a} ~= ${b}`); dumpn(`Checking ${a} ~= ${b}`);
@ -57,7 +60,7 @@ window.onload = async function () {
return el; return el;
} }
const box = await renderBox(); await renderBox();
// Test that we properly rendered our two panes. // Test that we properly rendered our two panes.

View file

@ -22,6 +22,8 @@ Test that Accordion renders correctly.
"use strict"; "use strict";
/* global sinon */
window.onload = async function() { window.onload = async function() {
try { try {
const { button, div } = require("devtools/client/shared/vendor/react-dom-factories"); const { button, div } = require("devtools/client/shared/vendor/react-dom-factories");

View file

@ -21,6 +21,9 @@ with optional columns, unknown and non-URL sources.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -16,6 +16,9 @@ Test that the frame component reacts to source-map pref changse.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const Services = browserRequire("Services"); const Services = browserRequire("Services");

View file

@ -63,7 +63,7 @@ window.onload = function() {
const tree = ReactDOM.render(list, document.body); const tree = ReactDOM.render(list, document.body);
const listEl = findRenderedDOMComponentWithClass(tree, "list"); const listEl = findRenderedDOMComponentWithClass(tree, "list");
const items = scryRenderedDOMComponentsWithTag(tree, "li"); scryRenderedDOMComponentsWithTag(tree, "li");
const defaultFocus = listEl.ownerDocument.body; const defaultFocus = listEl.ownerDocument.body;
function blurEl(el) { function blurEl(el) {
@ -250,7 +250,7 @@ window.onload = function() {
}]; }];
for (const test of tests) { for (const test of tests) {
const { action, condition, event, state, name } = test; const { action, event, state, name } = test;
is(listEl, findRenderedDOMComponentWithClass(tree, "list"), "Sanity check"); is(listEl, findRenderedDOMComponentWithClass(tree, "list"), "Sanity check");

View file

@ -21,6 +21,9 @@ Test for Notification Box. The test is checking:
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -17,6 +17,9 @@ Test for Notification Box. The test is checking:
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -17,6 +17,9 @@ Test for Notification Box. The test is checking:
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");
@ -29,7 +32,7 @@ window.onload = async function () {
const notificationNode = ReactDOM.findDOMNode(notificationBox); const notificationNode = ReactDOM.findDOMNode(notificationBox);
let buttonCallbackExecuted = false; let buttonCallbackExecuted = false;
var buttons = [{ const buttons = [{
label: "Button1", label: "Button1",
callback: () => { callback: () => {
buttonCallbackExecuted = true; buttonCallbackExecuted = true;

View file

@ -85,7 +85,6 @@ window.onload = async function () {
}, },
onChange: () => null, onChange: () => null,
}); });
const { refs } = component;
async function testSearchBoxWithAutocomplete() { async function testSearchBoxWithAutocomplete() {
ok(!$(".devtools-autocomplete-popup"), "Autocomplete list not visible"); ok(!$(".devtools-autocomplete-popup"), "Autocomplete list not visible");

View file

@ -16,6 +16,9 @@ Test sidebar toggle button
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
const SidebarToggle = browserRequire("devtools/client/shared/components/SidebarToggle.js"); const SidebarToggle = browserRequire("devtools/client/shared/components/SidebarToggle.js");

View file

@ -16,6 +16,9 @@ Test tabs accessibility.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -21,6 +21,9 @@ Test all-tabs menu.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -35,7 +35,7 @@ window.onload = function() {
const TreeView = const TreeView =
browserRequire("devtools/client/shared/components/tree/TreeView"); browserRequire("devtools/client/shared/components/tree/TreeView");
const props = { const _props = {
...TEST_TREE_VIEW_INTERFACE, ...TEST_TREE_VIEW_INTERFACE,
renderValue: props => { renderValue: props => {
return (props.value === "C" ? return (props.value === "C" ?
@ -47,7 +47,7 @@ window.onload = function() {
); );
}, },
}; };
const treeView = React.createElement(TreeView, props); const treeView = React.createElement(TreeView, _props);
const tree = ReactDOM.render(treeView, document.body); const tree = ReactDOM.render(treeView, document.body);
const treeViewEl = findRenderedDOMComponentWithClass(tree, "treeTable"); const treeViewEl = findRenderedDOMComponentWithClass(tree, "treeTable");
const rows = scryRenderedDOMComponentsWithClass(tree, "treeRow"); const rows = scryRenderedDOMComponentsWithClass(tree, "treeRow");
@ -251,7 +251,7 @@ window.onload = function() {
}]; }];
for (const test of tests) { for (const test of tests) {
const { action, condition, event, state, name } = test; const { action, event, state, name } = test;
info(name); info(name);
if (event) { if (event) {

View file

@ -74,7 +74,7 @@ window.onload = function() {
}]; }];
for (const test of tests) { for (const test of tests) {
const { action, condition, event, state, name } = test; const { action, event, state, name } = test;
info(name); info(name);
if (event) { if (event) {
@ -98,6 +98,7 @@ window.onload = function() {
if (label === "C") { if (label === "C") {
return ["hide"]; return ["hide"];
} }
return [];
} }
} }
}; };

View file

@ -17,6 +17,9 @@ depth.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -16,6 +16,9 @@ Test that collapsed subtrees aren't rendered.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -16,6 +16,9 @@ Test Tree's autoExpandDepth.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -16,6 +16,9 @@ Test that we only render visible tree items.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
function getSpacerHeights() { function getSpacerHeights() {

View file

@ -17,6 +17,9 @@ Test that arrows get the open attribute when their item's children are expanded.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -18,6 +18,9 @@ other inputs.
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -17,6 +17,9 @@ Test that when an item in the Tree component is expanded or collapsed the approp
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -17,6 +17,9 @@ Test that when an item in the Tree component is expanded or collapsed the approp
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");
@ -32,7 +35,7 @@ window.onload = async function () {
return ReactDOM.render(Tree(treeProps), window.document.body); return ReactDOM.render(Tree(treeProps), window.document.body);
} }
const tree = renderTree({ focused: "A" }); renderTree({ focused: "A" });
isRenderedTree(document.body.textContent, [ isRenderedTree(document.body.textContent, [
"A:true", "A:true",

View file

@ -29,6 +29,9 @@ Test that when an item in the Tree component is focused by arrow key, the view i
<pre id="test"> <pre id="test">
<script src="head.js" type="application/javascript"></script> <script src="head.js" type="application/javascript"></script>
<script type="application/javascript"> <script type="application/javascript">
'use strict'
window.onload = async function () { window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");

View file

@ -29,7 +29,6 @@ window.onload = async function() {
Simulate, Simulate,
findRenderedDOMComponentWithClass, findRenderedDOMComponentWithClass,
findRenderedDOMComponentWithTag, findRenderedDOMComponentWithTag,
scryRenderedDOMComponentsWithTag,
} = browserRequire("devtools/client/shared/vendor/react-dom-test-utils"); } = browserRequire("devtools/client/shared/vendor/react-dom-test-utils");
const Tree = createFactory( const Tree = createFactory(
browserRequire("devtools/client/shared/components/VirtualizedTree")); browserRequire("devtools/client/shared/components/VirtualizedTree"));
@ -209,7 +208,7 @@ window.onload = async function() {
}]; }];
for (const test of tests) { for (const test of tests) {
const { action, condition, event, props, name } = test; const { action, event, props, name } = test;
info(name); info(name);
if (event) { if (event) {
@ -225,6 +224,7 @@ window.onload = async function() {
if (test.activeElement) { if (test.activeElement) {
const expected = typeof test.activeElement === "string" ? const expected = typeof test.activeElement === "string" ?
els[test.activeElement] : test.activeElement; els[test.activeElement] : test.activeElement;
// eslint-disable-next-line no-debugger
if (document.activeElement!==expected) {debugger;} if (document.activeElement!==expected) {debugger;}
is(document.activeElement, expected, "Focus is set correctly."); is(document.activeElement, expected, "Focus is set correctly.");
} }

View file

@ -36,8 +36,6 @@ window.onload = async function () {
try { try {
const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom"); const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");
const { createFactory } = browserRequire("devtools/client/shared/vendor/react"); const { createFactory } = browserRequire("devtools/client/shared/vendor/react");
const { Simulate } =
browserRequire("devtools/client/shared/vendor/react-dom-test-utils");
const Tree = const Tree =
createFactory(browserRequire("devtools/client/shared/components/VirtualizedTree")); createFactory(browserRequire("devtools/client/shared/components/VirtualizedTree"));

View file

@ -16,6 +16,7 @@
window.addEventListener("load", function() { window.addEventListener("load", function() {
function initialSetup(event) { function initialSetup(event) {
// eslint-disable-next-line no-debugger
debugger; debugger;
const button = document.querySelector("button"); const button = document.querySelector("button");
button.onclick = clickHandler; button.onclick = clickHandler;

View file

@ -20,6 +20,7 @@
function initialSetup(event) { function initialSetup(event) {
const button = document.getElementById("initialSetup"); const button = document.getElementById("initialSetup");
button.removeEventListener("click", initialSetup); button.removeEventListener("click", initialSetup);
// eslint-disable-next-line no-debugger
debugger; debugger;
} }
@ -27,24 +28,24 @@
window.foobar = "clicker"; window.foobar = "clicker";
} }
function handleEventClick() { function HandleEventClick() {
const button = document.getElementById("handleEventClick"); const button = document.getElementById("handleEventClick");
// Create a long prototype chain to test for weird edge cases. // Create a long prototype chain to test for weird edge cases.
button.addEventListener("click", Object.create(Object.create(this))); button.addEventListener("click", Object.create(Object.create(this)));
} }
handleEventClick.prototype.handleEvent = function() { HandleEventClick.prototype.handleEvent = function() {
window.foobar = "handleEventClick"; window.foobar = "HandleEventClick";
}; };
function boundHandleEventClick() { function BoundHandleEventClick() {
const button = document.getElementById("boundHandleEventClick"); const button = document.getElementById("boundHandleEventClick");
this.handleEvent = this.handleEvent.bind(this); this.handleEvent = this.handleEvent.bind(this);
button.addEventListener("click", this); button.addEventListener("click", this);
} }
boundHandleEventClick.prototype.handleEvent = function() { BoundHandleEventClick.prototype.handleEvent = function() {
window.foobar = "boundHandleEventClick"; window.foobar = "BoundHandleEventClick";
}; };
const button = document.getElementById("clicker"); const button = document.getElementById("clicker");
@ -52,8 +53,8 @@
const boundClicker = clicker.bind(this).bind(this).bind(this); const boundClicker = clicker.bind(this).bind(this).bind(this);
button.addEventListener("click", boundClicker); button.addEventListener("click", boundClicker);
new handleEventClick(); new HandleEventClick();
new boundHandleEventClick(); new BoundHandleEventClick();
const initButton = document.getElementById("initialSetup"); const initButton = document.getElementById("initialSetup");
initButton.addEventListener("click", initialSetup); initButton.addEventListener("click", initialSetup);

View file

@ -13,7 +13,10 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
/* exported runDebuggerStatement */
function runDebuggerStatement() { function runDebuggerStatement() {
// eslint-disable-next-line no-debugger
debugger; debugger;
} }
</script> </script>

View file

@ -8,10 +8,11 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
/* exported initialSetup */
function initialSetup(event) { function initialSetup(event) {
// eslint-disable-next-line no-debugger
debugger; debugger;
} }
window.addEventListener("load", function() {}); window.addEventListener("load", function() {});
</script> </script>
</head> </head>