Bug 1229874: Part 3 - Enable ESLint in WebExtension code. r=billm

The base .eslintrc is essentially a merge of the root Toolkit .eslintrc and
the devtools .eslintrc, with some minor changes to match our prevalent style.

For the most enforces the coding styles that we've been using most
consistently. There are a couple of significant differences, though:

 * The rule for opening brace alignment can only be applied globally, and
   doesn't make exceptions for top-level functions. I chose to turn it on, and
   change the brace style of existing top-level functions that violated it,
   since the rule seemed worth using, and that's the direction most Toolkit JS
   code has been headed anyway.

 * The rule for switch/case statements requires an added indentation level for
   case statements. Most of our switch statements did not use an extra level
   of indentation, and I initially wrote the rule to enforce that style, until
   I came across case statements that used blocks, and required the extra
   indentation level for sanity.
This commit is contained in:
Kris Maglione
2015-12-02 16:58:53 -08:00
parent 62cc852397
commit 956fe582d0
65 changed files with 1312 additions and 615 deletions

View File

@@ -1,3 +1,5 @@
"use strict";
Components.utils.import("resource://gre/modules/ExtensionUtils.jsm");
var {
EventManager,
@@ -6,6 +8,7 @@ var {
// WeakMap[Extension -> Set(callback)]
var messageHandlers = new WeakMap();
/* eslint-disable mozilla/balanced-listeners */
extensions.on("startup", (type, extension) => {
messageHandlers.set(extension, new Set());
});
@@ -20,6 +23,7 @@ extensions.on("test-message", (type, extension, ...args) => {
handler(...args);
}
});
/* eslint-enable mozilla/balanced-listeners */
extensions.registerAPI((extension, context) => {
return {
@@ -49,11 +53,11 @@ extensions.registerAPI((extension, context) => {
},
assertTrue: function(value, msg) {
extension.emit("test-result", value ? true : false, msg);
extension.emit("test-result", Boolean(value), msg);
},
assertFalse: function(value, msg) {
extension.emit("test-result", !value ? true : false, msg);
extension.emit("test-result", !value, msg);
},
assertEq: function(expected, actual, msg) {