Bug 1346671 - Enable the no-useless-concat eslint rule in toolkit/
MozReview-Commit-ID: 1a422BiLEhK
--- a/browser/base/content/test/plugins/browser_blocklist_content.js
+++ b/browser/base/content/test/plugins/browser_blocklist_content.js
@@ -67,17 +67,17 @@ add_task(function* () {
add_task(function* () {
yield promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html>GO!</html>");
yield asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
// Hack the planet! Load our blocklist shim, so we can mess with blocklist
// return results in the content process. Active until we close our tab.
let mm = gTestBrowser.messageManager;
- info("test 3a: loading " + gChromeRoot + "blocklist_proxy.js" + "\n");
+ info("test 3a: loading " + gChromeRoot + "blocklist_proxy.js\n");
mm.loadFrameScript(gChromeRoot + "blocklist_proxy.js", true);
yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
yield promiseUpdatePluginBindings(gTestBrowser);
yield ContentTask.spawn(gTestBrowser, {}, function* () {
--- a/browser/components/customizableui/test/browser_1087303_button_preferences.js
+++ b/browser/components/customizableui/test/browser_1087303_button_preferences.js
@@ -37,14 +37,14 @@ function waitForPageLoad(aTab) {
let timeoutId = setTimeout(() => {
aTab.linkedBrowser.removeEventListener("load", onTabLoad, true);
deferred.reject("Page didn't load within " + 20000 + "ms");
}, 20000);
function onTabLoad(event) {
clearTimeout(timeoutId);
aTab.linkedBrowser.removeEventListener("load", onTabLoad, true);
- info("Tab event received: " + "load");
+ info("Tab event received: load");
deferred.resolve();
}
aTab.linkedBrowser.addEventListener("load", onTabLoad, true, true);
return deferred.promise;
}
--- a/browser/components/migration/ESEDBReader.jsm
+++ b/browser/components/migration/ESEDBReader.jsm
@@ -427,17 +427,17 @@ ESEDB.prototype = {
},
_convertResult(column, buffer, err) {
if (err != 0) {
if (err == 1004) {
// Deal with null values:
buffer = null;
} else {
- Cu.reportError("Unexpected JET error: " + err + ";" + " retrieving value for column " + column.name);
+ Cu.reportError("Unexpected JET error: " + err + "; retrieving value for column " + column.name);
throw new Error(convertESEError(err));
}
}
if (column.type == "string") {
return buffer ? buffer.readString() : "";
}
if (column.type == "boolean") {
return buffer ? (buffer.value == 255) : false;
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
@@ -25,17 +25,17 @@ add_task(function* test() {
page_without_title = app_name;
about_pb_title = "Open a private window?";
pb_page_with_title = test_title + " - (Private Browsing)";
pb_page_without_title = app_name + " - (Private Browsing)";
pb_about_pb_title = "Private Browsing - (Private Browsing)";
} else {
page_with_title = test_title + " - " + app_name;
page_without_title = app_name;
- about_pb_title = "Open a private window?" + " - " + app_name;
+ about_pb_title = "Open a private window? - " + app_name;
pb_page_with_title = test_title + " - " + app_name + " (Private Browsing)";
pb_page_without_title = app_name + " (Private Browsing)";
pb_about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)";
}
async function testTabTitle(aWindow, url, insidePB, expected_title) {
let tab = (await BrowserTestUtils.openNewForegroundTab(aWindow.gBrowser));
await BrowserTestUtils.loadURI(tab.linkedBrowser, url);
--- a/browser/extensions/pdfjs/test/browser_pdfjs_zoom.js
+++ b/browser/extensions/pdfjs/test/browser_pdfjs_zoom.js
@@ -67,17 +67,17 @@ add_task(function* test() {
"pdf handler defaults to always-ask is false");
is(handlerInfo.preferredAction, Ci.nsIHandlerInfo.handleInternally,
"pdf handler defaults to internal");
info("Pref action: " + handlerInfo.preferredAction);
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" },
function* (newTabBrowser) {
- yield waitForPdfJS(newTabBrowser, TESTROOT + "file_pdfjs_test.pdf" + "#zoom=100");
+ yield waitForPdfJS(newTabBrowser, TESTROOT + "file_pdfjs_test.pdf#zoom=100");
yield ContentTask.spawn(newTabBrowser, TESTS, function* (contentTESTS) {
let document = content.document;
function waitForRender() {
return new Promise((resolve) => {
document.addEventListener("pagerendered", function onPageRendered(e) {
if (e.detail.pageNumber !== 1) {
--- a/security/manager/ssl/tests/mochitest/mixedcontent/mixedContentTest.js
+++ b/security/manager/ssl/tests/mochitest/mixedcontent/mixedContentTest.js
@@ -156,17 +156,17 @@ function isSecurityState(expectedState,
if (isInsecure) {
gotState = "insecure";
} else if (isBroken) {
gotState = "broken";
} else if (isEV) {
gotState = "EV";
}
- test(gotState == expectedState, (message || "") + ", " + "expected " + expectedState + " got " + gotState);
+ test(gotState == expectedState, (message || "") + ", expected " + expectedState + " got " + gotState);
switch (expectedState) {
case "insecure":
test(isInsecure && !isBroken && !isEV, "for 'insecure' excpected flags [1,0,0], " + (message || ""));
break;
case "broken":
test(ui && !isInsecure && isBroken && !isEV, "for 'broken' expected flags [0,1,0], " + (message || ""));
break;
--- a/toolkit/.eslintrc.js
+++ b/toolkit/.eslintrc.js
@@ -236,16 +236,20 @@ module.exports = {
// Requires or disallows a whitespace (space or tab) beginning a comment
"spaced-comment": "error",
// No comparisons to NaN
"use-isnan": "error",
// Only check typeof against valid results
"valid-typeof": "error",
+
+ // Don't concatenate string literals together (unless they span multiple
+ // lines)
+ "no-useless-concat": "error",
},
"env": {
"es6": true,
"browser": true,
},
"globals": {
"BroadcastChannel": false,
// Specific to Firefox (Chrome code only).
--- a/toolkit/components/places/tests/bookmarks/test_1016953-renaming-uncompressed.js
+++ b/toolkit/components/places/tests/bookmarks/test_1016953-renaming-uncompressed.js
@@ -49,17 +49,17 @@ add_task(function* test_same_date_diff_h
// If the old file has been created on the same date, but has a different hash
// the existing file should be overwritten with the newer compressed version
let backupFolder = yield PlacesBackups.getBackupFolder();
let tempPath = OS.Path.join(OS.Constants.Path.profileDir,
"bug10169583_bookmarks.json");
let {count} = yield BookmarkJSONUtils.exportToFile(tempPath);
let dateObj = new Date();
let filename = "bookmarks-" + PlacesBackups.toISODateString(dateObj) + "_" +
- count + "_" + "differentHash==" + ".json";
+ count + "_differentHash==.json";
let backupFile = OS.Path.join(backupFolder, filename);
yield OS.File.move(tempPath, backupFile);
yield PlacesBackups.create(); // Force compressed backup
let mostRecentBackupFile = yield PlacesBackups.getMostRecentBackup();
// Decode lz4 compressed file to json and check if json is valid
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
createInstance(Ci.nsIScriptableUnicodeConverter);
--- a/toolkit/components/places/tests/bookmarks/test_1129529.js
+++ b/toolkit/components/places/tests/bookmarks/test_1129529.js
@@ -31,17 +31,17 @@ add_task(function* () {
lastModified: now,
uri: "http://test0.com/"
},
{
guid: "___guid2____",
index: 1,
id: 4,
charset: "UTF-8",
- tags: "tag1," + "a" + "0123456789".repeat(10), // 101 chars
+ tags: "tag1,a" + "0123456789".repeat(10), // 101 chars
type: "text/x-moz-place",
dateAdded: now,
lastModified: now,
uri: "http://test1.com/"
},
{
guid: "___guid3____",
index: 2,
--- a/toolkit/components/places/tests/unit/test_preventive_maintenance.js
+++ b/toolkit/components/places/tests/unit/test_preventive_maintenance.js
@@ -1322,17 +1322,17 @@ add_task(function* test_preventive_maint
// Get current bookmarks max ID for cleanup
let stmt = mDBConn.createStatement("SELECT MAX(id) FROM moz_bookmarks");
stmt.executeStep();
defaultBookmarksMaxId = stmt.getInt32(0);
stmt.finalize();
do_check_true(defaultBookmarksMaxId > 0);
for (let test of tests) {
- dump("\nExecuting test: " + test.name + "\n" + "*** " + test.desc + "\n");
+ dump("\nExecuting test: " + test.name + "\n*** " + test.desc + "\n");
yield test.setup();
let promiseMaintenanceFinished =
promiseTopicObserved(FINISHED_MAINTENANCE_NOTIFICATION_TOPIC);
Services.prefs.clearUserPref("places.database.lastMaintenance");
let callbackInvoked = false;
PlacesDBUtils.maintenanceOnIdle(() => callbackInvoked = true);
yield promiseMaintenanceFinished;
--- a/toolkit/components/tooltiptext/tests/browser_bug581947.js
+++ b/toolkit/components/tooltiptext/tests/browser_bug581947.js
@@ -14,17 +14,17 @@ function check(aBrowser, aElementName, a
"No tooltip should be shown when the element is valid");
e.setCustomValidity("foo");
if (aBarred) {
ok(!tttp.getNodeText(e, {}, {}),
"No tooltip should be shown when the element is barred from constraint validation");
} else {
ok(tttp.getNodeText(e, {}, {}),
- e.tagName + " " + "A tooltip should be shown when the element isn't valid");
+ e.tagName + " A tooltip should be shown when the element isn't valid");
}
e.setAttribute("title", "");
ok(!tttp.getNodeText(e, {}, {}),
"No tooltip should be shown if the title attribute is set");
e.removeAttribute("title");
contentElement.setAttribute("novalidate", "");
--- a/toolkit/content/tests/widgets/test_videocontrols_jsdisabled.html
+++ b/toolkit/content/tests/widgets/test_videocontrols_jsdisabled.html
@@ -51,16 +51,18 @@ function loadevent(event) {
// Other events expected by the test.
video.addEventListener("timeupdate", runTest);
video.addEventListener("pause", runTest);
}
var win;
function startTest() {
var videoURL = new URL("seek_with_sound.ogg", document.documentURI).href;
+
+ // eslint-disable-next-line no-useless-concat
var url = "data:text/html,<video src=" + videoURL + " controls autoplay=true></video><script>window.testExpando = true;</scr" + "ipt>";
win = window.open(url);
win.addEventListener("load", loadevent);
}
SimpleTest.waitForExplicitFinish();
--- a/toolkit/modules/Console.jsm
+++ b/toolkit/modules/Console.jsm
@@ -146,17 +146,17 @@ function stringify(aThing, aAllowNewLine
return debugElement(aThing);
}
type = (type == "Object" ? "" : type + " ");
let json;
try {
json = JSON.stringify(aThing);
} catch (ex) {
// Can't use a real ellipsis here, because cmd.exe isn't unicode-enabled
- json = "{" + Object.keys(aThing).join(":..,") + ":.., " + "}";
+ json = "{" + Object.keys(aThing).join(":..,") + ":.., }";
}
return type + json;
}
if (typeof aThing == "function") {
return aThing.toString().replace(/\s+/g, " ");
}
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
@@ -300,17 +300,17 @@ function check_results(aActualAddons, aE
do_check_addons(aActualAddons, aExpectedAddons, ADDON_PROPERTIES);
// Additional tests
aActualAddons.forEach(function check_each_addon(aActualAddon) {
// Separately check name so better messages are output when test fails
if (aActualAddon.name == "FAIL")
do_throw(aActualAddon.id + " - " + aActualAddon.description);
if (aActualAddon.name != "PASS")
- do_throw(aActualAddon.id + " - " + "invalid add-on name " + aActualAddon.name);
+ do_throw(aActualAddon.id + " - invalid add-on name " + aActualAddon.name);
do_check_eq(aActualAddon.install == null, !!aInstallNull || !aActualAddon.sourceURI);
// Check that sourceURI property consistent within actual addon
if (aActualAddon.install)
do_check_eq(aActualAddon.install.sourceURI.spec, aActualAddon.sourceURI.spec);
});
}
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -3991,17 +3991,18 @@ Downloader.prototype = {
// Prevent the preference from setting a value greater than 10000.
retryTimeout = Math.min(retryTimeout, 10000);
var maxFail = getPref("getIntPref", PREF_APP_UPDATE_SOCKET_MAXERRORS,
DEFAULT_SOCKET_MAX_ERRORS);
// Prevent the preference from setting a value greater than 20.
maxFail = Math.min(maxFail, 20);
LOG("Downloader:onStopRequest - status: " + status + ", " +
"current fail: " + this.updateService._consecutiveSocketErrors + ", " +
- "max fail: " + maxFail + ", " + "retryTimeout: " + retryTimeout);
+ "max fail: " + maxFail + ", " +
+ "retryTimeout: " + retryTimeout);
if (Components.isSuccessCode(status)) {
if (this._verifyDownload()) {
if (shouldUseService()) {
state = STATE_PENDING_SERVICE;
} else if (getElevationRequired()) {
state = STATE_PENDING_ELEVATE;
} else {
state = STATE_PENDING;