Bug 1443661 - Enable ESLint rule no-undef for test files in devtools/client/webconsole/new-console-output/. r=nchevobbe draft
authorMark Banner <standard8@mozilla.com>
Tue, 06 Mar 2018 22:50:58 +0000
changeset 770488 b8437e2bfb7df0eee7d9ede20bbed2a52c2b9af8
parent 770487 a10873c0967268262ff73b27548a37833b394dbd
child 770489 8ae9e13453e9365928c3e74176ec36c58a1c55cc
push id103413
push userbmo:standard8@mozilla.com
push dateWed, 21 Mar 2018 10:41:18 +0000
reviewersnchevobbe
bugs1443661
milestone61.0a1
Bug 1443661 - Enable ESLint rule no-undef for test files in devtools/client/webconsole/new-console-output/. r=nchevobbe MozReview-Commit-ID: 39cCKczUMQI
devtools/.eslintrc.js
devtools/.eslintrc.mochitests.js
devtools/.eslintrc.xpcshell.js
devtools/client/webconsole/new-console-output/test/.eslintrc.js
devtools/client/webconsole/new-console-output/test/.eslintrc.mocha.js
devtools/client/webconsole/new-console-output/test/chrome/.eslintrc.js
devtools/client/webconsole/new-console-output/test/components/.eslintrc.js
devtools/client/webconsole/new-console-output/test/fixtures/.eslintrc.js
devtools/client/webconsole/new-console-output/test/middleware/.eslintrc.js
devtools/client/webconsole/new-console-output/test/mocha-test-setup.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_console.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_console_clear_method.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_closure_inspection.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_file_uri.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_input_field_focus_on_panel_select.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_longstring_expand.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_longstring_hang.js
devtools/client/webconsole/new-console-output/test/mochitest/head.js
devtools/client/webconsole/new-console-output/test/store/.eslintrc.js
devtools/client/webconsole/new-console-output/test/utils/.eslintrc.js
devtools/server/socket/tests/.eslintrc.js
--- a/devtools/.eslintrc.js
+++ b/devtools/.eslintrc.js
@@ -7,16 +7,32 @@ module.exports = {
   "globals": {
     "exports": true,
     "isWorker": true,
     "loader": true,
     "module": true,
     "reportError": true,
     "require": true,
   },
+  "overrides": [{
+    // XXX Bug 1230193. We're still working on enabling no-undef for these test
+    // directories.
+    "files": [
+      "client/memory/test/**",
+      "server/tests/browser/**",
+      "server/tests/mochitest/**",
+      "server/tests/unit/**",
+      "shared/heapsnapshot/tests/unit/**",
+      "shared/tests/unit/**",
+      "shared/webconsole/test/**",
+    ],
+    "rules": {
+      "no-undef": "off",
+    }
+  }],
   "rules": {
     // These are the rules that have been configured so far to match the
     // devtools coding style.
 
     // Rules from the mozilla plugin
     "mozilla/no-aArgs": "error",
     "mozilla/no-single-arg-cu-import": "error",
     // See bug 1224289.
--- a/devtools/.eslintrc.mochitests.js
+++ b/devtools/.eslintrc.mochitests.js
@@ -15,12 +15,14 @@ module.exports = {
 
   "parserOptions": {
     "ecmaFeatures": {
       "jsx": true,
     }
   },
 
   "rules": {
+    // Allow non-camelcase so that run_test doesn't produce a warning.
+    "camelcase": "off",
     // Tests can always import anything.
     "mozilla/reject-some-requires": 0,
   },
 };
--- a/devtools/.eslintrc.xpcshell.js
+++ b/devtools/.eslintrc.xpcshell.js
@@ -1,19 +1,13 @@
 // Parent config file for all devtools xpcshell files.
 module.exports = {
   "extends": [
     "plugin:mozilla/xpcshell-test"
   ],
   "rules": {
     // Allow non-camelcase so that run_test doesn't produce a warning.
     "camelcase": "off",
-    // Allow using undefined variables so that tests can refer to functions
-    // and variables defined in head.js files, without having to maintain a
-    // list of globals in each .eslintrc file.
-    // Note that bug 1168340 will eventually help auto-registering globals
-    // from head.js files.
-    "no-undef": "off",
     "block-scoped-var": "off",
     // Tests can always import anything.
     "mozilla/reject-some-requires": "off",
   }
 };
deleted file mode 100644
--- a/devtools/client/webconsole/new-console-output/test/.eslintrc.js
+++ /dev/null
@@ -1,5 +0,0 @@
-"use strict";
-
-module.exports = {
-  "extends": ["../../../../.eslintrc.xpcshell.js"]
-};
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/new-console-output/test/.eslintrc.mocha.js
@@ -0,0 +1,14 @@
+"use strict";
+
+module.exports = {
+  "env": {
+    "browser": false,
+    "mocha": true,
+  },
+
+  "globals": {
+    // document and window are injected via jsdom-global.
+    "document": false,
+    "window": false,
+  }
+}
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/new-console-output/test/chrome/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+  // Extend from the shared list of defined globals for mochitests.
+  "extends": "../../../../../.eslintrc.mochitests.js"
+};
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/new-console-output/test/components/.eslintrc.js
@@ -0,0 +1,5 @@
+"use strict";
+
+module.exports = {
+  "extends": "../.eslintrc.mocha.js"
+};
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/new-console-output/test/fixtures/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+  // Extend from the shared list of defined globals for mochitests.
+  "extends": "../../../../../.eslintrc.mochitests.js"
+};
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/new-console-output/test/middleware/.eslintrc.js
@@ -0,0 +1,5 @@
+"use strict";
+
+module.exports = {
+  "extends": "../.eslintrc.mocha.js"
+};
--- a/devtools/client/webconsole/new-console-output/test/mocha-test-setup.js
+++ b/devtools/client/webconsole/new-console-output/test/mocha-test-setup.js
@@ -1,10 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* eslint-env node */
+
 "use strict";
 
 const mcRoot = `${__dirname}/../../../../../`;
 const getModule = mcPath => `module.exports = require("${mcRoot}${mcPath}");`;
 
 const { Services: { pref } } = require("devtools-modules");
 pref("devtools.debugger.remote-timeout", 10000);
 pref("devtools.hud.loglimit", 10000);
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_console.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_console.js
@@ -46,16 +46,17 @@ add_task(async function() {
 });
 
 async function testMessages(hud) {
   hud.jsterm.clearOutput(true);
 
   expectUncaughtException();
 
   executeSoon(() => {
+    // eslint-disable-next-line no-undef
     foobarException();
   });
 
   // Add a message from a chrome window.
   hud.iframeWindow.console.log("message from chrome window");
 
   // Check Cu.reportError stack.
   // Use another js script to not depend on the test file line numbers.
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_console_clear_method.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_console_clear_method.js
@@ -1,15 +1,18 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /* import-globals-from head.js */
 
+// XXX Remove this when the file is migrated to the new frontend.
+/* eslint-disable no-undef */
+
 // Check that console.clear() does not clear the output of the browser console.
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf8,<p>Bug 1296870";
 
 add_task(async function() {
   await loadTab(TEST_URI);
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_closure_inspection.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_closure_inspection.js
@@ -1,15 +1,18 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /* import-globals-from head.js */
 
+// XXX Remove this when the file is migrated to the new frontend.
+/* eslint-disable no-undef */
+
 // Check that inspecting a closure in the variables view sidebar works when
 // execution is paused.
 
 "use strict";
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "new-console-output/test/mochitest/test-closures.html";
 
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_file_uri.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_file_uri.js
@@ -1,15 +1,18 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
+// XXX Remove this when the file is migrated to the new frontend.
+/* eslint-disable no-undef */
+
 // See Bug 595223.
 
 const PREF = "devtools.webconsole.persistlog";
 const TEST_FILE = "test-network.html";
 
 var hud;
 
 add_task(async function() {
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_input_field_focus_on_panel_select.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_input_field_focus_on_panel_select.js
@@ -1,15 +1,18 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /* import-globals-from head.js */
 
+// XXX Remove this when the file is migrated to the new frontend.
+/* eslint-disable no-undef */
+
 // Test that the JS input field is focused when the user switches back to the
 // web console from other tools, see bug 891581.
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf8,<p>hello";
 
 add_task(async function() {
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_longstring_expand.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_longstring_expand.js
@@ -1,15 +1,18 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /* import-globals-from head.js */
 
+// XXX Remove this when the file is migrated to the new frontend.
+/* eslint-disable no-undef */
+
 // Test that long strings can be expanded in the console output.
 
 "use strict";
 
 const TEST_URI = "data:text/html;charset=utf8,test for bug 787981 - check " +
                  "that long strings can be expanded in the output.";
 
 add_task(async function() {
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_longstring_hang.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_longstring_hang.js
@@ -1,15 +1,18 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /* import-globals-from head.js */
 
+// XXX Remove this when the file is migrated to the new frontend.
+/* eslint-disable no-undef */
+
 // Test that very long strings do not hang the browser.
 
 "use strict";
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "new-console-output/test/mochitest/" +
                  "test-bug-859170-longstring-hang.html";
 
--- a/devtools/client/webconsole/new-console-output/test/mochitest/head.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/head.js
@@ -1,24 +1,25 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
-/* import-globals-from ../../../../shared/test/shared-head.js */
 /* eslint no-unused-vars: [2, {"vars": "local"}] */
 
 "use strict";
 
 // Import helpers registering the test-actor in remote targets
+/* globals registerTestActor, getTestActor, Task, openToolboxForTab, gBrowser */
 Services.scriptloader.loadSubScript(
   "chrome://mochitests/content/browser/devtools/client/shared/test/test-actor-registry.js",
   this);
 
 // shared-head.js handles imports, constants, and utility functions
 // Load the shared-head file first.
+/* import-globals-from ../../../../shared/test/shared-head.js */
 Services.scriptloader.loadSubScript(
   "chrome://mochitests/content/browser/devtools/client/shared/test/shared-head.js",
   this);
 
 var {HUDService} = require("devtools/client/webconsole/hudservice");
 var WCUL10n = require("devtools/client/webconsole/webconsole-l10n");
 const DOCS_GA_PARAMS = `?${new URLSearchParams({
   "utm_source": "mozilla",
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/new-console-output/test/store/.eslintrc.js
@@ -0,0 +1,5 @@
+"use strict";
+
+module.exports = {
+  "extends": "../.eslintrc.mocha.js"
+};
new file mode 100644
--- /dev/null
+++ b/devtools/client/webconsole/new-console-output/test/utils/.eslintrc.js
@@ -0,0 +1,5 @@
+"use strict";
+
+module.exports = {
+  "extends": "../.eslintrc.mocha.js"
+};
--- a/devtools/server/socket/tests/.eslintrc.js
+++ b/devtools/server/socket/tests/.eslintrc.js
@@ -1,6 +1,6 @@
 "use strict";
 
 module.exports = {
   // Extend from the common devtools mochitest eslintrc config.
-  "extends": "../../../.eslintrc.xpcshell.js"
+  "extends": "../../../.eslintrc.mochitests.js"
 };