Skip to content

Commit

Permalink
Update ESLint rules and apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwhitman committed Feb 11, 2022
1 parent ebdc39e commit 6a0076c
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 84 deletions.
109 changes: 79 additions & 30 deletions .eslintrc.cjs
@@ -1,32 +1,81 @@
module.exports = {
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"env": {
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"unix"
],
"no-trailing-spaces": [
"error"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
root : true,
parserOptions : {
ecmaVersion : 'latest',
sourceType : 'module'
},
env : {
node : true,
es6 : true
},
extends : 'eslint:recommended',
rules : {
'array-bracket-spacing' : [
'error',
'always',
{
objectsInArrays : false,
arraysInArrays : false
}
],
'brace-style' : [
'error',
'stroustrup',
{
allowSingleLine : true
}
],
'comma-dangle' : [
'error',
'never'
],
'eol-last' : [
'error',
'always'
],
eqeqeq : [
'error',
'always'
],
indent : [
'error',
'tab',
{
SwitchCase : 1
}
],
'key-spacing' : [
'error',
{
beforeColon : true,
afterColon : true,
align : 'colon'
}
],
'linebreak-style' : [
'error',
'unix'
],
'no-trailing-spaces' : [
'error'
],
'quote-props' : [
'error',
'as-needed'
],
quotes : [
'error',
'single',
{
avoidEscape : true
}
],
semi : [
'error',
'always'
],
'space-infix-ops' : [
'error'
]
}
};
10 changes: 5 additions & 5 deletions lib/internal/chats.js
Expand Up @@ -24,8 +24,8 @@ PushBullet.prototype.chats = async function chats(options) {
*/
PushBullet.prototype.createChat = async function createChat(email) {
const options = {
json: {
email: email
json : {
email : email
}
};

Expand All @@ -39,7 +39,7 @@ PushBullet.prototype.createChat = async function createChat(email) {
* @returns {Promise}
*/
PushBullet.prototype.muteChat = async function muteChat(chatIden) {
return this.updateChat(chatIden, { muted: true });
return this.updateChat(chatIden, { muted : true });
};

/**
Expand All @@ -49,7 +49,7 @@ PushBullet.prototype.muteChat = async function muteChat(chatIden) {
* @returns {Promise}
*/
PushBullet.prototype.unmuteChat = async function unmuteChat(chatIden) {
return this.updateChat(chatIden, { muted: false });
return this.updateChat(chatIden, { muted : false });
};

/**
Expand All @@ -61,7 +61,7 @@ PushBullet.prototype.unmuteChat = async function unmuteChat(chatIden) {
*/
PushBullet.prototype.updateChat = async function updateChat(chatIden, updates) {
const options = {
json: updates
json : updates
};

return this.makeRequest('post', PushBullet.CHATS_END_POINT + '/' + chatIden, options);
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/devices.js
Expand Up @@ -31,7 +31,7 @@ PushBullet.prototype.devices = async function devices(options) {
*/
PushBullet.prototype.createDevice = async function createDevice(deviceOptions) {
const options = {
json: deviceOptions
json : deviceOptions
};

return this.makeRequest('post', PushBullet.DEVICES_END_POINT, options);
Expand All @@ -45,7 +45,7 @@ PushBullet.prototype.createDevice = async function createDevice(deviceOptions) {
*/
PushBullet.prototype.updateDevice = async function updateDevice(deviceIden, deviceOptions) {
const options = {
json: deviceOptions
json : deviceOptions
};

return this.makeRequest('post', PushBullet.DEVICES_END_POINT + '/' + deviceIden, options);
Expand Down
8 changes: 4 additions & 4 deletions lib/internal/encryption.js
Expand Up @@ -50,7 +50,7 @@ export default class Encryption {

const initializationVector = forge.random.getBytes(12);
const cipher = forge.cipher.createCipher('AES-GCM', key);
cipher.start({ iv: initializationVector });
cipher.start({ iv : initializationVector });
cipher.update(forge.util.createBuffer(forge.util.encodeUtf8(message)));
cipher.finish();

Expand Down Expand Up @@ -82,13 +82,13 @@ export default class Encryption {

const decipher = forge.cipher.createDecipher('AES-GCM', key);
decipher.start({
iv: initializationVector,
tag: tag
iv : initializationVector,
tag : tag
});
decipher.update(forge.util.createBuffer(encryptedMessage));
decipher.finish();

const result = decipher.output.toString('utf8');
return result;
}
}
}
10 changes: 5 additions & 5 deletions lib/internal/ephemerals.js
Expand Up @@ -63,15 +63,15 @@ PushBullet.prototype.sendEphemeral = async function sendEphemeral(ephemeralOptio
if (this.encryption) {
const encryptedOptions = this.encryption.encrypt(JSON.stringify(ephemeralOptions));
ephemeralOptions = {
ciphertext: encryptedOptions,
encrypted: true
ciphertext : encryptedOptions,
encrypted : true
};
}

const options = {
json: {
type: 'push',
push: ephemeralOptions
json : {
type : 'push',
push : ephemeralOptions
}
};

Expand Down
48 changes: 24 additions & 24 deletions lib/internal/pushes.js
Expand Up @@ -14,9 +14,9 @@ import PushBullet from '../pushbullet.js';
*/
PushBullet.prototype.note = async function note(deviceParams, title, body) {
const pushParameters = {
type: 'note',
title: title,
body: body
type : 'note',
title : title,
body : body
};

return this.push(deviceParams, pushParameters);
Expand All @@ -33,10 +33,10 @@ PushBullet.prototype.note = async function note(deviceParams, title, body) {
*/
PushBullet.prototype.link = async function link(deviceParams, title, url, body) {
return this.push(deviceParams, {
type: 'link',
title: title,
url: url,
body: body
type : 'link',
title : title,
url : url,
body : body
});
};

Expand All @@ -53,14 +53,14 @@ PushBullet.prototype.file = async function file(deviceParams, filePath, body) {
const fileType = mime.getType(filePath);

const uploadRequestResponse = await fetch(PushBullet.UPLOAD_END_POINT, {
method: 'post',
body: JSON.stringify({
file_name: fileName,
file_type: fileType
method : 'post',
body : JSON.stringify({
file_name : fileName,
file_type : fileType
}),
headers: {
'Content-Type': 'application/json',
'Access-Token': this.apiKey
headers : {
'Content-Type' : 'application/json',
'Access-Token' : this.apiKey
}
});

Expand All @@ -70,20 +70,20 @@ PushBullet.prototype.file = async function file(deviceParams, filePath, body) {
formData.append('file', fs.createReadStream(filePath));

const uploadFileResponse = await fetch(uploadRequestResponseJson.upload_url, {
method: 'post',
body: formData
method : 'post',
body : formData
});

if (uploadFileResponse.status !== 204) {
throw new Error('file upload error');
}

return this.push(deviceParams, {
type: 'file',
file_name: fileName,
file_type: fileType,
file_url: uploadRequestResponseJson.file_url,
body: body
type : 'file',
file_name : fileName,
file_type : fileType,
file_url : uploadRequestResponseJson.file_url,
body : body
});
};

Expand Down Expand Up @@ -121,7 +121,7 @@ PushBullet.prototype.push = async function push(deviceParams, bullet) {
}
}

return this.makeRequest('post', PushBullet.PUSH_END_POINT, { json: bullet });
return this.makeRequest('post', PushBullet.PUSH_END_POINT, { json : bullet });
};

/**
Expand Down Expand Up @@ -160,7 +160,7 @@ PushBullet.prototype.history = async function history(options) {
* @returns {Promise}
*/
PushBullet.prototype.dismissPush = async function dismissPush(pushIden) {
return this.updatePush(pushIden, { dismissed: true });
return this.updatePush(pushIden, { dismissed : true });
};

/**
Expand All @@ -174,7 +174,7 @@ PushBullet.prototype.updatePush = async function updatePush(pushIden, updates) {
updates = updates ? updates : {};

const options = {
json: updates
json : updates
};

return this.makeRequest('post', PushBullet.PUSH_END_POINT + '/' + pushIden, options);
Expand Down
14 changes: 7 additions & 7 deletions lib/internal/subscriptions.js
Expand Up @@ -24,8 +24,8 @@ PushBullet.prototype.subscriptions = async function subscriptions(options) {
*/
PushBullet.prototype.subscribe = async function subscribe(channelTag) {
const options = {
json: {
channel_tag: channelTag
json : {
channel_tag : channelTag
}
};

Expand All @@ -49,7 +49,7 @@ PushBullet.prototype.unsubscribe = async function unsubscribe(subscriptionIden)
* @returns {Promise}
*/
PushBullet.prototype.muteSubscription = async function muteSubscription(subscriptionIden) {
return this.updateSubscription(subscriptionIden, { muted: true });
return this.updateSubscription(subscriptionIden, { muted : true });
};

/**
Expand All @@ -59,7 +59,7 @@ PushBullet.prototype.muteSubscription = async function muteSubscription(subscrip
* @returns {Promise}
*/
PushBullet.prototype.unmuteSubscription = async function unmuteSubscription(subscriptionIden) {
return this.updateSubscription(subscriptionIden, { muted: false });
return this.updateSubscription(subscriptionIden, { muted : false });
};

/**
Expand All @@ -71,7 +71,7 @@ PushBullet.prototype.unmuteSubscription = async function unmuteSubscription(subs
*/
PushBullet.prototype.updateSubscription = async function updateSubscription(subscriptionIden, updates) {
const options = {
json: updates
json : updates
};

return this.makeRequest('post', PushBullet.SUBS_END_POINT + '/' + subscriptionIden, options);
Expand All @@ -85,8 +85,8 @@ PushBullet.prototype.updateSubscription = async function updateSubscription(subs
*/
PushBullet.prototype.channelInfo = async function channelInfo(channelTag) {
const options = {
qs: {
tag: channelTag
qs : {
tag : channelTag
}
};

Expand Down
6 changes: 3 additions & 3 deletions lib/pushbullet.js
Expand Up @@ -81,9 +81,9 @@ PushBullet.prototype.getList = async function getList(endPoint, options) {
*/
PushBullet.prototype.makeRequest = async function makeRequest(verb, endPoint, options) {
const fetchInit = {
method: verb,
headers: {
'Access-Token': this.apiKey
method : verb,
headers : {
'Access-Token' : this.apiKey
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -5,7 +5,7 @@
"main": "./lib/pushbullet.js",
"type": "module",
"scripts": {
"lint": "./node_modules/.bin/eslint .",
"lint": "./node_modules/.bin/eslint . *.cjs",
"test": "./node_modules/.bin/mocha"
},
"repository": {
Expand Down

0 comments on commit 6a0076c

Please sign in to comment.