Bug 1436303 - Enable mozilla/no-define-cc-etc for some DevTools files;r=standard8,ochameau draft
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 08 Jun 2018 16:46:59 +0200
changeset 807411 ba540ae9fe94cee956c4a264de3283124d70a0ce
parent 805786 e0595117ff5bda3a63a72ad7b3b8754fec4fb4f0
push id113097
push userjdescottes@mozilla.com
push dateThu, 14 Jun 2018 13:44:15 +0000
reviewersstandard8, ochameau
bugs1436303
milestone62.0a1
Bug 1436303 - Enable mozilla/no-define-cc-etc for some DevTools files;r=standard8,ochameau MozReview-Commit-ID: IbSt6lAhOYt
.eslintrc.js
devtools/.eslintrc.js
devtools/client/shared/test/shared-head.js
devtools/shared/base-loader.js
devtools/shared/worker/loader.js
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -35,25 +35,16 @@ module.exports = {
       "browser/components/search/content/search.xml",
       "browser/components/translation/translation-infobar.xml",
       "toolkit/components/prompts/content/tabprompts.xml"
     ],
     "env": {
       "mozilla/browser-window": true
     }
   }, {
-    // XXX Bug 1436303. These directories are still being fixed, so turn off
-    // mozilla/no-cc-etc for now.
-    "files": [
-      "devtools/**"
-    ],
-    "rules": {
-      "mozilla/no-define-cc-etc": "off",
-    }
-  }, {
     // XXX Bug 1452706. These directories are still being fixed, so turn off
     //  mozilla/require-expected-throws-or-rejects for now.
     "files": [
       "services/fxaccounts/**",
       "toolkit/components/**",
     ],
     "rules": {
       "mozilla/rejects-requires-await": "off",
--- a/devtools/.eslintrc.js
+++ b/devtools/.eslintrc.js
@@ -144,17 +144,50 @@ module.exports = {
   }, {
     // 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"}],
     }
-  }],
+  }, {
+    // Cu, Cc etc... are not available in most devtools modules loaded by require.
+    "files": [
+      "**"
+    ],
+    "excludedFiles": [
+      // Enable the rule on JSM, test head files and some specific files.
+      "**/*.jsm",
+      "**/test/**/head.js",
+      "**/test/**/shared-head.js",
+      "client/debugger/test/mochitest/code_frame-script.js",
+      "client/inspector/animation-old/test/doc_frame_script.js",
+      "client/inspector/animation/test/doc_frame_script.js",
+      "client/inspector/rules/test/doc_frame_script.js",
+      "client/inspector/shared/test/doc_frame_script.js",
+      "client/jsonview/converter-observer.js",
+      "client/jsonview/test/doc_frame_script.js",
+      "client/responsive.html/browser/content.js",
+      "client/shared/browser-loader.js",
+      "server/actors/webconsole/content-process-forward.js",
+      "server/actors/worker/service-worker-process.js",
+      "server/startup/content-process.js",
+      "server/startup/frame.js",
+      "shared/base-loader.js",
+      "shared/worker/loader.js",
+      "startup/aboutdebugging-registration.js",
+      "startup/aboutdevtools/aboutdevtools-registration.js",
+      "startup/aboutdevtoolstoolbox-registration.js",
+      "startup/devtools-startup.js",
+    ],
+    "rules": {
+      "mozilla/no-define-cc-etc": "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/client/shared/test/shared-head.js
+++ b/devtools/client/shared/test/shared-head.js
@@ -5,18 +5,17 @@
 /* eslint no-unused-vars: [2, {"vars": "local"}] */
 
 "use strict";
 
 // This shared-head.js file is used for multiple mochitest test directories in
 // devtools.
 // It contains various common helper functions.
 
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr, Constructor: CC}
-  = Components;
+const { Constructor: CC } = Components;
 
 function scopedCuImport(path) {
   const scope = {};
   ChromeUtils.import(path, scope);
   return scope;
 }
 
 const {ScratchpadManager} = scopedCuImport("resource://devtools/client/scratchpad/scratchpad-manager.jsm");
--- a/devtools/shared/base-loader.js
+++ b/devtools/shared/base-loader.js
@@ -4,18 +4,17 @@
 
 /* global __URI__ */
 /* exported Loader, resolveURI, Module, Require, unload */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["Loader", "resolveURI", "Module", "Require", "unload"];
 
-const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu,
-        results: Cr, manager: Cm } = Components;
+const { Constructor: CC, manager: Cm } = Components;
 const systemPrincipal = CC("@mozilla.org/systemprincipal;1", "nsIPrincipal")();
 
 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
 const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
 const { normalize, dirname } = ChromeUtils.import("resource://gre/modules/osfile/ospath_unix.jsm", {});
 
 XPCOMUtils.defineLazyServiceGetter(this, "resProto",
                                    "@mozilla.org/network/protocol;1?name=resource",
--- a/devtools/shared/worker/loader.js
+++ b/devtools/shared/worker/loader.js
@@ -444,22 +444,17 @@ var {
   rpc,
   loadSubScript,
   reportError,
   setImmediate,
   xpcInspector,
 } = (function() {
   // Main thread
   if (typeof Components === "object") {
-    const {
-      Constructor: CC,
-      classes: Cc,
-      interfaces: Ci,
-      utils: Cu
-    } = Components;
+    const { Constructor: CC } = Components;
 
     const principal = CC("@mozilla.org/systemprincipal;1", "nsIPrincipal")();
 
     // To ensure that the this passed to addDebuggerToGlobal is a global, the
     // Debugger object needs to be defined in a sandbox.
     const sandbox = Cu.Sandbox(principal, {});
     Cu.evalInSandbox(
       "Components.utils.import('resource://gre/modules/jsdebugger.jsm');" +