Bug 1301287 - Password manager: enable eslint brace-style rule on shipping code. r=johannh
MozReview-Commit-ID: BDHUOlv83eR
--- a/toolkit/components/passwordmgr/.eslintrc
+++ b/toolkit/components/passwordmgr/.eslintrc
@@ -1,14 +1,17 @@
{
"extends": "../../.eslintrc",
"rules": {
// Require spacing around =>
"arrow-spacing": 2,
+ // No newline before open brace for a block
+ "brace-style": [2, "1tbs", {"allowSingleLine": true}],
+
// No space before always a space after a comma
"comma-spacing": [2, {"before": false, "after": true}],
// Commas at the end of the line not the start
"comma-style": 2,
// No using undeclared variables
"no-undef": 2,
--- a/toolkit/components/passwordmgr/LoginHelper.jsm
+++ b/toolkit/components/passwordmgr/LoginHelper.jsm
@@ -84,18 +84,17 @@ this.LoginHelper = {
/**
* Due to the way the signons2.txt file is formatted, we need to make
* sure certain field values or characters do not cause the file to
* be parsed incorrectly. Reject logins that we can't store correctly.
*
* @throws String with English message in case validation failed.
*/
checkLoginValues(aLogin) {
- function badCharacterPresent(l, c)
- {
+ function badCharacterPresent(l, c) {
return ((l.formSubmitURL && l.formSubmitURL.indexOf(c) != -1) ||
(l.httpRealm && l.httpRealm.indexOf(c) != -1) ||
l.hostname.indexOf(c) != -1 ||
l.usernameField.indexOf(c) != -1 ||
l.passwordField.indexOf(c) != -1);
}
// Nulls are invalid, as they don't round-trip well.
--- a/toolkit/components/passwordmgr/LoginImport.jsm
+++ b/toolkit/components/passwordmgr/LoginImport.jsm
@@ -40,18 +40,17 @@ XPCOMUtils.defineLazyModuleGetter(this,
* Provides an object that has a method to import login-related data from the
* previous SQLite storage format.
*
* @param aStore
* LoginStore object where imported data will be added.
* @param aPath
* String containing the file path of the SQLite login database.
*/
-this.LoginImport = function (aStore, aPath)
-{
+this.LoginImport = function (aStore, aPath) {
this.store = aStore;
this.path = aPath;
}
this.LoginImport.prototype = {
/**
* LoginStore object where imported data will be added.
*/
--- a/toolkit/components/passwordmgr/LoginStore.jsm
+++ b/toolkit/components/passwordmgr/LoginStore.jsm
@@ -121,18 +121,17 @@ const PERMISSION_SAVE_LOGINS = "login-sa
//// LoginStore
/**
* Handles serialization of login-related data and persistence into a file.
*
* @param aPath
* String containing the file path where data should be saved.
*/
-function LoginStore(aPath)
-{
+function LoginStore(aPath) {
this.path = aPath;
this._saver = new DeferredTask(() => this.save(), kSaveDelayMs);
AsyncShutdown.profileBeforeChange.addBlocker("Login store: writing data",
() => this._saver.finalize());
}
LoginStore.prototype = {
@@ -157,18 +156,17 @@ LoginStore.prototype = {
/**
* Loads persistent data from the file to memory.
*
* @return {Promise}
* @resolves When the operation finished successfully.
* @rejects JavaScript exception.
*/
- load: function ()
- {
+ load() {
return Task.spawn(function* () {
try {
let bytes = yield OS.File.read(this.path);
// If synchronous loading happened in the meantime, exit now.
if (this.dataReady) {
return;
}
@@ -209,18 +207,17 @@ LoginStore.prototype = {
this._processLoadedData();
}.bind(this));
},
/**
* Loads persistent data from the file to memory, synchronously.
*/
- ensureDataReady: function ()
- {
+ ensureDataReady() {
if (this.dataReady) {
return;
}
try {
// This reads the file and automatically detects the UTF-8 encoding.
let inputStream = new FileInputStream(new FileUtils.File(this.path),
FileUtils.MODE_RDONLY,
@@ -261,18 +258,17 @@ LoginStore.prototype = {
}
this._processLoadedData();
},
/**
* Synchronously work on the data just loaded into memory.
*/
- _processLoadedData: function ()
- {
+ _processLoadedData() {
// Create any arrays that are not present in the saved file.
if (!this.data.logins) {
this.data.logins = [];
}
// Stub needed for login imports before data has been migrated.
if (!this.data.disabledHosts) {
this.data.disabledHosts = [];
@@ -302,18 +298,17 @@ LoginStore.prototype = {
}
delete this.data.disabledHosts;
},
/**
* Called when the data changed, this triggers asynchronous serialization.
*/
- saveSoon: function ()
- {
+ saveSoon() {
return this._saver.arm();
},
/**
* DeferredTask that handles the save operation.
*/
_saver: null,
@@ -321,18 +316,17 @@ LoginStore.prototype = {
* Saves persistent data from memory to the file.
*
* If an error occurs, the previous file is not deleted.
*
* @return {Promise}
* @resolves When the operation finished successfully.
* @rejects JavaScript exception.
*/
- save: function ()
- {
+ save() {
return Task.spawn(function* () {
// Create or overwrite the file.
let bytes = gTextEncoder.encode(JSON.stringify(this.data));
yield OS.File.writeAtomic(this.path, bytes,
{ tmpPath: this.path + ".tmp" });
}.bind(this));
},
};
--- a/toolkit/components/passwordmgr/content/passwordManager.js
+++ b/toolkit/components/passwordmgr/content/passwordManager.js
@@ -481,18 +481,17 @@ function FinalizeSignonDeletions(syncNee
function HandleSignonKeyPress(e) {
// If editing is currently performed, don't do anything.
if (signonsTree.getAttribute("editing")) {
return;
}
if (e.keyCode == KeyboardEvent.DOM_VK_DELETE ||
(AppConstants.platform == "macosx" &&
- e.keyCode == KeyboardEvent.DOM_VK_BACK_SPACE))
- {
+ e.keyCode == KeyboardEvent.DOM_VK_BACK_SPACE)) {
DeleteSignon();
}
}
function getColumnByName(column) {
switch (column) {
case "hostname":
return document.getElementById("siteCol");
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -656,18 +656,17 @@ LoginManagerPrompter.prototype = {
authInfo: aAuthInfo,
level: aLevel,
inProgress : false,
prompter: this
};
this._factory._asyncPrompts[hashKey] = asyncPrompt;
this._factory._doAsyncPrompt();
- }
- catch (e) {
+ } catch (e) {
Components.utils.reportError("LoginManagerPrompter: " +
"asyncPromptAuth: " + e + "\nFalling back to promptAuth\n");
// Fail the prompt operation to let the consumer fall back
// to synchronous promptAuth method
throw e;
}
return cancelable;
@@ -902,18 +901,17 @@ LoginManagerPrompter.prototype = {
};
// The main action is the "Remember" or "Update" button.
let mainAction = {
label: this._getLocalizedString(initialMsgNames.buttonLabel),
accessKey: this._getLocalizedString(initialMsgNames.buttonAccessKey),
callback: () => {
histogram.add(PROMPT_ADD_OR_UPDATE);
- if (histogramName == "PWMGR_PROMPT_REMEMBER_ACTION")
- {
+ if (histogramName == "PWMGR_PROMPT_REMEMBER_ACTION") {
Services.obs.notifyObservers(null, 'LoginStats:NewSavedPassword', null);
}
readDataFromUI();
persistData();
browser.focus();
}
};
--- a/toolkit/components/passwordmgr/storage-json.js
+++ b/toolkit/components/passwordmgr/storage-json.js
@@ -175,18 +175,17 @@ this.LoginManagerStorage_json.prototype
let [idToModify, oldStoredLogin] = this._getIdForLogin(oldLogin);
if (!idToModify)
throw new Error("No matching logins");
let newLogin = LoginHelper.buildModifiedLogin(oldStoredLogin, newLoginData);
// Check if the new GUID is duplicate.
if (newLogin.guid != oldStoredLogin.guid &&
- !this._isGuidUnique(newLogin.guid))
- {
+ !this._isGuidUnique(newLogin.guid)) {
throw new Error("specified GUID already exists");
}
// Look for an existing entry in case key properties changed.
if (!newLogin.matches(oldLogin, true)) {
let logins = this.findLogins({}, newLogin.hostname,
newLogin.formSubmitURL,
newLogin.httpRealm);
--- a/toolkit/components/passwordmgr/storage-mozStorage.js
+++ b/toolkit/components/passwordmgr/storage-mozStorage.js
@@ -22,18 +22,17 @@ XPCOMUtils.defineLazyModuleGetter(this,
*/
function Transaction(aDatabase) {
this._db = aDatabase;
this._hasTransaction = false;
try {
this._db.beginTransaction();
this._hasTransaction = true;
- }
- catch (e) { /* om nom nom exceptions */ }
+ } catch (e) { /* om nom nom exceptions */ }
}
Transaction.prototype = {
commit : function() {
if (this._hasTransaction)
this._db.commitTransaction();
},
@@ -330,18 +329,17 @@ LoginManagerStorage_mozStorage.prototype
let [idToModify, oldStoredLogin] = this._getIdForLogin(oldLogin);
if (!idToModify)
throw new Error("No matching logins");
let newLogin = LoginHelper.buildModifiedLogin(oldStoredLogin, newLoginData);
// Check if the new GUID is duplicate.
if (newLogin.guid != oldStoredLogin.guid &&
- !this._isGuidUnique(newLogin.guid))
- {
+ !this._isGuidUnique(newLogin.guid)) {
throw new Error("specified GUID already exists");
}
// Look for an existing entry in case key properties changed.
if (!newLogin.matches(oldLogin, true)) {
let logins = this.findLogins({}, newLogin.hostname,
newLogin.formSubmitURL,
newLogin.httpRealm);
--- a/toolkit/components/passwordmgr/test/.eslintrc
+++ b/toolkit/components/passwordmgr/test/.eslintrc
@@ -1,10 +1,11 @@
{
"extends": [
"../../../../testing/mochitest/mochitest.eslintrc",
"../../../../testing/mochitest/chrome.eslintrc"
],
"rules": {
+ "brace-style": 0,
"no-undef": 0,
"no-unused-vars": 0,
},
}