From 13831072024006e0a5b4ab96dc7ffde801cb5296 Mon Sep 17 00:00:00 2001
From: Mahrud Sayrafi <mahrud@berkeley.edu>
Date: Wed, 7 Feb 2018 04:03:46 -0800
Subject: [PATCH] Fixed and unmuted a few eslint errors, ~10 remain

---
 .eslintrc.js              | 8 ++------
 README.md                 | 2 +-
 src/crypto/signature.js   | 4 ++--
 src/packet/packetlist.js  | 1 +
 src/packet/secret_key.js  | 8 ++++----
 src/worker/async_proxy.js | 4 ++--
 src/worker/worker.js      | 2 +-
 7 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/.eslintrc.js b/.eslintrc.js
index ed553c48..baccf3a6 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -333,6 +333,7 @@ module.exports = {
     "require-await": 0,
     "no-multi-assign": 0,
     "no-underscore-dangle": 0, 
+    "no-restricted-syntax": 0,
     "one-var-declaration-per-line": 0,
 
     // Custom errors:
@@ -347,18 +348,13 @@ module.exports = {
     "no-unused-vars": 0,
     "indent": [ 0, 2, { "SwitchCase": 1 } ],
 
-    // Consider fixing these:
+    // TODO Consider fixing these:
     "new-cap": [ 0, { "properties": false, "capIsNewExceptionPattern": "^type_.*" }],
     "no-lonely-if": 0,
     "no-fallthrough": 0,
-    "consistent-this": 0,
     "no-invalid-this": 0,
-    "callback-return": 0,
-    "no-useless-call": 0, // only occurs for workers
     "import/extensions": 0,
     "no-useless-escape": 0,
-    "no-case-declarations": 0,
-    "no-restricted-syntax": 0,
     "no-array-constructor": 0,
     "no-constant-condition": 0,
     "no-buffer-constructor": 0, // deprecated
diff --git a/README.md b/README.md
index f73c35c2..c59a0ae4 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ OpenPGP.js [![Build Status](https://travis-ci.org/openpgpjs/openpgpjs.svg?branch
 
 ### Performance
 
-* Version 3.0.0 of the library introduces support for public-key cryptography using [elliptic curves](https://wiki.gnupg.org/ECC). We use native implementations on browsers and Node.js when available or [Elliptic](https://github.com/indutny/elliptic) when otherwise. Elliptic curve cryptography provides stronger security per bits of key, which allows for much faster operations. Currently the following curves are supported: ("Yes*" means "when available")
+* Version 3.0.0 of the library introduces support for public-key cryptography using [elliptic curves](https://wiki.gnupg.org/ECC). We use native implementations on browsers and Node.js when available or [Elliptic](https://github.com/indutny/elliptic) otherwise. Elliptic curve cryptography provides stronger security per bits of key, which allows for much faster operations. Currently the following curves are supported: ("Yes*" means "when available")
 
 >| Curve      | Encryption | Signature | Elliptic | NodeCrypto | WebCrypto |
 >|:---------- |:----------:|:---------:|:--------:|:----------:|:---------:|
diff --git a/src/crypto/signature.js b/src/crypto/signature.js
index cf0090ea..92083877 100644
--- a/src/crypto/signature.js
+++ b/src/crypto/signature.js
@@ -62,7 +62,7 @@ export default {
         return dopublic.compareTo(s1) === 0;
       case 19:
         // ECDSA
-        const ecdsa = publicKey.elliptic.ecdsa;
+        var ecdsa = publicKey.elliptic.ecdsa;
         curve = publickey_MPIs[0];
         r = msg_MPIs[0].toBigInteger();
         s = msg_MPIs[1].toBigInteger();
@@ -71,7 +71,7 @@ export default {
         return ecdsa.verify(curve.oid, hash_algo, {r: r, s: s}, m, Q);
       case 22:
         // EdDSA
-        const eddsa = publicKey.elliptic.eddsa;
+        var eddsa = publicKey.elliptic.eddsa;
         curve = publickey_MPIs[0];
         r = msg_MPIs[0].toBigInteger();
         s = msg_MPIs[1].toBigInteger();
diff --git a/src/packet/packetlist.js b/src/packet/packetlist.js
index 752cc1b5..77ba0baf 100644
--- a/src/packet/packetlist.js
+++ b/src/packet/packetlist.js
@@ -1,3 +1,4 @@
+/* eslint-disable callback-return */
 /**
  * This class represents a list of openpgp packets.
  * Take care when iterating over it - the packets themselves
diff --git a/src/packet/secret_key.js b/src/packet/secret_key.js
index 284d5c89..af5eafce 100644
--- a/src/packet/secret_key.js
+++ b/src/packet/secret_key.js
@@ -272,11 +272,11 @@ SecretKey.prototype.decrypt = function (passphrase) {
 };
 
 SecretKey.prototype.generate = function (bits, curve) {
-  var self = this;
+  var that = this;
 
-  return crypto.generateParams(self.algorithm, bits, curve).then(function(params) {
-    self.params = params;
-    self.isDecrypted = true;
+  return crypto.generateParams(that.algorithm, bits, curve).then(function(params) {
+    that.params = params;
+    that.isDecrypted = true;
   });
 };
 
diff --git a/src/worker/async_proxy.js b/src/worker/async_proxy.js
index 6a780206..99d56554 100644
--- a/src/worker/async_proxy.js
+++ b/src/worker/async_proxy.js
@@ -90,7 +90,7 @@ AsyncProxy.prototype.onMessage = function(event) {
  */
 AsyncProxy.prototype.seedRandom = function(size) {
   const buf = this.getRandomBuffer(size);
-  this.worker.postMessage({ event:'seed-random', buf }, util.getTransferables.call(util, buf));
+  this.worker.postMessage({ event:'seed-random', buf }, util.getTransferables(buf));
 };
 
 /**
@@ -125,7 +125,7 @@ AsyncProxy.prototype.delegate = function(method, options) {
 
   return new Promise((resolve, reject) => {
     // clone packets (for web worker structured cloning algorithm)
-    this.worker.postMessage({ id:id, event:method, options:packet.clone.clonePackets(options) }, util.getTransferables.call(util, options));
+    this.worker.postMessage({ id:id, event:method, options:packet.clone.clonePackets(options) }, util.getTransferables(options));
 
     // remember to handle parsing cloned packets from worker
     this.tasks[id] = { resolve: data => resolve(packet.clone.parseClonedPackets(data, method)), reject };
diff --git a/src/worker/worker.js b/src/worker/worker.js
index 2b25f319..a7850b4a 100644
--- a/src/worker/worker.js
+++ b/src/worker/worker.js
@@ -98,5 +98,5 @@ function response(event) {
   if (openpgp.crypto.random.randomBuffer.size < MIN_SIZE_RANDOM_BUFFER) {
     self.postMessage({event: 'request-seed'});
   }
-  self.postMessage(event, openpgp.util.getTransferables.call(openpgp.util, event.data));
+  self.postMessage(event, openpgp.util.getTransferables(event.data));
 }