diff --git a/.eslintrc.json b/.eslintrc.json index cac4cb9..4e3c88b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -62,7 +62,6 @@ "eqeqeq": "off", "indent": "off", "max-len": "off", - "no-unused-vars": "off", - "object-curly-spacing": "off" + "no-unused-vars": "off" } } diff --git a/README.md b/README.md index 6a1de01..36fa7b0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Using docker ```docker build -t . && docker run -v build:/usr/src/app/build ``` - + Using bash ```zip -r build/pEp4Tb@pEp.security.xpi chrome``` @@ -21,19 +21,19 @@ catch syntax errors. After installing with `npm install` just run: You can run ESLint to check the style guides defined in `.eslintrc.json` with the npm script: npm run lint - -ESLint can auto fix some problems with the option `--fix` but most of them must be fixed manually: + +ESLint can auto fix some problems with the option `--fix` but most of them must be fixed manually: npm run lint --fix - - + npm run lint -- --fix (on Windows) + + ## Tests -To run tests first is needed to install all dependencies - +To run tests first is needed to install all dependencies + npm install ### Run npm run test - \ No newline at end of file diff --git a/chrome/content/TbContacts.js b/chrome/content/TbContacts.js index cbc44e6..0fe8869 100644 --- a/chrome/content/TbContacts.js +++ b/chrome/content/TbContacts.js @@ -1,11 +1,11 @@ -var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm"); +var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm"); var { pEp } = ChromeUtils.import("chrome://pEp4Tb/content/modules/pEp.js"); const TbContacts = { getCardForEmail(emailAddress) { // copied from msgHdrViewOverlay.js const books = MailServices.ab.directories; - const result = {book: null, card: null}; + const result = { book: null, card: null }; while (!result.card && books.hasMoreElements()) { const ab = books.getNext().QueryInterface(Ci.nsIAbDirectory); try { @@ -21,12 +21,12 @@ const TbContacts = { return result; }, - getpEpIdentity({name, email}) { + getpEpIdentity({ name, email }) { let card = this.getCardForEmail(email).card; return new pEp.Identity(email, card && card.UID, name); }, - getpEpOwnIdentity({name, email}) { + getpEpOwnIdentity({ name, email }) { const identity = new pEp.Identity(email, "pEp_own_userId", name); identity.me = true; return identity; diff --git a/chrome/content/TbMessageView.js b/chrome/content/TbMessageView.js index 40116f7..ec526e9 100644 --- a/chrome/content/TbMessageView.js +++ b/chrome/content/TbMessageView.js @@ -1,5 +1,5 @@ var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); -var {jsmime} = ChromeUtils.import("resource:///modules/jsmime.jsm"); +var { jsmime } = ChromeUtils.import("resource:///modules/jsmime.jsm"); var { pEpController } = ChromeUtils.import("chrome://pEp4Tb/content/pEpController.js"); var { TbHelper } = ChromeUtils.import("chrome://pEp4Tb/content/TbHelper.js"); var { TbContacts } = ChromeUtils.import("chrome://pEp4Tb/content/TbContacts.js"); diff --git a/chrome/content/dialogs/privacy_status.js b/chrome/content/dialogs/privacy_status.js index 99c153e..dbfdbbc 100644 --- a/chrome/content/dialogs/privacy_status.js +++ b/chrome/content/dialogs/privacy_status.js @@ -74,7 +74,7 @@ function onLoad() { .map(fetchData) .map(([template, promise]) => { const fragment = new pEpUtils.Fragment(template, document); - promise.then(({data, handlers}) => { + promise.then(({ data, handlers }) => { fragment .populate(data) .attach("click", handlers); diff --git a/chrome/content/modules/pEp.js b/chrome/content/modules/pEp.js index b6ced76..d6da4e7 100644 --- a/chrome/content/modules/pEp.js +++ b/chrome/content/modules/pEp.js @@ -383,7 +383,7 @@ pEp.Message = class { let opt = []; // add extra headers if ("opt_fields" in this) { - opt = this.opt_fields.map(({key, value}) => [key, value]); + opt = this.opt_fields.map(({ key, value }) => [key, value]); } return [ ["Message-ID", this.id || "No-message-ID"], @@ -393,7 +393,7 @@ pEp.Message = class { addressesHeaders() { function getNameAddress(addr) { - return {name: addr.username, email: addr.address}; + return { name: addr.username, email: addr.address }; } const opt = []; diff --git a/chrome/content/modules/pEpAdapter.js b/chrome/content/modules/pEpAdapter.js index 51d5540..8c41550 100644 --- a/chrome/content/modules/pEpAdapter.js +++ b/chrome/content/modules/pEpAdapter.js @@ -216,7 +216,7 @@ class pEpAdapter { console.log("pEpAdapter.js: import_key() success: ", response); if ((typeof (response) === "object") && response.hasOwnProperty("error")) { - throw new Error({code: "PEP-ERROR", message: response.error.message, response}); + throw new Error({ code: "PEP-ERROR", message: response.error.message, response }); } if (response.result.return.hasOwnProperty("status")) { @@ -311,7 +311,7 @@ class pEpAdapter { console.log("pEpAdapter.js: decrypt_message() success: ", response); if ((typeof (response) === "object") && response.hasOwnProperty("error")) { - throw new Error({code: "PEP-ERROR", message: response.error.message, response}); + throw new Error({ code: "PEP-ERROR", message: response.error.message, response }); } let decryptedMessage; @@ -343,7 +343,7 @@ class pEpAdapter { default: this.log.debug("callPepAdapter: 'decrypt_message' returned with error: ", response); - throw new Error({code: "PEP-ERROR", message: response.error.message, response}); + throw new Error({ code: "PEP-ERROR", message: response.error.message, response }); } } @@ -372,7 +372,7 @@ class pEpAdapter { let encryptedMessage = {}; if ((typeof (response) === "object") && response.hasOwnProperty("error")) { - throw new Error({code: "PEP-ERROR", message: response.error.message, response}); + throw new Error({ code: "PEP-ERROR", message: response.error.message, response }); } if (response.result.return.hasOwnProperty("status")) { @@ -393,7 +393,7 @@ class pEpAdapter { default: this.log.debug("callPepAdapter: 'encrypt' returned with error: ", response); - throw new Error({code: response.result.return.status, message: response}); + throw new Error({ code: response.result.return.status, message: response }); } } diff --git a/chrome/content/modules/pEpFiles.js b/chrome/content/modules/pEpFiles.js index eb998bc..a8fd51d 100644 --- a/chrome/content/modules/pEpFiles.js +++ b/chrome/content/modules/pEpFiles.js @@ -1,6 +1,6 @@ const EXPORTED_SYMBOLS = ["pEpFiles"]; -var {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm"); +var { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm"); class pEpFiles { initPath(localFileObj, pathStr) { diff --git a/chrome/content/options.js b/chrome/content/options.js index 1e20100..21b0b8c 100644 --- a/chrome/content/options.js +++ b/chrome/content/options.js @@ -7,13 +7,13 @@ var { pEpController } = ChromeUtils.import("chrome://pEp4Tb/content/pEpControlle // Add preferences info (see developer.thunderbird.net/add-ons/updates/tb68). Preferences.addAll([ - {id: "extensions.pEp.storeAllSecurely", type: "bool"}, - {id: "extensions.pEp.warnUnencrypted", type: "bool"}, - {id: "extensions.pEp.protectSubjects", type: "bool"}, - {id: "extensions.pEp.passiveMode", type: "bool"}, - {id: "extensions.pEp.pEpSync", type: "bool"}, - {id: "extensions.pEp.keyFingerprint", type: "string"}, - {id: "extensions.pEp.keyLocation", type: "string"}, + { id: "extensions.pEp.storeAllSecurely", type: "bool" }, + { id: "extensions.pEp.warnUnencrypted", type: "bool" }, + { id: "extensions.pEp.protectSubjects", type: "bool" }, + { id: "extensions.pEp.passiveMode", type: "bool" }, + { id: "extensions.pEp.pEpSync", type: "bool" }, + { id: "extensions.pEp.keyFingerprint", type: "string" }, + { id: "extensions.pEp.keyLocation", type: "string" }, // examples with different types // { id: "extensions.nameOfAddon.pref2", type: "string" }, // { id: "extensions.nameOfAddon.pref3", type: "int" }, @@ -73,7 +73,7 @@ function loadAccounts() { let id = `mail.identity.${identity.key}.enableEncryption`; // Get prior value, if any. Default to true. let value = Services.prefs.getBoolPref(id, true); - Preferences.add({id, type: "bool"}); + Preferences.add({ id, type: "bool" }); checkbox.setAttribute("preference", id); Services.prefs.setBoolPref(id, value); @@ -97,7 +97,7 @@ function loadAccounts() { let id = `mail.account.${account.key}.storeSecurely`; // Get prior value, if any. Default to true. let value = storeAllSecurely ? true : Services.prefs.getBoolPref(id, true); - Preferences.add({id, type: "bool"}); + Preferences.add({ id, type: "bool" }); checkbox.setAttribute("preference", id); Services.prefs.setBoolPref(id, value); checkbox.setAttribute("disabled", storeAllSecurely); diff --git a/chrome/content/pEpMimeDecrypt.js b/chrome/content/pEpMimeDecrypt.js index ae7b0c1..0c5e60f 100644 --- a/chrome/content/pEpMimeDecrypt.js +++ b/chrome/content/pEpMimeDecrypt.js @@ -113,18 +113,18 @@ MimeDecrypt.prototype = { // so we treat all fields the same. if (message.from && message.from.address) { message.from = TbHelper.isOwnIdentity(message.from.address) - ? TbContacts.getpEpOwnIdentity({name: message.from.username, email: message.from.address}) - : TbContacts.getpEpIdentity({name: message.from.username, email: message.from.address}); + ? TbContacts.getpEpOwnIdentity({ name: message.from.username, email: message.from.address }) + : TbContacts.getpEpIdentity({ name: message.from.username, email: message.from.address }); } message.to = message.to && message.to.map((addr) => (TbHelper.isOwnIdentity(addr.address) - ? TbContacts.getpEpOwnIdentity({name: addr.username, email: addr.address}) - : TbContacts.getpEpIdentity({name: addr.username, email: addr.address}))); + ? TbContacts.getpEpOwnIdentity({ name: addr.username, email: addr.address }) + : TbContacts.getpEpIdentity({ name: addr.username, email: addr.address }))); message.cc = message.cc && message.cc.map((addr) => (TbHelper.isOwnIdentity(addr.address) - ? TbContacts.getpEpOwnIdentity({name: addr.username, email: addr.address}) - : TbContacts.getpEpIdentity({name: addr.username, email: addr.address}))); + ? TbContacts.getpEpOwnIdentity({ name: addr.username, email: addr.address }) + : TbContacts.getpEpIdentity({ name: addr.username, email: addr.address }))); message.bcc = message.bcc && message.bcc.map((addr) => (TbHelper.isOwnIdentity(addr.address) - ? TbContacts.getpEpOwnIdentity({name: addr.username, email: addr.address}) - : TbContacts.getpEpIdentity({name: addr.username, email: addr.address}))); + ? TbContacts.getpEpOwnIdentity({ name: addr.username, email: addr.address }) + : TbContacts.getpEpIdentity({ name: addr.username, email: addr.address }))); // Decrypt, `pEpController.decryptedPromise` is also used in pepmsghdrview.js. this.controller.decryptedHeader = this.uri && this.uri.QueryInterface(Ci.nsIMsgMessageUrl).messageHeader; diff --git a/chrome/content/pepmessengercompose.js b/chrome/content/pepmessengercompose.js index 6a2e8e5..d717d5e 100644 --- a/chrome/content/pepmessengercompose.js +++ b/chrome/content/pepmessengercompose.js @@ -352,7 +352,7 @@ var pEpComposer = { "Send Unsecure", null, null, - {value: 0}, + { value: 0 }, ) === 1); }, diff --git a/chrome/experiments.js b/chrome/experiments.js index 5bd8300..51f3d4b 100644 --- a/chrome/experiments.js +++ b/chrome/experiments.js @@ -1,6 +1,6 @@ /* global ExtensionCommon */ -var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); -var {ExtensionSupport} = ChromeUtils.import("resource:///modules/ExtensionSupport.jsm"); +var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); +var { ExtensionSupport } = ChromeUtils.import("resource:///modules/ExtensionSupport.jsm"); const EXTENSION_NAME = "pEp4Tb@pEp.security";