Skip to content

Commit 40c4748

Browse files
committed
Fix eslint issues
1 parent 1ad10ec commit 40c4748

File tree

12 files changed

+1476
-108
lines changed

12 files changed

+1476
-108
lines changed

.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "airbnb",
3+
"rules": {
4+
"indent": ["error", 4],
5+
"max-len": ["error", { "code": 200 }],
6+
"comma-dangle": ["error", "never"]
7+
}
8+
}

config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require('dotenv').config();
2-
const Package = require('./package.json');
32
const process = require('process');
3+
const Package = require('./package.json');
44

55
module.exports = {
66
github: {
@@ -22,8 +22,8 @@ module.exports = {
2222
sync: {
2323
enabled: true,
2424
modes: {
25-
raw: false, // sync raw boostnote files
26-
parsed: true, // sync parsed Markdown files
25+
raw: false, // sync raw boostnote files
26+
parsed: true // sync parsed Markdown files
2727
}
2828
},
2929
watcher: {
@@ -32,4 +32,4 @@ module.exports = {
3232
process.env.LOCAL_BOOSTNOTE_DIR
3333
]
3434
}
35-
}
35+
};

github/helpers.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ exports.trimSlashes = (str) => {
22
if (str && typeof str === 'string') {
33
return str.replace(/^\/|\/$/g, '');
44
}
5-
}
5+
return str;
6+
};
67

7-
exports.pathDepth = (path) => {
8-
return path.replace(/^\/|\/$/, '').split('/').length;
9-
}
8+
exports.pathDepth = path => path.replace(/^\/|\/$/, '').split('/').length;

github/httpStatus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ module.exports = {
6262
URI_TOO_LONG: 414,
6363
USE_PROXY: 305,
6464
VARIANT_ALSO_NEGOTIATES: 506
65-
}
65+
};

github/index.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Github Helper for Boostnote Github Sync.
2+
* Github Helper for Boostnote Github Sync.
33
* This helper currently supports creating/updating files only. Deleting files is not yet supported.
44
*/
55

@@ -9,14 +9,14 @@ const { resolve } = require('url');
99
const { join, basename } = require('path');
1010
const { promisify } = require('util');
1111
const httpStatus = require('./httpStatus');
12-
const {pathDepth, trimSlashes} = require('./helpers');
12+
const { trimSlashes } = require('./helpers');
1313

1414
module.exports = class GithubHelper {
1515
/**
1616
* Create a Github Helper object
17-
* @param {*} container
18-
* @param {*} logger
19-
* @param {*} config
17+
* @param {*} container
18+
* @param {*} logger
19+
* @param {*} config
2020
*/
2121
constructor(container, logger, config) {
2222
this.container = container;
@@ -45,17 +45,17 @@ module.exports = class GithubHelper {
4545
Authorization: `Bearer ${this.apiConfig.accessToken}`,
4646
'User-Agent': '',
4747
'Content-Type': 'application/json',
48-
'Accept': 'application/json'
48+
Accept: 'application/json'
4949
},
5050
body,
5151
json: true
5252
});
53-
53+
5454
return {
5555
status: response.statusCode,
5656
body: response.body
5757
};
58-
}
58+
};
5959
}
6060

