From 8922be9c58a1b2a94bf87a06328b3f9dbbb77b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Wed, 28 Feb 2018 18:51:35 +0100 Subject: [PATCH] Bug 1433175 - enable the use-cc-etc eslint rule, r=Standard8. --- .eslintrc.js | 20 ------------------- .../css/generated/generate-properties-db.js | 5 +---- .../tests/unit/test_css-properties-db.js | 3 +-- dom/indexedDB/test/file.js | 1 + .../tests/browser/robocop/robocop_head.js | 1 + testing/xpcshell/dbg-actors.js | 2 +- .../ctypes/tests/unit/test_jsctypes.js | 1 + toolkit/content/datepicker.xhtml | 4 ++-- toolkit/content/timepicker.xhtml | 4 ++-- toolkit/content/widgets/browser.xml | 3 +-- toolkit/content/widgets/datetimebox.xml | 18 ++++++++--------- toolkit/content/widgets/dialog.xml | 2 +- toolkit/content/widgets/menu.xml | 2 +- toolkit/content/widgets/tabbox.xml | 12 ++++------- toolkit/modules/Promise-backend.js | 2 ++ 15 files changed, 28 insertions(+), 52 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f63629dce5d3..c9c99abc25aa 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -64,26 +64,6 @@ module.exports = { "varsIgnorePattern": "^EXPORTED_SYMBOLS$" }] } - }, { - // XXX Bug 1433175. These directories are still being fixed, so turn off - // mozilla/use-cc-etc for now. - "files": [ - "accessible/**", - "browser/**", - "devtools/**", - "dom/**", - "extensions/pref/**", - "mobile/android/**", - "security/manager/**", - "services/**", - "storage/test/**", - "testing/**", - "toolkit/**", - "xpcom/**", - ], - "rules": { - "mozilla/use-cc-etc": "off", - } }, { // XXX Bug 1436303. These directories are still being fixed, so turn off // mozilla/no-cc-etc for now. diff --git a/devtools/shared/css/generated/generate-properties-db.js b/devtools/shared/css/generated/generate-properties-db.js index fdd3f14092c6..bb7e52de5695 100644 --- a/devtools/shared/css/generated/generate-properties-db.js +++ b/devtools/shared/css/generated/generate-properties-db.js @@ -4,8 +4,6 @@ "use strict"; -/* globals InspectorUtils */ - /* * This is an xpcshell script that runs to generate a static list of CSS properties * as known by the platform. It is run from ./mach_commands.py by running @@ -13,8 +11,7 @@ */ var {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {}); var {generateCssProperties} = require("devtools/server/actors/css-properties"); - -Components.utils.importGlobalProperties(["InspectorUtils"]); +const InspectorUtils = require("InspectorUtils"); // xpcshell can output extra information, so place some delimiter text between // the output of the css properties database. diff --git a/devtools/shared/tests/unit/test_css-properties-db.js b/devtools/shared/tests/unit/test_css-properties-db.js index 021c5fd0cea5..5985a227c015 100644 --- a/devtools/shared/tests/unit/test_css-properties-db.js +++ b/devtools/shared/tests/unit/test_css-properties-db.js @@ -22,8 +22,7 @@ const {PSEUDO_ELEMENTS, CSS_PROPERTIES, PREFERENCES} = require("devtools/shared/css/generated/properties-db"); const {generateCssProperties} = require("devtools/server/actors/css-properties"); const {Preferences} = require("resource://gre/modules/Preferences.jsm"); - -Components.utils.importGlobalProperties(["InspectorUtils"]); +const InspectorUtils = require("InspectorUtils"); function run_test() { const propertiesErrorMessage = "If this assertion fails, then the client side CSS " + diff --git a/dom/indexedDB/test/file.js b/dom/indexedDB/test/file.js index ef9f39dca0cf..b71e20652083 100644 --- a/dom/indexedDB/test/file.js +++ b/dom/indexedDB/test/file.js @@ -109,6 +109,7 @@ function verifyBuffers(buffer1, buffer2) function verifyBlob(blob1, blob2, fileId, blobReadHandler) { + // eslint-disable-next-line mozilla/use-cc-etc is(blob1 instanceof Components.interfaces.nsIDOMBlob, true, "Instance of nsIDOMBlob"); is(blob1 instanceof File, blob2 instanceof File, diff --git a/mobile/android/tests/browser/robocop/robocop_head.js b/mobile/android/tests/browser/robocop/robocop_head.js index 615d470562bd..72c07290836e 100644 --- a/mobile/android/tests/browser/robocop/robocop_head.js +++ b/mobile/android/tests/browser/robocop/robocop_head.js @@ -24,6 +24,7 @@ * for more information. */ +/* eslint-disable mozilla/use-cc-etc */ /* eslint-disable mozilla/use-chromeutils-import */ var _quit = false; diff --git a/testing/xpcshell/dbg-actors.js b/testing/xpcshell/dbg-actors.js index 98850e1b6ef0..4894300e60a6 100644 --- a/testing/xpcshell/dbg-actors.js +++ b/testing/xpcshell/dbg-actors.js @@ -8,7 +8,7 @@ /* eslint "mozilla/use-chromeutils-import": ["error", {allowCu: true}] */ // eslint-disable-next-line mozilla/no-define-cc-etc -const Cu = Components.utils; +const Cu = Components.utils; // eslint-disable-line mozilla/use-cc-etc const { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {}); var { Services } = Cu.import("resource://gre/modules/Services.jsm", {}); const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {}); diff --git a/toolkit/components/ctypes/tests/unit/test_jsctypes.js b/toolkit/components/ctypes/tests/unit/test_jsctypes.js index b7f0c38698ee..7f5ef2afd034 100644 --- a/toolkit/components/ctypes/tests/unit/test_jsctypes.js +++ b/toolkit/components/ctypes/tests/unit/test_jsctypes.js @@ -1924,6 +1924,7 @@ function run_FunctionType_tests() { Assert.equal(t4_t.name, "char*(*(**[][8])(int32_t, g_t(*)()))[]"); // Not available in a Worker + // eslint-disable-next-line mozilla/use-cc-etc if ("@mozilla.org/systemprincipal;1" in Components.classes) { var sp = Cc["@mozilla.org/systemprincipal;1"]. createInstance(Ci.nsIPrincipal); diff --git a/toolkit/content/datepicker.xhtml b/toolkit/content/datepicker.xhtml index 45d2cb80db7d..8d640f168e79 100644 --- a/toolkit/content/datepicker.xhtml +++ b/toolkit/content/datepicker.xhtml @@ -42,8 +42,8 @@ // capability, so using |overflow: hidden| is not an option. // Instead, we are inserting a user agent stylesheet that is // capable of selecting scrollbars, and do |display: none|. - var domWinUtls = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); + var domWinUtls = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils); domWinUtls.loadSheetUsingURIString('data:text/css,@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); scrollbar { display: none; }', domWinUtls.AGENT_SHEET); // Create a DatePicker instance and prepare to be // initialized by the "DatePickerInit" event from datetimepopup.xml diff --git a/toolkit/content/timepicker.xhtml b/toolkit/content/timepicker.xhtml index a100ed45bc81..4ecc7c67d635 100644 --- a/toolkit/content/timepicker.xhtml +++ b/toolkit/content/timepicker.xhtml @@ -26,8 +26,8 @@ // capability, so using |overflow: hidden| is not an option. // Instead, we are inserting a user agent stylesheet that is // capable of selecting scrollbars, and do |display: none|. - var domWinUtls = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); + var domWinUtls = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils); domWinUtls.loadSheetUsingURIString('data:text/css,@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); scrollbar { display: none; }', domWinUtls.AGENT_SHEET); // Create a TimePicker instance and prepare to be // initialized by the "TimePickerInit" event from timepicker.xml diff --git a/toolkit/content/widgets/browser.xml b/toolkit/content/widgets/browser.xml index 0647405f4fdf..63e68190f3a6 100644 --- a/toolkit/content/widgets/browser.xml +++ b/toolkit/content/widgets/browser.xml @@ -604,8 +604,7 @@ - Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); + Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); null diff --git a/toolkit/content/widgets/datetimebox.xml b/toolkit/content/widgets/datetimebox.xml index c124a4a1de10..b6aa82c7d076 100644 --- a/toolkit/content/widgets/datetimebox.xml +++ b/toolkit/content/widgets/datetimebox.xml @@ -1605,55 +1605,55 @@ - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + throw Cr.NS_ERROR_NOT_IMPLEMENTED; - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + throw Cr.NS_ERROR_NOT_IMPLEMENTED; - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + throw Cr.NS_ERROR_NOT_IMPLEMENTED; - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + throw Cr.NS_ERROR_NOT_IMPLEMENTED; - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + throw Cr.NS_ERROR_NOT_IMPLEMENTED; - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + throw Cr.NS_ERROR_NOT_IMPLEMENTED; - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + throw Cr.NS_ERROR_NOT_IMPLEMENTED; - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + throw Cr.NS_ERROR_NOT_IMPLEMENTED; - throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + throw Cr.NS_ERROR_NOT_IMPLEMENTED; diff --git a/toolkit/content/widgets/dialog.xml b/toolkit/content/widgets/dialog.xml index a851b760aae5..122a8500ce30 100644 --- a/toolkit/content/widgets/dialog.xml +++ b/toolkit/content/widgets/dialog.xml @@ -459,7 +459,7 @@ var btn = this.getButton(this.defaultButton); if (btn) - btn.setAttribute("default", event.originalTarget == btn || !(event.originalTarget instanceof Components.interfaces.nsIDOMXULButtonElement)); + btn.setAttribute("default", event.originalTarget == btn || !(event.originalTarget instanceof Ci.nsIDOMXULButtonElement)); #endif diff --git a/toolkit/content/widgets/menu.xml b/toolkit/content/widgets/menu.xml index 529c26426bbc..87d533050a55 100644 --- a/toolkit/content/widgets/menu.xml +++ b/toolkit/content/widgets/menu.xml @@ -33,7 +33,7 @@ for (var parent = this.parentNode; parent; parent = parent.parentNode) { - if (parent instanceof Components.interfaces.nsIDOMXULContainerElement) + if (parent instanceof Ci.nsIDOMXULContainerElement) return parent; } return null; diff --git a/toolkit/content/widgets/tabbox.xml b/toolkit/content/widgets/tabbox.xml index 53780015681b..b84dbb0a9dbc 100644 --- a/toolkit/content/widgets/tabbox.xml +++ b/toolkit/content/widgets/tabbox.xml @@ -205,18 +205,14 @@ case "window": this._eventNode = window; break; case "document": this._eventNode = document; break; } - const nsIEventListenerService = - Components.interfaces.nsIEventListenerService; - let els = Components.classes["@mozilla.org/eventlistenerservice;1"] - .getService(nsIEventListenerService); + let els = Cc["@mozilla.org/eventlistenerservice;1"] + .getService(Ci.nsIEventListenerService); els.addSystemEventListener(this._eventNode, "keydown", this, false); - const nsIEventListenerService = - Components.interfaces.nsIEventListenerService; - let els = Components.classes["@mozilla.org/eventlistenerservice;1"] - .getService(nsIEventListenerService); + let els = Cc["@mozilla.org/eventlistenerservice;1"] + .getService(Ci.nsIEventListenerService); els.removeSystemEventListener(this._eventNode, "keydown", this, false); diff --git a/toolkit/modules/Promise-backend.js b/toolkit/modules/Promise-backend.js index 0ee5086b780f..479bc567f5a7 100644 --- a/toolkit/modules/Promise-backend.js +++ b/toolkit/modules/Promise-backend.js @@ -45,9 +45,11 @@ /* global setImmediate:false */ /* eslint-disable mozilla/no-define-cc-etc */ +/* eslint-disable mozilla/use-cc-etc */ var Cu = this.require ? require("chrome").Cu : Components.utils; var Cc = this.require ? require("chrome").Cc : Components.classes; var Ci = this.require ? require("chrome").Ci : Components.interfaces; +/* eslint-enable mozilla/use-cc-etc */ /* eslint-enable mozilla/no-define-cc-etc */ // If we can access Components, then we use it to capture an async // parent stack trace; see scheduleWalkerLoop. However, as it might