From 140d4a11e5ce98d0681b160d96b8781978c58a67 Mon Sep 17 00:00:00 2001 From: Vlad Filippov Date: Thu, 16 Jul 2020 11:29:50 -0400 Subject: [PATCH] Refactor remaining 'var' to 'let/const' usages --- lib/Webhooks.js | 2 +- lib/makeRequest.js | 3 ++- lib/utils.js | 2 +- test/resources/BalanceTransactions.spec.js | 4 ++-- test/utils.spec.js | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/Webhooks.js b/lib/Webhooks.js index aad76df2da..ca362e5911 100644 --- a/lib/Webhooks.js +++ b/lib/Webhooks.js @@ -48,7 +48,7 @@ const Webhook = { opts.secret ); - var generatedHeader = [ + const generatedHeader = [ 't=' + opts.timestamp, opts.scheme + '=' + opts.signature, ].join(','); diff --git a/lib/makeRequest.js b/lib/makeRequest.js index 14740f235b..0da41f5b02 100644 --- a/lib/makeRequest.js +++ b/lib/makeRequest.js @@ -64,8 +64,9 @@ function getRequestOpts(self, requestArgs, spec, overrideData) { function makeRequest(self, requestArgs, spec, overrideData) { return new Promise((resolve, reject) => { + let opts; try { - var opts = getRequestOpts(self, requestArgs, spec, overrideData); + opts = getRequestOpts(self, requestArgs, spec, overrideData); } catch (err) { reject(err); return; diff --git a/lib/utils.js b/lib/utils.js index 551a0620be..16c9f95be6 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -67,7 +67,7 @@ const utils = (module.exports = { /** * Outputs a new function with interpolated object property values. * Use like so: - * var fn = makeURLInterpolator('some/url/{param1}/{param2}'); + * const fn = makeURLInterpolator('some/url/{param1}/{param2}'); * fn({ param1: 123, param2: 456 }); // => 'some/url/123/456' */ makeURLInterpolator: (() => { diff --git a/test/resources/BalanceTransactions.spec.js b/test/resources/BalanceTransactions.spec.js index c79c305451..c4081a3e11 100644 --- a/test/resources/BalanceTransactions.spec.js +++ b/test/resources/BalanceTransactions.spec.js @@ -1,7 +1,7 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; describe('BalanceTransactions Resource', function() { describe('retrieve', function() { diff --git a/test/utils.spec.js b/test/utils.spec.js index 5ca1443db3..c20f709c59 100644 --- a/test/utils.spec.js +++ b/test/utils.spec.js @@ -510,8 +510,8 @@ describe('utils', () => { it('handles being unable to require `child_process`', () => { utils._exec = null; - var actualErr = null; - var actualRes = null; + let actualErr = null; + let actualRes = null; function myCb(err, res) { actualErr = err; actualRes = res;