Skip to content

Commit 5388395

Browse files
rub1emarco-c
authored andcommitted
Update eslint-config-airbnb to v17 (#417)
1 parent dfeda72 commit 5388395

10 files changed

+616
-519
lines changed

package-lock.json

Lines changed: 537 additions & 433 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"chromedriver": "2.46.0",
4242
"del": "3.0.0",
4343
"eslint": "5.13.0",
44-
"eslint-config-airbnb": "16.1.0",
44+
"eslint-config-airbnb": "17.1.0",
4545
"eslint-plugin-import": "2.16.0",
4646
"geckodriver": "1.14.1",
4747
"istanbul": "0.4.5",

src/cli.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ const generateVapidKeys = returnJson => {
4848
outputText = JSON.stringify(vapidKeys);
4949
} else {
5050
const outputLine = '\n=======================================\n';
51-
outputText = outputLine + '\n' +
52-
'Public Key:\n' + vapidKeys.publicKey + '\n\n' +
53-
'Private Key:\n' + vapidKeys.privateKey + '\n' +
54-
outputLine;
51+
outputText = outputLine + '\n'
52+
+ 'Public Key:\n' + vapidKeys.publicKey + '\n\n'
53+
+ 'Private Key:\n' + vapidKeys.privateKey + '\n'
54+
+ outputLine;
5555
}
5656

5757
console.log(outputText);

src/encryption-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const encrypt = function(userPublicKey, userAuth, payload, contentEncoding) {
2626
}
2727

2828
if (urlBase64.decode(userAuth).length < 16) {
29-
throw new Error('The subscription auth key should be at least 16 ' +
30-
'bytes long');
29+
throw new Error('The subscription auth key should be at least 16 '
30+
+ 'bytes long');
3131
}
3232

3333
if (typeof payload !== 'string' && !Buffer.isBuffer(payload)) {

src/vapid-helper.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ function validateSubject(subject) {
7171
}
7272

7373
if (typeof subject !== 'string' || subject.length === 0) {
74-
throw new Error('The subject value must be a string containing a URL or ' +
75-
'mailto: address. ' + subject);
74+
throw new Error('The subject value must be a string containing a URL or '
75+
+ 'mailto: address. ' + subject);
7676
}
7777

7878
if (subject.indexOf('mailto:') !== 0) {
@@ -89,8 +89,8 @@ function validatePublicKey(publicKey) {
8989
}
9090

9191
if (typeof publicKey !== 'string') {
92-
throw new Error('Vapid public key is must be a URL safe Base 64 ' +
93-
'encoded string.');
92+
throw new Error('Vapid public key is must be a URL safe Base 64 '
93+
+ 'encoded string.');
9494
}
9595

9696
publicKey = urlBase64.decode(publicKey);
@@ -106,8 +106,8 @@ function validatePrivateKey(privateKey) {
106106
}
107107

108108
if (typeof privateKey !== 'string') {
109-
throw new Error('Vapid private key must be a URL safe Base 64 ' +
110-
'encoded string.');
109+
throw new Error('Vapid private key must be a URL safe Base 64 '
110+
+ 'encoded string.');
111111
}
112112

113113
privateKey = urlBase64.decode(privateKey);
@@ -174,8 +174,8 @@ function getVapidHeaders(audience, subject, publicKey, privateKey, contentEncodi
174174
}
175175

176176
if (typeof audience !== 'string' || audience.length === 0) {
177-
throw new Error('The audience value must be a string containing the ' +
178-
'origin of a push service. ' + audience);
177+
throw new Error('The audience value must be a string containing the '
178+
+ 'origin of a push service. ' + audience);
179179
}
180180

181181
const audienceParseResult = url.parse(audience);
@@ -217,7 +217,8 @@ function getVapidHeaders(audience, subject, publicKey, privateKey, contentEncodi
217217
return {
218218
Authorization: 'vapid t=' + jwt + ', k=' + urlBase64.encode(publicKey)
219219
};
220-
} else if (contentEncoding === WebPushConstants.supportedContentEncodings.AES_GCM) {
220+
}
221+
if (contentEncoding === WebPushConstants.supportedContentEncodings.AES_GCM) {
221222
return {
222223
Authorization: 'WebPush ' + jwt,
223224
'Crypto-Key': 'p256ecdsa=' + urlBase64.encode(publicKey)

src/web-push-lib.js

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ WebPushLib.prototype.setGCMAPIKey = function(apiKey) {
3232
return;
3333
}
3434

35-
if (typeof apiKey === 'undefined' || typeof apiKey !== 'string' ||
36-
apiKey.length === 0) {
35+
if (typeof apiKey === 'undefined'
36+
|| typeof apiKey !== 'string'
37+
|| apiKey.length === 0) {
3738
throw new Error('The GCM API Key should be a non-empty string or null.');
3839
}
3940

@@ -50,8 +51,7 @@ WebPushLib.prototype.setGCMAPIKey = function(apiKey) {
5051
* @param {string} publicKey The public VAPID key, a URL safe, base64 encoded string
5152
* @param {string} privateKey The private VAPID key, a URL safe, base64 encoded string.
5253
*/
53-
WebPushLib.prototype.setVapidDetails =
54-
function(subject, publicKey, privateKey) {
54+
WebPushLib.prototype.setVapidDetails = function(subject, publicKey, privateKey) {
5555
if (arguments.length === 1 && arguments[0] === null) {
5656
vapidDetails = null;
5757
return;
@@ -83,25 +83,24 @@ WebPushLib.prototype.setVapidDetails =
8383
* @return {Object} This method returns an Object which
8484
* contains 'endpoint', 'method', 'headers' and 'payload'.
8585
*/
86-
WebPushLib.prototype.generateRequestDetails =
87-
function(subscription, payload, options) {
86+
WebPushLib.prototype.generateRequestDetails = function(subscription, payload, options) {
8887
if (!subscription || !subscription.endpoint) {
89-
throw new Error('You must pass in a subscription with at least ' +
90-
'an endpoint.');
88+
throw new Error('You must pass in a subscription with at least '
89+
+ 'an endpoint.');
9190
}
9291

93-
if (typeof subscription.endpoint !== 'string' ||
94-
subscription.endpoint.length === 0) {
95-
throw new Error('The subscription endpoint must be a string with ' +
96-
'a valid URL.');
92+
if (typeof subscription.endpoint !== 'string'
93+
|| subscription.endpoint.length === 0) {
94+
throw new Error('The subscription endpoint must be a string with '
95+
+ 'a valid URL.');
9796
}
9897

9998
if (payload) {
10099
// Validate the subscription keys
101-
if (!subscription.keys || !subscription.keys.p256dh ||
102-
!subscription.keys.auth) {
103-
throw new Error('To send a message with a payload, the ' +
104-
'subscription must have \'auth\' and \'p256dh\' keys.');
100+
if (!subscription.keys || !subscription.keys.p256dh
101+
|| !subscription.keys.auth) {
102+
throw new Error('To send a message with a payload, the '
103+
+ 'subscription must have \'auth\' and \'p256dh\' keys.');
105104
}
106105
}
107106

@@ -125,9 +124,9 @@ WebPushLib.prototype.generateRequestDetails =
125124
for (let i = 0; i < optionKeys.length; i += 1) {
126125
const optionKey = optionKeys[i];
127126
if (validOptionKeys.indexOf(optionKey) === -1) {
128-
throw new Error('\'' + optionKey + '\' is an invalid option. ' +
129-
'The valid options are [\'' + validOptionKeys.join('\', \'') +
130-
'\'].');
127+
throw new Error('\'' + optionKey + '\' is an invalid option. '
128+
+ 'The valid options are [\'' + validOptionKeys.join('\', \'')
129+
+ '\'].');
131130
}
132131
}
133132

@@ -139,9 +138,9 @@ WebPushLib.prototype.generateRequestDetails =
139138
});
140139

141140
if (duplicates.length > 0) {
142-
throw new Error('Duplicated headers defined [' +
143-
duplicates.join(',') + ']. Please either define the header in the' +
144-
'top level options OR in the \'headers\' key.');
141+
throw new Error('Duplicated headers defined ['
142+
+ duplicates.join(',') + ']. Please either define the header in the'
143+
+ 'top level options OR in the \'headers\' key.');
145144
}
146145
}
147146

@@ -191,13 +190,13 @@ WebPushLib.prototype.generateRequestDetails =
191190
let requestPayload = null;
192191

193192
if (payload) {
194-
if (!subscription.keys ||
195-
typeof subscription !== 'object' ||
196-
!subscription.keys.p256dh ||
197-
!subscription.keys.auth) {
198-
throw new Error(new Error('Unable to send a message with ' +
199-
'payload to this subscription since it doesn\'t have the ' +
200-
'required encryption keys'));
193+
if (!subscription.keys
194+
|| typeof subscription !== 'object'
195+
|| !subscription.keys.p256dh
196+
+ !subscription.keys.auth) {
197+
throw new Error(new Error('Unable to send a message with '
198+
+ 'payload to this subscription since it doesn\'t have the '
199+
+ 'required encryption keys'));
201200
}
202201

203202
const encrypted = encryptionHelper
@@ -223,16 +222,16 @@ WebPushLib.prototype.generateRequestDetails =
223222
// VAPID isn't supported by GCM hence the if, else if.
224223
if (isGCM) {
225224
if (!currentGCMAPIKey) {
226-
console.warn('Attempt to send push notification to GCM endpoint, ' +
227-
'but no GCM key is defined. Please use setGCMApiKey() or add ' +
228-
'\'gcmAPIKey\' as an option.');
225+
console.warn('Attempt to send push notification to GCM endpoint, '
226+
+ 'but no GCM key is defined. Please use setGCMApiKey() or add '
227+
+ '\'gcmAPIKey\' as an option.');
229228
} else {
230229
requestDetails.headers.Authorization = 'key=' + currentGCMAPIKey;
231230
}
232231
} else if (currentVapidDetails) {
233232
const parsedUrl = url.parse(subscription.endpoint);
234-
const audience = parsedUrl.protocol + '//' +
235-
parsedUrl.host;
233+
const audience = parsedUrl.protocol + '//'
234+
+ parsedUrl.host;
236235

237236
const vapidHeaders = vapidHelper.getVapidHeaders(
238237
audience,
@@ -246,8 +245,8 @@ WebPushLib.prototype.generateRequestDetails =
246245

247246
if (contentEncoding === webPushConstants.supportedContentEncodings.AES_GCM) {
248247
if (requestDetails.headers['Crypto-Key']) {
249-
requestDetails.headers['Crypto-Key'] += ';' +
250-
vapidHeaders['Crypto-Key'];
248+
requestDetails.headers['Crypto-Key'] += ';'
249+
+ vapidHeaders['Crypto-Key'];
251250
} else {
252251
requestDetails.headers['Crypto-Key'] = vapidHeaders['Crypto-Key'];
253252
}
@@ -278,8 +277,7 @@ WebPushLib.prototype.generateRequestDetails =
278277
* resolves if the sending of the notification was successful, otherwise it
279278
* rejects.
280279
*/
281-
WebPushLib.prototype.sendNotification =
282-
function(subscription, payload, options) {
280+
WebPushLib.prototype.sendNotification = function(subscription, payload, options) {
283281
let requestDetails;
284282
try {
285283
requestDetails = this.generateRequestDetails(subscription, payload, options);

test/test-generate-request-details.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,12 @@ suite('Test Generate Request Details', function() {
206206
invalidRequests.forEach(function(invalidRequest) {
207207
test(invalidRequest.testTitle, function() {
208208
if (invalidRequest.addEndpoint) {
209-
invalidRequest.requestOptions.subscription.endpoint =
210-
'https://127.0.0.1:8080';
209+
invalidRequest.requestOptions.subscription.endpoint = 'https://127.0.0.1:8080';
211210
}
212211

213212
if (invalidRequest.serverFlags) {
214-
invalidRequest.requestOptions.subscription.endpoint += '?' +
215-
invalidRequest.serverFlags.join('&');
213+
invalidRequest.requestOptions.subscription.endpoint += '?'
214+
+ invalidRequest.serverFlags.join('&');
216215
}
217216

218217
assert.throws(function() {

test/test-vapid-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ suite('Test Vapid Helpers', function() {
187187
assert(headers['Crypto-Key']);
188188
}
189189
} catch (err) {
190-
console.warn('Valid input call for getVapidHeaders() threw an ' +
191-
'error. [' + index + ']');
190+
console.warn('Valid input call for getVapidHeaders() threw an '
191+
+ 'error. [' + index + ']');
192192
throw err;
193193
}
194194
});

test/testSelenium.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ let testServerURL;
4141
function runTest(browser, options) {
4242
options = options || {};
4343

44-
if (browser.getId() === 'firefox' &&
45-
process.env.TRAVIS === 'true') {
44+
if (browser.getId() === 'firefox'
45+
&& process.env.TRAVIS === 'true') {
4646
try {
4747
which.sync('geckodriver');
4848
} catch (err) {
@@ -223,8 +223,8 @@ availableBrowsers.forEach(function(browser) {
223223

224224
return del(testDirectory)
225225
.catch(function() {
226-
console.warn('Unable to delete test directory, going to wait 2 ' +
227-
'seconds and try again');
226+
console.warn('Unable to delete test directory, going to wait 2 '
227+
+ 'seconds and try again');
228228
// Add a timeout so that if the browser
229229
// changes any files in the test directory
230230
// it doesn't cause del to throw an error

test/testSendNotification.js

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ suite('sendNotification', function() {
126126

127127
assert.equal(requestDetails.headers['content-length'], requestBody.length, 'Check Content-Length header');
128128

129-
if (typeof options.extraOptions !== 'undefined' &&
130-
typeof options.extraOptions.TTL !== 'undefined') {
129+
if (typeof options.extraOptions !== 'undefined'
130+
&& typeof options.extraOptions.TTL !== 'undefined') {
131131
assert.equal(requestDetails.headers.ttl, options.extraOptions.TTL, 'Check TTL header');
132132
} else if (!isGCM) {
133133
assert.equal(requestDetails.headers.ttl, 2419200, 'Check default TTL header');
@@ -183,8 +183,8 @@ suite('sendNotification', function() {
183183
}
184184

185185
if (isGCM) {
186-
if (typeof options.extraOptions !== 'undefined' &&
187-
typeof options.extraOptions.gcmAPIKey !== 'undefined') {
186+
if (typeof options.extraOptions !== 'undefined'
187+
&& typeof options.extraOptions.gcmAPIKey !== 'undefined') {
188188
assert.equal(requestDetails.headers.authorization, 'key=' + options.extraOptions.gcmAPIKey, 'Check GCM Authorization header');
189189
} else {
190190
assert.equal(requestDetails.headers.authorization, 'key=my_gcm_key', 'Check GCM Authorization header');
@@ -331,13 +331,12 @@ suite('sendNotification', function() {
331331
test(validRequest.testTitle + ' (aesgcm)', function() {
332332
// Set the default endpoint if it's not already configured
333333
if (!validRequest.requestOptions.subscription.endpoint) {
334-
validRequest.requestOptions.subscription.endpoint =
335-
'https://127.0.0.1:' + serverPort;
334+
validRequest.requestOptions.subscription.endpoint = 'https://127.0.0.1:' + serverPort;
336335
}
337336

338337
if (validRequest.serverFlags) {
339-
validRequest.requestOptions.subscription.endpoint += '?' +
340-
validRequest.serverFlags.join('&');
338+
validRequest.requestOptions.subscription.endpoint += '?'
339+
+ validRequest.serverFlags.join('&');
341340
}
342341

343342
validRequest.requestOptions.extraOptions = validRequest.requestOptions.extraOptions || {};
@@ -360,13 +359,12 @@ suite('sendNotification', function() {
360359
test(validRequest.testTitle + ' (aes128gcm)', function() {
361360
// Set the default endpoint if it's not already configured
362361
if (!validRequest.requestOptions.subscription.endpoint) {
363-
validRequest.requestOptions.subscription.endpoint =
364-
'https://127.0.0.1:' + serverPort;
362+
validRequest.requestOptions.subscription.endpoint = 'https://127.0.0.1:' + serverPort;
365363
}
366364

367365
if (validRequest.serverFlags) {
368-
validRequest.requestOptions.subscription.endpoint += '?' +
369-
validRequest.serverFlags.join('&');
366+
validRequest.requestOptions.subscription.endpoint += '?'
367+
+ validRequest.serverFlags.join('&');
370368
}
371369

372370
validRequest.requestOptions.extraOptions = validRequest.requestOptions.extraOptions || {};
@@ -458,8 +456,7 @@ suite('sendNotification', function() {
458456

459457
// Set the default endpoint if it's not already configured
460458
if (!validGCMRequest.requestOptions.subscription.endpoint) {
461-
validGCMRequest.requestOptions.subscription.endpoint =
462-
'https://android.googleapis.com/gcm/send/someSubscriptionID';
459+
validGCMRequest.requestOptions.subscription.endpoint = 'https://android.googleapis.com/gcm/send/someSubscriptionID';
463460
}
464461

465462
const webPush = require('../src/index');
@@ -659,13 +656,12 @@ suite('sendNotification', function() {
659656
invalidRequests.forEach(function(invalidRequest) {
660657
test(invalidRequest.testTitle + ' (aesgcm)', function() {
661658
if (invalidRequest.addEndpoint) {
662-
invalidRequest.requestOptions.subscription.endpoint =
663-
'https://127.0.0.1:' + serverPort;
659+
invalidRequest.requestOptions.subscription.endpoint = 'https://127.0.0.1:' + serverPort;
664660
}
665661

666662
if (invalidRequest.serverFlags) {
667-
invalidRequest.requestOptions.subscription.endpoint += '?' +
668-
invalidRequest.serverFlags.join('&');
663+
invalidRequest.requestOptions.subscription.endpoint += '?'
664+
+ invalidRequest.serverFlags.join('&');
669665
}
670666

671667
invalidRequest.requestOptions.extraOptions = invalidRequest.requestOptions.extraOptions || {};
@@ -686,13 +682,12 @@ suite('sendNotification', function() {
686682

687683
test(invalidRequest.testTitle + ' (aes128gcm)', function() {
688684
if (invalidRequest.addEndpoint) {
689-
invalidRequest.requestOptions.subscription.endpoint =
690-
'https://127.0.0.1:' + serverPort;
685+
invalidRequest.requestOptions.subscription.endpoint = 'https://127.0.0.1:' + serverPort;
691686
}
692687

693688
if (invalidRequest.serverFlags) {
694-
invalidRequest.requestOptions.subscription.endpoint += '?' +
695-
invalidRequest.serverFlags.join('&');
689+
invalidRequest.requestOptions.subscription.endpoint += '?'
690+
+ invalidRequest.serverFlags.join('&');
696691
}
697692

698693
invalidRequest.requestOptions.extraOptions = invalidRequest.requestOptions.extraOptions || {};

0 commit comments

Comments
 (0)