6161
/**
@@ -69,7 +69,7 @@ module.exports = class GithubHelper {
6969
* Get github user id
7070
*/
7171
async fetchGithubUser() {
72-
const {status, body} = await this.sendRequest({
72+
const { status, body } = await this.sendRequest({
7373
method: 'get',
7474
path: '/user'
7575
});
@@ -87,9 +87,9 @@ module.exports = class GithubHelper {
8787
* Get a reference to the HEAD of sync repository
8888
*/
8989
async getHead() {
90-
const {status, body} = await this.sendRequest({
90+
const { status, body } = await this.sendRequest({
9191
method: 'get',
92-
path: `/repos/${this.userId}/${this.repo.name}/git/refs/${this.defaultRefs}`, // default notes branch is 'master'
92+
path: `/repos/${this.userId}/${this.repo.name}/git/refs/${this.defaultRefs}` // default notes branch is 'master'
9393
});
9494

9595
if (status !== httpStatus.OK) {
@@ -103,10 +103,10 @@ module.exports = class GithubHelper {
103103

104104
/**
105105
* Grab the tree information from the commit that HEAD points to
106-
* @param {string} hash
106+
* @param {string} hash
107107
*/
108108
async getCommitTreeSHA(hash) {
109-
const {status, body} = await this.sendRequest({
109+
const { status, body } = await this.sendRequest({
110110
method: 'get',
111111
path: `/repos/${this.userId}/${this.repo.name}/git/commits/${hash}`
112112
});
@@ -123,10 +123,10 @@ module.exports = class GithubHelper {
123123

124124
/**
125125
* Post the content-to-by-synced as a git blob
126-
* @param {string} localFile
126+
* @param {string} localFile
127127
*/
128128
async publishBlobFromContent({ content, encoding }) {
129-
const {status, body} = await this.sendRequest({
129+
const { status, body } = await this.sendRequest({
130130
method: 'post',
131131
path: `/repos/${this.userId}/${this.repo.name}/git/blobs`,
132132
body: { content, encoding }
@@ -151,17 +151,17 @@ module.exports = class GithubHelper {
151151
const GITHUB_BLOB_MODE = '100644';
152152
const GITHUB_BLOB_TYPE = 'blob';
153153

154-
const {status, body} = await this.sendRequest({
154+
const { status, body } = await this.sendRequest({
155155
method: 'post',
156156
path: `/repos/${this.userId}/${this.repo.name}/git/trees`,
157157
body: {
158-
'base_tree': baseTreeSHA,
159-
'tree': [
158+
base_tree: baseTreeSHA,
159+
tree: [
160160
{
161-
'path': trimSlashes(remoteFilePath), // remove leading and trailing slashes if any
162-
'mode': GITHUB_BLOB_MODE,
163-
'type': GITHUB_BLOB_TYPE,
164-
'sha': blobSHA
161+
path: trimSlashes(remoteFilePath), // remove leading and trailing slashes if any
162+
mode: GITHUB_BLOB_MODE,
163+
type: GITHUB_BLOB_TYPE,
164+
sha: blobSHA
165165
}
166166
]
167167
}
@@ -176,24 +176,24 @@ module.exports = class GithubHelper {
176176

177177
/**
178178
* Create a new commit after updating tree
179-
* @param {object} options
179+
* @param {object} options
180180
* @param {string} options.parentCommitSHA
181181
* @param {string} options.treeSHA
182182
* @param {string} options.message
183183
*/
184184
async commit({ parentCommitSHA, treeSHA, message }) {
185-
const {status, body} = await this.sendRequest({
185+
const { status, body } = await this.sendRequest({
186186
method: 'post',
187187
path: `/repos/${this.userId}/${this.repo.name}/git/commits`,
188188
body: {
189-
'message': message,
190-
'author': {
191-
'name': this.commitConfig.userName,
192-
'email': this.commitConfig.userEmail,
193-
'date': (new Date()).toISOString()
189+
message,
190+
author: {
191+
name: this.commitConfig.userName,
192+
email: this.commitConfig.userEmail,
193+
date: (new Date()).toISOString()
194194
},
195-
'parents': [parentCommitSHA],
196-
'tree': treeSHA
195+
parents: [parentCommitSHA],
196+
tree: treeSHA
197197
}
198198
});
199199

@@ -206,10 +206,10 @@ module.exports = class GithubHelper {
206206

207207
/**
208208
* Update head with new commit
209-
* @param {string} commitSHA
209+
* @param {string} commitSHA
210210
*/
211211
async updateHead(commitSHA) {
212-
const {status, body} = await this.sendRequest({
212+
const { status, body } = await this.sendRequest({
213213
method: 'patch',
214214
path: `/repos/${this.userId}/${this.repo.name}/git/refs/${this.defaultRefs}`,
215215
body: {
@@ -224,12 +224,12 @@ module.exports = class GithubHelper {
224224
}
225225
return body;
226226
}
227-
227+
228228
/**
229229
* Convenience function to sync file to github
230-
* @param {object} options
230+
* @param {object} options
231231
* @param {string} options.filePath
232-
* @param {string} options.remotePath
232+
* @param {string} options.remotePath
233233
*/
234234
async publishFile({ filePath, remotePath }) {
235235
const encoding = 'base64';
@@ -264,4 +264,4 @@ module.exports = class GithubHelper {
264264
this.logger.debug(`Commit ${commitHash} created!`);
265265
await this.updateHead(commitHash);
266266
}
267-
}
267+
};

0 commit comments

Comments
 (0)