Bug 1339559 - Enable no-mixed-operators ESLint rule
MozReview-Commit-ID: LjuiizBh1OK
--- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_runAt.html
+++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_runAt.html
@@ -81,17 +81,17 @@ add_task(function* testExecuteScript() {
// regardless of retries.
browser.test.assertTrue(states[1] == "interactive" || states[1] == "complete",
`document_end state is valid: ${states[1]}`);
browser.test.assertTrue(states[2] == "complete",
`document_idle state is valid: ${states[2]}`);
// If we have the earliest valid states for each script, we're done.
// Otherwise, try again.
- success = (states[0] == "loading" || DEBUG &&
+ success = ((states[0] == "loading" || DEBUG) &&
states[1] == "interactive" &&
states[2] == "complete");
}
browser.test.assertTrue(success, "Got the earliest expected states at least once");
browser.test.notifyPass("executeScript-runAt");
} catch (e) {
--- a/toolkit/components/extensions/.eslintrc.js
+++ b/toolkit/components/extensions/.eslintrc.js
@@ -162,16 +162,19 @@ module.exports = { // eslint-disable-lin
"no-invalid-regexp": "error",
// No odd whitespace characters
"no-irregular-whitespace": "error",
// No single if block inside an else block
"no-lonely-if": "warn",
+ // No mixing different operators without parens
+ "no-mixed-operators": ["error", {"groups": [["&&", "||"], ["==", "!=", "===", "!==", ">", ">=", "<", "<="], ["in", "instanceof"]]}],
+
// No mixing spaces and tabs in indent
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
// Disallow use of multiple spaces (sometimes used to align const values,
// array or object items, etc.). It's hard to maintain and doesn't add that
// much benefit.
"no-multi-spaces": "warn",
--- a/toolkit/components/extensions/ExtensionCommon.jsm
+++ b/toolkit/components/extensions/ExtensionCommon.jsm
@@ -229,17 +229,17 @@ class BaseContext {
* @returns {Error}
*/
normalizeError(error) {
if (error instanceof this.cloneScope.Error) {
return error;
}
let message, fileName;
if (instanceOf(error, "Object") || error instanceof ExtensionError ||
- typeof error == "object" && this.principal.subsumes(Cu.getObjectPrincipal(error))) {
+ (typeof error == "object" && this.principal.subsumes(Cu.getObjectPrincipal(error)))) {
message = error.message;
fileName = error.fileName;
} else {
Cu.reportError(error);
}
message = message || "An unexpected error occurred";
return new this.cloneScope.Error(message, fileName);
}
--- a/toolkit/components/extensions/ext-c-runtime.js
+++ b/toolkit/components/extensions/ext-c-runtime.js
@@ -9,17 +9,17 @@ function runtimeApiFactory(context) {
onMessage: context.messenger.onMessage("runtime.onMessage"),
onConnectExternal: context.messenger.onConnectExternal("runtime.onConnectExternal"),
onMessageExternal: context.messenger.onMessageExternal("runtime.onMessageExternal"),
connect: function(extensionId, connectInfo) {
- let name = connectInfo !== null && connectInfo.name || "";
+ let name = (connectInfo !== null && connectInfo.name) || "";
extensionId = extensionId || extension.id;
let recipient = {extensionId};
return context.messenger.connect(context.messageManager, name, recipient);
},
sendMessage: function(...args) {
let options; // eslint-disable-line no-unused-vars
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html
@@ -80,17 +80,17 @@ function background() {
browser.test.log(`onBeforeRequest upload: ${details.url} ${JSON.stringify(details.requestBody)}`);
browser.test.assertTrue(!!requestBody, `Intercepted upload ${details.url} #${details.requestId} ${upload} have a requestBody`);
if (!requestBody) {
return;
}
let byteLength = parseInt(upload, 10);
if (byteLength) {
browser.test.assertTrue(!!requestBody.raw, `Binary upload ${details.url} #${details.requestId} ${upload} have a raw attribute`);
- browser.test.assertEq(byteLength, requestBody.raw && requestBody.raw.map(r => r.bytes && r.bytes.byteLength || 0).reduce((a, b) => a + b), `Binary upload size matches`);
+ browser.test.assertEq(byteLength, requestBody.raw && requestBody.raw.map(r => r.bytes ? r.bytes.byteLength : 0).reduce((a, b) => a + b), `Binary upload size matches`);
return;
}
if ("raw" in requestBody) {
browser.test.assertEq(upload, JSON.stringify(requestBody.raw).replace(/(\bfile: ")[^"]+/, "$1<file>"), `Upload ${details.url} #${details.requestId} matches raw data`);
} else {
browser.test.assertEq(upload, JSON.stringify(requestBody.formData), `Upload ${details.url} #${details.requestId} matches form data.`);
}
}
--- a/toolkit/components/extensions/test/xpcshell/test_ext_storage_sync.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_storage_sync.js
@@ -116,17 +116,17 @@ class KintoServer {
installBatchPath() {
const batchPath = "/v1/batch";
function handlePost(request, response) {
let bodyStr = CommonUtils.readBytesFromInputStream(request.bodyInputStream);
let body = JSON.parse(bodyStr);
let defaults = body.defaults;
for (let req of body.requests) {
- let headers = Object.assign({}, defaults && defaults.headers || {}, req.headers);
+ let headers = Object.assign({}, (defaults && defaults.headers) || {}, req.headers);
// FIXME: assert auth is "Bearer ...token..."
this.posts.push(Object.assign({}, req, {headers}));
}
response.setStatusLine(null, 200, "OK");
response.setHeader("Content-Type", "application/json; charset=UTF-8");
response.setHeader("Date", (new Date()).toUTCString());
--- a/toolkit/modules/addons/WebRequest.jsm
+++ b/toolkit/modules/addons/WebRequest.jsm
@@ -57,17 +57,17 @@ var RequestId = {
let id = (this.count++).toString();
if (channel) {
getData(channel).requestId = id;
}
return id;
},
get(channel) {
- return channel && getData(channel).requestId || this.create(channel);
+ return (channel && getData(channel).requestId) || this.create(channel);
},
};
function runLater(job) {
Services.tm.currentThread.dispatch(job, Ci.nsIEventTarget.DISPATCH_NORMAL);
}
function parseFilter(filter) {