Bug 1403956 - Enable ESLint from chrome/ directory. r?Standard8 draft
authorMithilan <mithilan91@gmail.com>
Wed, 25 Oct 2017 10:46:19 -0400
changeset 686166 a277088e7798444b68b1c0930894b750d732cfaf
parent 685217 474827d9661997fc98a5d019724e750330b4a29a
child 737317 652d44557894eaec4a14583d6113722725d62922
push id86114
push userbmo:mithilan91@gmail.com
push dateWed, 25 Oct 2017 14:46:36 +0000
reviewersStandard8
bugs1403956
milestone58.0a1
Bug 1403956 - Enable ESLint from chrome/ directory. r?Standard8 MozReview-Commit-ID: 7pBIWVtXDUq
.eslintrc.js
browser/.eslintrc.js
browser/components/about/test/unit/.eslintrc.js
browser/components/about/test/unit/test_getURIFlags.js
chrome/test/unit/test_bug564667.js
chrome/test/unit/test_data_protocol_registration.js
chrome/test/unit/test_resolve_uris.js
chrome/test/unit_ipc/test_resolve_uris_ipc.js
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,25 +1,20 @@
 "use strict";
 
 module.exports = {
   // New rules and configurations should generally be added in
   // tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js to
   // allow external repositories that use the plugin to pick them up as well.
   "extends": [
     "plugin:mozilla/recommended",
-    "plugin:mozilla/chrome-test",
-    "plugin:mozilla/xpcshell-test"
   ],
   "plugins": [
     "mozilla"
   ],
 
   // The html plugin is enabled via a command line option on eslint. To avoid
   // bad interactions with the xml preprocessor in eslint-plugin-mozilla, we
   // turn off processing of the html plugin for .xml files.
   "settings": {
     "html/xml-extensions": [ ".xhtml" ]
   },
-  "rules": {
-        "no-native-reassign": ["error", {"exceptions": ["run_test"]}]
-    }
 };
--- a/browser/.eslintrc.js
+++ b/browser/.eslintrc.js
@@ -1,11 +1,14 @@
 "use strict";
 
 module.exports = {
+  "extends": [
+    "plugin:mozilla/xpcshell-test",
+  ],
   "rules": {
     // XXX Bug 1326071 - This should be reduced down - probably to 20 or to
     // be removed & synced with the mozilla/recommended value.
     "complexity": ["error", {"max": 40}],
 
     // Disallow empty statements. This will report an error for:
     // try { something(); } catch (e) {}
     // but will not report it for:
--- a/browser/components/about/test/unit/.eslintrc.js
+++ b/browser/components/about/test/unit/.eslintrc.js
@@ -1,7 +1,7 @@
 "use strict";
 
 module.exports = {
   "extends": [
-    "plugin:mozilla/browser-test"
+    "plugin:mozilla/browser-test",
   ]
 };
--- a/browser/components/about/test/unit/test_getURIFlags.js
+++ b/browser/components/about/test/unit/test_getURIFlags.js
@@ -1,18 +1,16 @@
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 
 const contract = "@mozilla.org/network/protocol/about;1?what=newtab";
 const am = Cc[contract].getService(Ci.nsIAboutModule);
 const uri = Services.io.newURI("about:newtab");
 
-/*eslint no-native-reassign: "error"*/
-/*eslint-env browser*/
 function run_test() {
   test_AS_enabled_flags();
   test_AS_disabled_flags();
 }
 
 // Since tiles isn't e10s capable, it shouldn't advertise that it can load in
 // the child.
 function test_AS_disabled_flags() {
--- a/chrome/test/unit/test_bug564667.js
+++ b/chrome/test/unit/test_bug564667.js
@@ -41,18 +41,17 @@ function test_removed_mapping(chromeURL,
 }
 
 /*
  * Checks if any overlay was added after loading
  * the manifest files
  *
  * @param type The type of overlay: overlay|style
  */
-function test_no_overlays(chromeURL, target, type) {
-  type = type || "overlay";
+function test_no_overlays(chromeURL, target, type = "overlay") {
   var uri = gIOS.newURI(chromeURL);
   var overlays = (type == "overlay") ?
       gCR.getXULOverlays(uri) : gCR.getStyleOverlays(uri);
 
   // We shouldn't be allowed to register overlays nor styles
   if (overlays.hasMoreElements()) {
     if (type == "styles")
       do_throw("Style Registered: " + chromeURL);
--- a/chrome/test/unit/test_data_protocol_registration.js
+++ b/chrome/test/unit/test_data_protocol_registration.js
@@ -1,23 +1,23 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
  * vim: sw=2 ts=2 sts=2 tw=78 expandtab :
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-/* globals newAppInfo */
+
 var manifests = [
   do_get_file("data/test_data_protocol_registration.manifest"),
 ];
 registerManifests(manifests);
 
 function run_test() {
   const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
 
-  Components.utils.import("resource://testing-common/AppInfo.jsm", this);
+  let newAppInfo = Components.utils.import("resource://testing-common/AppInfo.jsm", {}).newAppInfo;
   let XULAppInfo = newAppInfo({
     name: "XPCShell",
     ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
     version: "5",
     platformVersion: "1.9",
   });
 
   let XULAppInfoFactory = {
--- a/chrome/test/unit/test_resolve_uris.js
+++ b/chrome/test/unit/test_resolve_uris.js
@@ -79,12 +79,13 @@ function do_run_test() {
       dump(e + "\n");
       do_throw("Should have registered a handler for type '" +
                type + "'\n");
     }
   }
 }
 
 if (typeof run_test === "undefined") {
+  // eslint-disable-next-line no-native-reassign
   run_test = function() {
     do_run_test();
   };
 }
--- a/chrome/test/unit_ipc/test_resolve_uris_ipc.js
+++ b/chrome/test/unit_ipc/test_resolve_uris_ipc.js
@@ -1,9 +1,9 @@
 //
 // Run test script in content process instead of chrome (xpcshell's default)
 //
-/* globals do_run_test */
 function run_test() {
+  /* globals do_run_test */
   load("../unit/test_resolve_uris.js");
   do_run_test();
   run_test_in_child("../unit/test_resolve_uris.js");
 }