Bug 1344027 - Move eslint-plugin-mozilla's .eslintrc.js file so that all of the plugin is linted, and fix the resulting issues. r=mossop
authorMark Banner <standard8@mozilla.com>
Fri, 03 Mar 2017 10:17:54 +0000
changeset 374986 feea1e54c19bf38897657c5b73458cc48e3f2483
parent 374985 bdd4e1f734a272b61b7a5209c47e61b25fa9baf7
child 374987 8947d02cec5d0de02f090b70d5352e95c51f1abc
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1344027
milestone54.0a1
Bug 1344027 - Move eslint-plugin-mozilla's .eslintrc.js file so that all of the plugin is linted, and fix the resulting issues. r=mossop MozReview-Commit-ID: POYhxkeOaw
tools/lint/eslint/eslint-plugin-mozilla/.eslintrc.js
tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
tools/lint/eslint/eslint-plugin-mozilla/lib/environments/places-overlay.js
tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js
tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js
tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js
tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
tools/lint/eslint/eslint-plugin-mozilla/lib/processors/self-hosted.js
tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xbl-bindings.js
tools/lint/eslint/eslint-plugin-mozilla/lib/rules/.eslintrc.js
tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-removeChild.js
tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-listeners.js
tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-parameters.js
tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-removeEventListener.js
tools/lint/eslint/eslint-plugin-mozilla/tests/test-no-import-into-var-and-global.js
tools/lint/eslint/eslint-plugin-mozilla/tests/test-no-single-arg-cu-import.js
tools/lint/eslint/eslint-plugin-mozilla/tests/use-ownerGlobal.js
rename from tools/lint/eslint/eslint-plugin-mozilla/lib/rules/.eslintrc.js
rename to tools/lint/eslint/eslint-plugin-mozilla/.eslintrc.js
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
@@ -29,43 +29,47 @@ const EXTRA_SCRIPTS = [
   "browser/components/downloads/content/downloads.js",
   "browser/components/downloads/content/indicator.js",
   // This gets loaded into the same scopes as browser.js via browser.xul and
   // placesOverlay.xul.
   "toolkit/content/globalOverlay.js",
   // Via editMenuOverlay.xul
   "toolkit/content/editMenuOverlay.js",
   // Via baseMenuOverlay.xul
-  "browser/base/content/utilityOverlay.js",
+  "browser/base/content/utilityOverlay.js"
 ];
 
 // Some files in global-scripts.inc need mapping to specific locations.
 const MAPPINGS = {
   "printUtils.js": "toolkit/components/printing/content/printUtils.js",
-  "browserPlacesViews.js": "browser/components/places/content/browserPlacesViews.js",
+  "browserPlacesViews.js":
+    "browser/components/places/content/browserPlacesViews.js",
   "panelUI.js": "browser/components/customizableui/content/panelUI.js",
-  "viewSourceUtils.js": "toolkit/components/viewsource/content/viewSourceUtils.js",
+  "viewSourceUtils.js":
+    "toolkit/components/viewsource/content/viewSourceUtils.js"
 };
 
