Bug 1245649: Enable no-negated-in-lhs, no-native-reassign, no-func-assign and no-labels. r=MattN
--- a/toolkit/.eslintrc
+++ b/toolkit/.eslintrc
@@ -57,17 +57,17 @@
// No duplicate keys in object declarations
"no-dupe-keys": 2,
// No duplicate cases in switch statements
"no-duplicate-case": 2,
// No labels
- // "no-labels": 2,
+ "no-labels": 2,
// If an if block ends with a return no need for an else block
// "no-else-return": 2,
// No empty statements
// "no-empty": 2,
// No empty character classes in regex
@@ -81,17 +81,17 @@
// No using !! where casting to boolean is already happening
// "no-extra-boolean-cast": 2,
// No double semicolon
"no-extra-semi": 2,
// No overwriting defined functions
- // "no-func-assign": 2,
+ "no-func-assign": 2,
// No invalid regular expresions
"no-invalid-regexp": 2,
// No odd whitespace characters
"no-irregular-whitespace": 2,
// No single if block inside an else block
@@ -99,20 +99,20 @@
// No mixing spaces and tabs in indent
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
// No unnecessary spacing
// "no-multi-spaces": [2, { exceptions: { "AssignmentExpression": true, "VariableDeclarator": true, "ArrayExpression": true, "ObjectExpression": true } }],
// No reassigning native JS objects
- // "no-native-reassign": 2,
+ "no-native-reassign": 2,
// No (!foo in bar)
- // "no-negated-in-lhs": 2,
+ "no-negated-in-lhs": 2,
// Nested ternary statements are confusing
// "no-nested-ternary": 2,
// Use {} instead of new Object()
// "no-new-object": 2,
// No Math() or JSON()
--- a/toolkit/components/asyncshutdown/AsyncShutdown.jsm
+++ b/toolkit/components/asyncshutdown/AsyncShutdown.jsm
@@ -173,17 +173,17 @@ PromiseSet.prototype = {
value.resolve();
return true;
},
_ensurePromise: function(key) {
if (!key || typeof key != "object") {
throw new Error("Expected an object");
}
- if ((!"then" in key) || typeof key.then != "function") {
+ if ((!("then" in key)) || typeof key.then != "function") {
throw new Error("Expected a Promise");
}
},
};
/**
--- a/toolkit/components/formautofill/FormAutofillStartup.js
+++ b/toolkit/components/formautofill/FormAutofillStartup.js
@@ -44,17 +44,17 @@ FormAutofillStartup.prototype = {
},
// nsIFrameMessageListener
receiveMessage: function (aMessage) {
// Process the "FormAutofill:RequestAutocomplete" message. Any exception
// raised in the parent process is caught and serialized into the reply
// message that is sent to the requesting child process.
FormAutofill.processRequestAutocomplete(aMessage.data)
- .catch(ex => { exception: ex })
+ .catch(ex => { return { exception: ex } })
.then(result => {
// The browser message manager in the parent will send the reply to the
// associated frame message manager in the child.
let browserMM = aMessage.target.messageManager;
browserMM.sendAsyncMessage("FormAutofill:RequestAutocompleteResult",
result);
})
.catch(Cu.reportError);
--- a/toolkit/content/widgets/toolbar.xml
+++ b/toolkit/content/widgets/toolbar.xml
@@ -237,37 +237,42 @@
var paletteChildren = palette ? palette.childNodes : [];
for (let c = 0; c < paletteChildren.length; c++) {
let curNode = paletteChildren[c];
paletteItems[curNode.id] = curNode;
}
var children = this.childNodes;
- iter:
// iterate over the ids to use on the toolbar
for (let i = 0; i < ids.length; i++) {
- let id = ids[i];
+ let id = ids[i];
// iterate over the existing nodes on the toolbar. nodeidx is the
// spot where we want to insert items.
+ let found = false;
for (let c = nodeidx; c < children.length; c++) {
let curNode = children[c];
if (this._idFromNode(curNode) == id) {
// the node already exists. If c equals nodeidx, we haven't
// iterated yet, so the item is already in the right position.
// Otherwise, insert it here.
if (c != nodeidx) {
this.insertBefore(curNode, children[nodeidx]);
}
added[curNode.id] = true;
nodeidx++;
- continue iter; // move on to the next id
+ found = true;
+ break;
}
}
+ if (found) {
+ // move on to the next id
+ continue;
+ }
// the node isn't already on the toolbar, so add a new one.
var nodeToAdd = paletteItems[id] || this._getToolbarItem(id);
if (nodeToAdd && !(nodeToAdd.id in added)) {
added[nodeToAdd.id] = true;
this.insertBefore(nodeToAdd, children[nodeidx] || null);
nodeToAdd.setAttribute("removable", "true");
nodeidx++;
--- a/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
+++ b/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
@@ -189,17 +189,17 @@ var SimpleServiceDiscovery = {
if (!fixedDevices) {
return;
}
fixedDevices = JSON.parse(fixedDevices);
for (let fixedDevice of fixedDevices) {
// Verify we have the right data
- if (!"location" in fixedDevice || !"target" in fixedDevice) {
+ if (!("location" in fixedDevice) || !("target" in fixedDevice)) {
continue;
}
fixedDevice.location = this._forceTrailingSlash(fixedDevice.location);
let service = {
location: fixedDevice.location,
target: fixedDevice.target