-const globalScriptsRegExp = /<script type=\"application\/javascript\" src=\"(.*)\"\/>/;
+const globalScriptsRegExp =
+  /<script type=\"application\/javascript\" src=\"(.*)\"\/>/;
 
 function getGlobalScriptsIncludes() {
   let globalScriptsPath = path.join(rootDir, "browser", "base", "content",
                                     "global-scripts.inc");
   let fileData = fs.readFileSync(globalScriptsPath, {encoding: "utf8"});
 
   fileData = fileData.split("\n");
 
   let result = [];
 
   for (let line of fileData) {
     let match = line.match(globalScriptsRegExp);
     if (match) {
-      let sourceFile = match[1].replace("chrome://browser/content/", "browser/base/content/")
-                               .replace("chrome://global/content/", "toolkit/content/");
+      let sourceFile =
+        match[1].replace("chrome://browser/content/", "browser/base/content/")
+                .replace("chrome://global/content/", "toolkit/content/");
 
       for (let mapping of Object.getOwnPropertyNames(MAPPINGS)) {
         if (sourceFile.includes(mapping)) {
           sourceFile = MAPPINGS[mapping];
         }
       }
 
       result.push(sourceFile);
@@ -79,18 +83,19 @@ function getScriptGlobals() {
   let fileGlobals = [];
   var scripts = EXTRA_SCRIPTS.concat(getGlobalScriptsIncludes());
   for (let script of scripts) {
     let fileName = path.join(rootDir, script);
     try {
       fileGlobals = fileGlobals.concat(globals.getGlobalsForFile(fileName));
     } catch (e) {
       console.error(`Could not load globals from file ${fileName}: ${e}`);
-      console.error(`You may need to update the mappings in ${module.filename}`);
-      throw new Error(`Could not load globals from file ${fileName}: ${e}`)
+      console.error(
+        `You may need to update the mappings in ${module.filename}`);
+      throw new Error(`Could not load globals from file ${fileName}: ${e}`);
     }
   }
 
   return fileGlobals;
 }
 
 function mapGlobals(fileGlobals) {
   var globalObjects = {};
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/places-overlay.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/places-overlay.js
@@ -12,51 +12,52 @@
 
 // -----------------------------------------------------------------------------
 // Rule Definition
 // -----------------------------------------------------------------------------
 var path = require("path");
 var helpers = require("../helpers");
 var globals = require("../globals");
 var root = helpers.getRootDir(module.filename);
-var modules = require(path.join(root, "tools", "lint", "eslint", "modules.json"));
+var modules = require(path.join(root,
+                                "tools", "lint", "eslint", "modules.json"));
 
 const placesOverlayFiles = [
   "toolkit/content/globalOverlay.js",
   "browser/base/content/utilityOverlay.js",
   "browser/components/places/content/controller.js",
-  "browser/components/places/content/treeView.js",
+  "browser/components/places/content/treeView.js"
 ];
 
 const extraPlacesDefinitions = [
   // Straight definitions.
   {name: "Cc", writable: false},
   {name: "Ci", writable: false},
   {name: "Cr", writable: false},
   {name: "Cu", writable: false},
-  // Via Components.utils / XPCOMUtils.defineLazyModuleGetter (and map to single)
-  // variable.
+  // Via Components.utils / XPCOMUtils.defineLazyModuleGetter (and map to
+  // single) variable.
   {name: "XPCOMUtils", writable: false},
   {name: "Task", writable: false},
   {name: "PlacesUIUtils", writable: false},
-  {name: "PlacesTransactions", writable: false},
-]
+  {name: "PlacesTransactions", writable: false}
+];
 
 const placesOverlayModules = [
-  "PlacesUtils.jsm",
-]
+  "PlacesUtils.jsm"
+];
 
 function getScriptGlobals() {
   let fileGlobals = [];
   for (let file of placesOverlayFiles) {
-    let fileName = path.join(root, file)
+    let fileName = path.join(root, file);
     try {
       fileGlobals = fileGlobals.concat(globals.getGlobalsForFile(fileName));
     } catch (e) {
-      throw new Error(`Could not load globals from file ${fileName}: ${e}`)
+      throw new Error(`Could not load globals from file ${fileName}: ${e}`);
     }
   }
 
   for (let file of placesOverlayModules) {
     if (file in modules) {
       for (let globalVar of modules[file]) {
         fileGlobals.push({name: globalVar, writable: false});
       }
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js
@@ -24,21 +24,21 @@ const simpleTestFiles = [
   "WindowSnapshot.js"
 ];
 const simpleTestPath = "testing/mochitest/tests/SimpleTest";
 
 function getScriptGlobals() {
   let fileGlobals = [];
   let root = helpers.getRootDir(module.filename);
   for (let file of simpleTestFiles) {
-    let fileName = path.join(root, simpleTestPath, file)
+    let fileName = path.join(root, simpleTestPath, file);
     try {
       fileGlobals = fileGlobals.concat(globals.getGlobalsForFile(fileName));
     } catch (e) {
-      throw new Error(`Could not load globals from file ${fileName}: ${e}`)
+      throw new Error(`Could not load globals from file ${fileName}: ${e}`);
     }
   }
 
   return fileGlobals;
 }
 
 function mapGlobals(fileGlobals) {
   var globalObjects = {};
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js
@@ -10,18 +10,18 @@
 
 const path = require("path");
 const fs = require("fs");
 const helpers = require("./helpers");
 const escope = require("escope");
 const estraverse = require("estraverse");
 
 /**
- * Parses a list of "name:boolean_value" or/and "name" options divided by comma or
- * whitespace.
+ * Parses a list of "name:boolean_value" or/and "name" options divided by comma
+ * or whitespace.
  *
  * This function was copied from eslint.js
  *
  * @param {string} string The string to parse.
  * @param {Comment} comment The comment node which has the string.
  * @returns {Object} Result map object of names and boolean values
  */
 function parseBooleanConfig(string, comment) {
@@ -33,17 +33,17 @@ function parseBooleanConfig(string, comm
   string = string.replace(/\s*,\s*/g, ",");
 
   string.split(/\s|,+/).forEach(function(name) {
     if (!name) {
       return;
     }
 
     let pos = name.indexOf(":");
-    let value = undefined;
+    let value;
     if (pos !== -1) {
       value = name.substring(pos + 1, name.length);
       name = name.substring(0, pos);
     }
 
     items[name] = {
       value: (value === "true"),
       comment: comment
@@ -72,17 +72,17 @@ var globalDiscoveryInProgressForFiles = 
  * parents parameter which is a list of the parent nodes of the current node.
  * Each returns an array of globals found.
  *
  * @param  {String} filePath
  *         The absolute path of the file being parsed.
  */
 function GlobalsForNode(filePath) {
   this.path = filePath;
-  this.dirname = path.dirname(this.path)
+  this.dirname = path.dirname(this.path);
   this.root = helpers.getRootDir(this.path);
 }
 
 GlobalsForNode.prototype = {
   BlockComment(node, parents) {
     let value = node.value.trim();
     let match = /^import-globals-from\s+(.+)$/.exec(value);
     if (!match) {
@@ -97,29 +97,31 @@ GlobalsForNode.prototype = {
 
     return module.exports.getGlobalsForFile(filePath);
   },
 
   ExpressionStatement(node, parents, globalScope) {
     let isGlobal = helpers.getIsGlobalScope(parents);
     let globals = helpers.convertExpressionToGlobals(node, isGlobal, this.root);
     // Map these globals now, as getGlobalsForFile is pre-mapped.
-    globals = globals.map(name => { return { name, writable: true }});
+    globals = globals.map(name => {
+      return { name, writable: true };
+    });
 
     // Here we assume that if importScripts is set in the global scope, then
     // this is a worker. It would be nice if eslint gave us a way of getting
     // the environment directly.
     if (globalScope && globalScope.set.get("importScripts")) {
       let workerDetails = helpers.convertWorkerExpressionToGlobals(node,
         isGlobal, this.root, this.dirname);
       globals = globals.concat(workerDetails);
     }
 
     return globals;
-  },
+  }
 };
 
 module.exports = {
   /**
    * Returns all globals for a given file. Recursively searches through
    * import-globals-from directives and also includes globals defined by
    * standard eslint directives.
    *
@@ -151,17 +153,17 @@ module.exports = {
     let ast = helpers.getAST(content);
 
     // Discover global declarations
     let scopeManager = escope.analyze(ast);
     let globalScope = scopeManager.acquire(ast);
 
     let globals = Object.keys(globalScope.variables).map(v => ({
       name: globalScope.variables[v].name,
-      writable: true,
+      writable: true
     }));
 
     // Walk over the AST to find any of our custom globals
     let handler = new GlobalsForNode(path);
 
     helpers.walkAST(ast, (type, node, parents) => {
       // We have to discover any globals that ESLint would have defined through
       // comment directives
@@ -170,17 +172,17 @@ module.exports = {
         value = value.replace(/\n/g, '');
         let match = /^globals?\s+(.+)/.exec(value);
         if (match) {
           let values = parseBooleanConfig(match[1].trim(), node);
           for (let name of Object.keys(values)) {
             globals.push({
               name,
               writable: values[name].value
-            })
+            });
           }
         }
       }
 
       if (type in handler) {
         let newGlobals = handler[type](node, parents, globalScope);
         globals.push.apply(globals, newGlobals);
       }
@@ -213,14 +215,14 @@ module.exports = {
 
     for (let type of Object.keys(GlobalsForNode.prototype)) {
       parser[type] = function(node) {
         if (type === "Program") {
           globalScope = context.getScope();
         }
         let globals = handler[type](node, context.getAncestors(), globalScope);
         helpers.addGlobals(globals, globalScope);
-      }
+      };
     }
 
     return parser;
   }
 };
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js
@@ -30,17 +30,17 @@ var definitions = [
   /^DevToolsUtils\.defineLazyGetter\(this, "(\w+)"/,
   /^Object\.defineProperty\(this, "(\w+)"/,
   /^Reflect\.defineProperty\(this, "(\w+)"/,
   /^this\.__defineGetter__\("(\w+)"/,
   /^this\.(\w+) =/
 ];
 
 var imports = [
-  /^(?:Cu|Components\.utils)\.import\(".*\/((.*?)\.jsm?)"(?:, this)?\)/,
+  /^(?:Cu|Components\.utils)\.import\(".*\/((.*?)\.jsm?)"(?:, this)?\)/
 ];
 
 var workerImportFilenameMatch = /(.*\/)*(.*?\.jsm?)/;
 
 module.exports = {
   /**
    * Gets the abstract syntax tree (AST) of the JavaScript source code contained
    * in sourceText.
@@ -66,19 +66,21 @@ module.exports = {
    *         The AST node to convert.
    *
    * @return {String}
    *         The JS source for the node.
    */
   getASTSource: function(node) {
     switch (node.type) {
       case "MemberExpression":
-        if (node.computed)
+        if (node.computed) {
           throw new Error("getASTSource unsupported computed MemberExpression");
-        return this.getASTSource(node.object) + "." + this.getASTSource(node.property);
+        }
+        return this.getASTSource(node.object) + "." +
+          this.getASTSource(node.property);
       case "ThisExpression":
         return "this";
       case "Identifier":
         return node.name;
       case "Literal":
         return JSON.stringify(node.value);
       case "CallExpression":
         var args = node.arguments.map(a => this.getASTSource(a)).join(", ");
@@ -87,17 +89,18 @@ module.exports = {
         return "{}";
       case "ExpressionStatement":
         return this.getASTSource(node.expression) + ";";
       case "FunctionExpression":
         return "function() {}";
       case "ArrowFunctionExpression":
         return "() => {}";
       case "AssignmentExpression":
-        return this.getASTSource(node.left) + " = " + this.getASTSource(node.right);
+        return this.getASTSource(node.left) + " = " +
+          this.getASTSource(node.right);
       default:
         throw new Error("getASTSource unsupported node type: " + node.type);
     }
   },
 
   /**
    * This walks an AST in a manner similar to ESLint passing node and comment
    * events to the listener. The listener is expected to be a simple function
@@ -171,21 +174,23 @@ module.exports = {
    *
    * @return {Array}
    *         An array of objects that contain details about the globals:
    *         - {String} name
    *                    The name of the global.
    *         - {Boolean} writable
    *                     If the global is writeable or not.
    */
-  convertWorkerExpressionToGlobals: function(node, isGlobal, repository, dirname) {
+  convertWorkerExpressionToGlobals: function(node, isGlobal, repository,
+                                             dirname) {
     var getGlobalsForFile = require("./globals").getGlobalsForFile;
 
     if (!modules) {
-      modules = require(path.join(repository, "tools", "lint", "eslint", "modules.json"));
+      modules = require(path.join(repository,
+        "tools", "lint", "eslint", "modules.json"));
     }
 
     let results = [];
     let expr = node.expression;
 
     if (node.expression.type === "CallExpression" &&
         expr.callee &&
         expr.callee.type === "Identifier" &&
@@ -208,23 +213,23 @@ module.exports = {
       }
     }
 
     return results;
   },
 
   convertExpressionToGlobals: function(node, isGlobal, repository) {
     if (!modules) {
-      modules = require(path.join(repository, "tools", "lint", "eslint", "modules.json"));
+      modules = require(path.join(repository,
+        "tools", "lint", "eslint", "modules.json"));
     }
 
     try {
       var source = this.getASTSource(node);
-    }
-    catch (e) {
+    } catch (e) {
       return [];
     }
 
     for (var reg of definitions) {
       var match = source.match(reg);
       if (match) {
         // Must be in the global scope
         if (!isGlobal) {
@@ -315,17 +320,17 @@ module.exports = {
       range: true,
       loc: true,
       comment: true,
       attachComment: true,
       ecmaVersion: 8,
       sourceType: "script",
       ecmaFeatures: {
         experimentalObjectRestSpread: true,
-        globalReturn: true,
+        globalReturn: true
       }
     };
   },
 
   /**
    * Check whether the context is the global scope.
    *
    * @param {Array} ancestors
@@ -373,19 +378,20 @@ module.exports = {
   getTestHeadFiles: function(scope) {
     if (!this.getIsTest(scope)) {
       return [];
     }
 
     let filepath = this.cleanUpPath(scope.getFilename());
     let dir = path.dirname(filepath);
 
-    let names = fs.readdirSync(dir)
-                  .filter(name => name.startsWith("head") && name.endsWith(".js"))
-                  .map(name => path.join(dir, name));
+    let names =
+      fs.readdirSync(dir)
+        .filter(name => name.startsWith("head") && name.endsWith(".js"))
+        .map(name => path.join(dir, name));
     return names;
   },
 
   /**
    * Gets all the test manifest data for a directory
    *
    * @param  {String} dir
    *         The directory
@@ -407,17 +413,17 @@ module.exports = {
       }
 
       try {
         let manifest = ini.parse(fs.readFileSync(path.join(dir, name), 'utf8'));
 
         manifests.push({
           file: path.join(dir, name),
           manifest
-        })
+        });
       } catch (e) {
       }
     }
 
     directoryManifests.set(dir, manifests);
     return manifests;
   },
 
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
@@ -12,35 +12,38 @@
 // Plugin Definition
 //------------------------------------------------------------------------------
 module.exports = {
   environments: {
     "browser-window": require("../lib/environments/browser-window.js"),
     "chrome-worker": require("../lib/environments/chrome-worker.js"),
     "frame-script": require("../lib/environments/frame-script.js"),
     "places-overlay": require("../lib/environments/places-overlay.js"),
-    "simpletest": require("../lib/environments/simpletest.js"),
+    "simpletest": require("../lib/environments/simpletest.js")
   },
   processors: {
     ".xml": require("../lib/processors/xbl-bindings"),
-    ".js": require("../lib/processors/self-hosted"),
+    ".js": require("../lib/processors/self-hosted")
   },
   rules: {
     "avoid-removeChild": require("../lib/rules/avoid-removeChild"),
     "balanced-listeners": require("../lib/rules/balanced-listeners"),
     "import-globals": require("../lib/rules/import-globals"),
     "import-headjs-globals": require("../lib/rules/import-headjs-globals"),
     "mark-test-function-used": require("../lib/rules/mark-test-function-used"),
     "no-aArgs": require("../lib/rules/no-aArgs"),
     "no-cpows-in-tests": require("../lib/rules/no-cpows-in-tests"),
     "no-single-arg-cu-import": require("../lib/rules/no-single-arg-cu-import"),
-    "no-import-into-var-and-global": require("../lib/rules/no-import-into-var-and-global.js"),
+    "no-import-into-var-and-global":
+      require("../lib/rules/no-import-into-var-and-global.js"),
     "no-useless-parameters": require("../lib/rules/no-useless-parameters"),
-    "no-useless-removeEventListener": require("../lib/rules/no-useless-removeEventListener"),
-    "reject-importGlobalProperties": require("../lib/rules/reject-importGlobalProperties"),
+    "no-useless-removeEventListener":
+      require("../lib/rules/no-useless-removeEventListener"),
+    "reject-importGlobalProperties":
+      require("../lib/rules/reject-importGlobalProperties"),
     "reject-some-requires": require("../lib/rules/reject-some-requires"),
     "use-ownerGlobal": require("../lib/rules/use-ownerGlobal"),
     "var-only-at-top-level": require("../lib/rules/var-only-at-top-level")
   },
   rulesConfig: {
     "avoid-removeChild": 0,
     "balanced-listeners": 0,
     "import-globals": 0,
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/self-hosted.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/self-hosted.js
@@ -36,9 +36,9 @@ module.exports = {
     }
 
     return [lines.join("\n")];
   },
 
   postprocess: function(messages, filename) {
     return Array.prototype.concat.apply([], messages);
   }
-}
+};
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xbl-bindings.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xbl-bindings.js
@@ -9,28 +9,29 @@
 
 "use strict";
 
 const NS_XBL = "http://www.mozilla.org/xbl";
 
 let sax = require("sax");
 
 // Converts sax's error message to something that eslint will understand
-let errorRegex = /(.*)\nLine: (\d+)\nColumn: (\d+)\nChar: (.*)/
+let errorRegex = /(.*)\nLine: (\d+)\nColumn: (\d+)\nChar: (.*)/;
 function parseError(err) {
   let matches = err.message.match(errorRegex);
-  if (!matches)
+  if (!matches) {
     return null;
+  }
 
   return {
     fatal: true,
     message: matches[1],
     line: parseInt(matches[2]) + 1,
     column: parseInt(matches[3])
-  }
+  };
 }
 
 let entityRegex = /&[\w][\w-\.]*;/g;
 
 // A simple sax listener that generates a tree of element information
 function XMLParser(parser) {
   this.parser = parser;
   parser.onopentag = this.onOpenTag.bind(this);
@@ -39,18 +40,18 @@ function XMLParser(parser) {
   parser.onopencdata = this.onOpenCDATA.bind(this);
   parser.oncdata = this.onCDATA.bind(this);
   parser.oncomment = this.onComment.bind(this);
 
   this.document = {
     local: "#document",
     uri: null,
     children: [],
-    comments: [],
-  }
+    comments: []
+  };
   this._currentNode = this.document;
 }
 
 XMLParser.prototype = {
   parser: null,
 
   onOpenTag: function(tag) {
     let node = {
@@ -59,17 +60,17 @@ XMLParser.prototype = {
       namespace: tag.uri,
       attributes: {},
       children: [],
       comments: [],
       textContent: "",
       textLine: this.parser.line,
       textColumn: this.parser.column,
       textEndLine: this.parser.line
-    }
+    };
 
     for (let attr of Object.keys(tag.attributes)) {
       if (tag.attributes[attr].uri == "") {
         node.attributes[attr] = tag.attributes[attr].value;
       }
     }
 
     this._currentNode.children.push(node);
@@ -97,17 +98,17 @@ XMLParser.prototype = {
 
   onCDATA: function(text) {
     this.addText(text);
   },
 
   onComment: function(text) {
     this._currentNode.comments.push(text);
   }
-}
+};
 
 // -----------------------------------------------------------------------------
 // Processor Definition
 // -----------------------------------------------------------------------------
 
 const INDENT_LEVEL = 2;
 
 function indent(count) {
@@ -124,17 +125,18 @@ let scriptLines = [];
 let lineMap = [];
 
 function addSyntheticLine(line, linePos, addDisableLine) {
   lineMap[scriptLines.length] = { line: linePos, offset: null };
   scriptLines.push(line + (addDisableLine ? "" : " // eslint-disable-line"));
 }
 
 /**
- * Adds generated lines from an XBL node to the script to be passed back to eslint.
+ * Adds generated lines from an XBL node to the script to be passed back to
+ * eslint.
  */
 function addNodeLines(node, reindent) {
   let lines = node.textContent.split("\n");
   let startLine = node.textLine;
   let startColumn = node.textColumn;
 
   // The case where there are no whitespace lines before the first text is
   // treated differently for indentation
@@ -153,35 +155,42 @@ function addNodeLines(node, reindent) {
   while (lines.length && lines[lines.length - 1].trim() == "") {
     lines.pop();
   }
 
   if (!indentFirst) {
     let firstLine = lines.shift();
     firstLine = " ".repeat(reindent * INDENT_LEVEL) + firstLine;
     // ESLint counts columns starting at 1 rather than 0
-    lineMap[scriptLines.length] = { line: startLine, offset: reindent * INDENT_LEVEL - (startColumn - 1) };
+    lineMap[scriptLines.length] = {
+      line: startLine,
+      offset: reindent * INDENT_LEVEL - (startColumn - 1)
+    };
     scriptLines.push(firstLine);
     startLine++;
   }
 
-  // Find the preceeding whitespace for all lines that aren't entirely whitespace
+  // Find the preceeding whitespace for all lines that aren't entirely
+  // whitespace.
   let indents = lines.filter(s => s.trim().length > 0)
                      .map(s => s.length - s.trimLeft().length);
   // Find the smallest indent level in use
   let minIndent = Math.min.apply(null, indents);
 
   for (let line of lines) {
     if (line.trim().length == 0) {
       // Don't offset lines that are only whitespace, the only possible JS error
       // is trailing whitespace and we want it to point at the right place
       lineMap[scriptLines.length] = { line: startLine, offset: 0 };
     } else {
       line = " ".repeat(reindent * INDENT_LEVEL) + line.substring(minIndent);
-      lineMap[scriptLines.length] = { line: startLine, offset: reindent * INDENT_LEVEL - (minIndent - 1) };
+      lineMap[scriptLines.length] = {
+        line: startLine,
+        offset: reindent * INDENT_LEVEL - (minIndent - 1)
+      };
     }
 
     scriptLines.push(line);
     startLine++;
   }
 }
 
 module.exports = {
@@ -190,22 +199,22 @@ module.exports = {
     scriptLines = [];
     lineMap = [];
 
     // Non-strict allows us to ignore many errors from entities and
     // preprocessing at the expense of failing to report some XML errors.
     // Unfortunately it also throws away the case of tagnames and attributes
     let parser = sax.parser(false, {
       lowercase: true,
-      xmlns: true,
+      xmlns: true
     });
 
     parser.onerror = function(err) {
       xmlParseError = parseError(err);
-    }
+    };
 
     let xp = new XMLParser(parser);
     parser.write(text);
 
     // Sanity checks to make sure we're dealing with an XBL document
     let document = xp.document;
     if (document.children.length != 1) {
       return [];
@@ -226,17 +235,18 @@ module.exports = {
 
     addSyntheticLine(`this.bindings = {`, bindings.textLine);
 
     for (let binding of bindings.children) {
       if (binding.local != "binding" || binding.namespace != NS_XBL) {
         continue;
       }
 
-      addSyntheticLine(indent(1) + `"${binding.attributes.id}": {`, binding.textLine);
+      addSyntheticLine(indent(1) +
+        `"${binding.attributes.id}": {`, binding.textLine);
 
       for (let part of binding.children) {
         if (part.namespace != NS_XBL) {
           continue;
         }
 
         if (part.local == "implementation") {
           addSyntheticLine(indent(2) + `implementation: {`, part.textLine);
@@ -255,18 +265,20 @@ module.exports = {
             case "field": {
               // Fields are something like lazy getter functions
 
               // Ignore empty fields
               if (item.textContent.trim().length == 0) {
                 continue;
               }
 
-              addSyntheticLine(indent(3) + `get ${item.attributes.name}() {`, item.textLine);
-              addSyntheticLine(indent(4) + `return (`, item.textLine);
+              addSyntheticLine(indent(3) +
+                `get ${item.attributes.name}() {`, item.textLine);
+              addSyntheticLine(indent(4) +
+                `return (`, item.textLine);
 
               // Remove trailing semicolons, as we are adding our own
               item.textContent = item.textContent.replace(/;(?=\s*$)/, "");
               addNodeLines(item, 5);
 
               addSyntheticLine(indent(4) + `);`, item.textLine);
               addSyntheticLine(indent(3) + `},`, item.textEndLine);
               break;
@@ -275,60 +287,70 @@ module.exports = {
             case "destructor": {
               // Constructors and destructors become function declarations
               addSyntheticLine(indent(3) + `${item.local}() {`, item.textLine);
               addNodeLines(item, 4);
               addSyntheticLine(indent(3) + `},`, item.textEndLine);
               break;
             }
             case "method": {
-              // Methods become function declarations with the appropriate params
+              // Methods become function declarations with the appropriate
+              // params.
 
-              let params = item.children.filter(n => n.local == "parameter" && n.namespace == NS_XBL)
+              let params = item.children.filter(n => {
+                return n.local == "parameter" && n.namespace == NS_XBL;
+              })
                                         .map(n => n.attributes.name)
                                         .join(", ");
-              let body = item.children.filter(n => n.local == "body" && n.namespace == NS_XBL)[0];
+              let body = item.children.filter(n => {
+                return n.local == "body" && n.namespace == NS_XBL;
+              })[0];
 
-              addSyntheticLine(indent(3) + `${item.attributes.name}(${params}) {`, item.textLine);
+              addSyntheticLine(indent(3) +
+                `${item.attributes.name}(${params}) {`, item.textLine);
               addNodeLines(body, 4);
               addSyntheticLine(indent(3) + `},`, item.textEndLine);
               break;
             }
             case "property": {
               // Properties become one or two function declarations
               for (let propdef of item.children) {
                 if (propdef.namespace != NS_XBL) {
                   continue;
                 }
 
                 if (propdef.local == "setter") {
-                  addSyntheticLine(indent(3) + `set ${item.attributes.name}(val) {`, propdef.textLine);
+                  addSyntheticLine(indent(3) +
+                    `set ${item.attributes.name}(val) {`, propdef.textLine);
                 } else if (propdef.local == "getter") {
-                  addSyntheticLine(indent(3) + `get ${item.attributes.name}() {`, propdef.textLine);
+                  addSyntheticLine(indent(3) +
+                    `get ${item.attributes.name}() {`, propdef.textLine);
                 } else {
                   continue;
                 }
                 addNodeLines(propdef, 4);
                 addSyntheticLine(indent(3) + `},`, propdef.textEndLine);
               }
               break;
             }
             case "handler": {
-              // Handlers become a function declaration with an `event` parameter
+              // Handlers become a function declaration with an `event`
+              // parameter.
               addSyntheticLine(indent(3) + `function(event) {`, item.textLine);
               addNodeLines(item, 4);
               addSyntheticLine(indent(3) + `},`, item.textEndLine);
               break;
             }
             default:
               continue;
           }
         }
 
-        addSyntheticLine(indent(2) + (part.local == "implementation" ? `},` : `],`), part.textEndLine);
+        addSyntheticLine(indent(2) +
+          (part.local == "implementation" ? `},` : `],`), part.textEndLine);
       }
       addSyntheticLine(indent(1) + `},`, binding.textEndLine);
     }
     addSyntheticLine(`};`, bindings.textEndLine);
 
     let script = scriptLines.join("\n") + "\n";
     return [script];
   },
--- a/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-removeChild.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-removeChild.js
@@ -26,12 +26,12 @@ exports.runTest = function(ruleTester) {
       "elt.parentNode.parentNode.removeChild(elt2.parentNode);",
       "elt.parentNode.removeChild(elt2);",
       "elt.removeChild(elt2);"
     ],
     invalid: [
       invalidCode("elt.parentNode.removeChild(elt);"),
       invalidCode("elt.parentNode.parentNode.removeChild(elt.parentNode);"),
       invalidCode("$(e).parentNode.removeChild($(e));"),
-      invalidCode("$('e').parentNode.removeChild($('e'));"),
+      invalidCode("$('e').parentNode.removeChild($('e'));")
     ]
   });
 };
--- a/tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-listeners.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-listeners.js
@@ -9,18 +9,20 @@
 
 var rule = require("../lib/rules/balanced-listeners");
 
 //------------------------------------------------------------------------------
 // Tests
 //------------------------------------------------------------------------------
 
 function error(code, message) {
-  return {code: code,
-          errors: [{message: message, type: "Identifier"}]};
+  return {
+    code: code,
+    errors: [{message: message, type: "Identifier"}]
+  };
 }
 
 exports.runTest = function(ruleTester) {
   ruleTester.run("balanced-listeners", rule, {
     valid: [
       "elt.addEventListener('event', handler);" +
       "elt.removeEventListener('event', handler);",
 
--- a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-parameters.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-parameters.js
@@ -28,17 +28,17 @@ exports.runTest = function(ruleTester) {
       "Services.io.newURI('http://example.com');",
       "Services.io.newURI('http://example.com', 'utf8');",
       "elt.addEventListener('click', handler);",
       "elt.addEventListener('click', handler, true);",
       "elt.addEventListener('click', handler, {once: true});",
       "elt.removeEventListener('click', handler);",
       "elt.removeEventListener('click', handler, true);",
       "window.getComputedStyle(elt);",
-      "window.getComputedStyle(elt, ':before');",
+      "window.getComputedStyle(elt, ':before');"
     ],
     invalid: [
       {
         code: "Services.prefs.clearUserPref('browser.search.custom', false);",
         errors: callError("clearUserPref takes only 1 parameter.")
       },
       {
         code: "Services.prefs.getBoolPref('browser.search.custom', true);",
@@ -77,21 +77,24 @@ exports.runTest = function(ruleTester) {
         errors: callError("newURI's last parameters are optional.")
       },
       {
         code: "Services.io.newURI('http://example.com', '');",
         errors: callError("newURI's last parameters are optional.")
       },
       {
         code: "elt.addEventListener('click', handler, false);",
-        errors: callError("addEventListener's third parameter can be omitted when it's false.")
+        errors: callError(
+          "addEventListener's third parameter can be omitted when it's false.")
       },
       {
         code: "elt.removeEventListener('click', handler, false);",
-        errors: callError("removeEventListener's third parameter can be omitted when it's false.")
+        errors: callError(
+          "removeEventListener's third parameter can be omitted when it's" +
+          " false.")
       },
       {
         code: "window.getComputedStyle(elt, null);",
         errors: callError("getComputedStyle's second parameter can be omitted.")
       },
       {
         code: "window.getComputedStyle(elt, '');",
         errors: callError("getComputedStyle's second parameter can be omitted.")
--- a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-removeEventListener.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-removeEventListener.js
@@ -50,17 +50,17 @@ exports.runTest = function(ruleTester) {
       // Should not reject when there's a literal and a variable
       "elt.addEventListener('click', function listener() {" +
       "  elt.removeEventListener(eventName, listener);" +
       "});",
 
       // Should not reject when there's 2 different variables
       "elt.addEventListener(event1, function listener() {" +
       "  elt.removeEventListener(event2, listener);" +
-      "});",
+      "});"
     ],
     invalid: [
       invalidCode("elt.addEventListener('click', function listener() {" +
                   "  elt.removeEventListener('click', listener);" +
                   "});"),
       invalidCode("elt.addEventListener('click', function listener() {" +
                   "  elt.removeEventListener('click', listener, true);" +
                   "}, true);"),
@@ -71,12 +71,12 @@ exports.runTest = function(ruleTester) {
                   "  /* Comment */" +
                   "  elt.removeEventListener('click', listener);" +
                   "});"),
       invalidCode("elt.addEventListener('click', function() {" +
                   "  elt.removeEventListener('click', arguments.callee);" +
                   "});"),
       invalidCode("elt.addEventListener(eventName, function listener() {" +
                   "  elt.removeEventListener(eventName, listener);" +
-                  "});"),
+                  "});")
     ]
   });
 };
--- a/tools/lint/eslint/eslint-plugin-mozilla/tests/test-no-import-into-var-and-global.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/test-no-import-into-var-and-global.js
@@ -1,35 +1,35 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
- "use strict";
+"use strict";
 
 //------------------------------------------------------------------------------
 // Requirements
 //------------------------------------------------------------------------------
 
 var rule = require("../lib/rules/no-import-into-var-and-global");
 
 //------------------------------------------------------------------------------
 // Tests
 //------------------------------------------------------------------------------
 
 const ExpectedError = {
   message: "Cu.import imports into variables and into global scope.",
   type: "CallExpression"
-}
+};
 
 exports.runTest = function(ruleTester) {
   ruleTester.run("no-import-into-var-and-global", rule, {
     valid: [
       "var foo = Cu.import('fake', {});",
-      "var foo = Components.utils.import('fake', {});",
+      "var foo = Components.utils.import('fake', {});"
     ],
     invalid: [{
       code: "var foo = Cu.import('fake', this);",
       errors: [ExpectedError]
     }, {
       code: "var foo = Cu.import('fake');",
       errors: [ExpectedError]
     }]
   });
-}
+};
--- a/tools/lint/eslint/eslint-plugin-mozilla/tests/test-no-single-arg-cu-import.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/test-no-single-arg-cu-import.js
@@ -11,21 +11,21 @@ var rule = require("../lib/rules/no-sing
 
 //------------------------------------------------------------------------------
 // Tests
 //------------------------------------------------------------------------------
 
 const ExpectedError = {
   message: "Single argument Cu.import exposes new globals to all modules",
   type: "CallExpression"
-}
+};
 
 exports.runTest = function(ruleTester) {
   ruleTester.run("no-single-arg-cu-import", rule, {
     valid: [
-      "Cu.import('fake', {});",
+      "Cu.import('fake', {});"
     ],
     invalid: [{
       code: "Cu.import('fake');",
       errors: [ExpectedError]
     }]
   });
 };
--- a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-ownerGlobal.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-ownerGlobal.js
@@ -18,17 +18,18 @@ function invalidCode(code) {
   return {code: code, errors: [{message: message, type: "MemberExpression"}]};
 }
 
 exports.runTest = function(ruleTester) {
   ruleTester.run("use-ownerGlobal", rule, {
     valid: [
       "aEvent.target.ownerGlobal;",
       "this.DOMPointNode.ownerGlobal.getSelection();",
-      "windowToMessageManager(node.ownerGlobal);",
+      "windowToMessageManager(node.ownerGlobal);"
     ],
     invalid: [
       invalidCode("aEvent.target.ownerDocument.defaultView;"),
-      invalidCode("this.DOMPointNode.ownerDocument.defaultView.getSelection();"),
-      invalidCode("windowToMessageManager(node.ownerDocument.defaultView);"),
+      invalidCode(
+        "this.DOMPointNode.ownerDocument.defaultView.getSelection();"),
+      invalidCode("windowToMessageManager(node.ownerDocument.defaultView);")
     ]
   });
 };