Skip to content

Commit 2d1c29d

Browse files
committed
chore: actually the linter during build; fix accumulated code style violations
1 parent c50436a commit 2d1c29d

22 files changed

+150
-119
lines changed

.eslintrc

Lines changed: 0 additions & 26 deletions
This file was deleted.

.eslintrc.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
extends:
3+
- eslint:recommended
4+
- google
5+
parserOptions:
6+
ecmaVersion: 6
7+
sourceType: module
8+
rules:
9+
arrow-parens: [error, always]
10+
eqeqeq: error
11+
guard-for-in: error
12+
indent: [error, 3, {SwitchCase: 1}]
13+
max-len: [error, {code: 120, ignoreTrailingComments: true}]
14+
no-bitwise: warn
15+
no-extend-native: error
16+
no-useless-constructor: off
17+
no-var: error
18+
padded-blocks: off
19+
quotes: [error, single, {avoidEscape: true}]
20+
require-jsdoc:
21+
- error
22+
- require:
23+
FunctionDeclaration: false
24+
ClassDeclaration: true
25+
MethodDefinition: true
26+
spaced-comment: error
27+
valid-jsdoc: [error, {requireParamDescription: true}]
28+
29+
env:
30+
es6: true
31+
node: true
32+
browser: true
33+
# globals:
34+
# require: false
35+
# define: false
36+
# escape: false

.jscsrc

Lines changed: 0 additions & 16 deletions
This file was deleted.

gulpfile.babel.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
11
import gulp from 'gulp';
2-
import jscs from 'gulp-jscs';
32
import eslint from 'gulp-eslint';
4-
import stylish from 'gulp-jscs-stylish';
5-
63
import babel from 'gulp-babel';
74
import rename from 'gulp-rename';
85

96
import browserify from 'browserify';
107
import buffer from 'vinyl-buffer';
118
import del from 'del';
12-
import path from 'path';
13-
import {Promise} from 'es6-promise';
149
import source from 'vinyl-source-stream';
1510
import sourcemaps from 'gulp-sourcemaps';
1611
import uglify from 'gulp-uglify';
1712

1813
const ALL_SOURCES = [
19-
path.join(__dirname, '/*.js'),
20-
path.join(__dirname, '/src/*.js'),
21-
path.join(__dirname, '/test/*.js')
14+
'*.js',
15+
'lib/*.js',
16+
'test/*.js'
2217
];
2318

2419
gulp.task('lint', function() {
25-
const opts = {
26-
base: './'
27-
};
28-
return gulp.src(ALL_SOURCES, opts)
20+
return gulp.src(ALL_SOURCES)
2921
.pipe(eslint())
30-
.pipe(jscs())
31-
.pipe(stylish.combineWithHintResults())
32-
.pipe(stylish())
22+
.pipe(eslint.format())
23+
.pipe(eslint.failAfterError())
3324
;
3425
});
3526

lib/GitHub.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
55
* Github.js is freely distributable.
66
*/
7+
/* eslint valid-jsdoc: ["error", {"requireReturnDescription": false}] */
78

89
import Gist from './Gist';
910
import User from './User';
@@ -51,6 +52,7 @@ class GitHub {
5152
/**
5253
* Create a new Organization wrapper
5354
* @param {string} organization - the name of the organization
55+
* @param {string} foo - this
5456
* @return {Organization}
5557
*/
5658
getOrganization(organization) {
@@ -99,9 +101,15 @@ class GitHub {
99101
* @return {Markdown}
100102
*/
101103
getMarkdown() {
102-
return new Markdown(this.__auth, this.__apiBase);
104+
return new Markdown(this.__auth, this.__apiBase);
103105
}
104106

107+
/**
108+
* Computes the full repository name
109+
* @param {string} user - the username (or the full name)
110+
* @param {string} repo - the repository name, must not be passed if `user` is the full name
111+
* @return {string} the repository's full name
112+
*/
105113
_getFullName(user, repo) {
106114
let fullname = user;
107115

lib/Issue.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Issue extends Requestable {
5252
* @return {Promise} - the promise for the http request
5353
*/
5454
listIssueComments(issue, cb) {
55-
return this._request('GET', `/repos/${this.__repository}/issues/${issue}/comments`, null, cb); // jscs:ignore
55+
return this._request('GET', `/repos/${this.__repository}/issues/${issue}/comments`, null, cb);
5656
}
5757

5858
/**
@@ -63,7 +63,7 @@ class Issue extends Requestable {
6363
* @return {Promise} - the promise for the http request
6464
*/
6565
getIssueComment(id, cb) {
66-
return this._request('GET', `/repos/${this.__repository}/issues/comments/${id}`, null, cb); // jscs:ignore
66+
return this._request('GET', `/repos/${this.__repository}/issues/comments/${id}`, null, cb);
6767
}
6868

6969
/**
@@ -75,7 +75,7 @@ class Issue extends Requestable {
7575
* @return {Promise} - the promise for the http request
7676
*/
7777
createIssueComment(issue, comment, cb) {
78-
return this._request('POST', `/repos/${this.__repository}/issues/${issue}/comments`, {body: comment}, cb); // jscs:ignore
78+
return this._request('POST', `/repos/${this.__repository}/issues/${issue}/comments`, {body: comment}, cb);
7979
}
8080

8181
/**
@@ -87,7 +87,7 @@ class Issue extends Requestable {
8787
* @return {Promise} - the promise for the http request
8888
*/
8989
editIssueComment(id, comment, cb) {
90-
return this._request('PATCH', `/repos/${this.__repository}/issues/comments/${id}`, {body: comment}, cb); // jscs:ignore
90+
return this._request('PATCH', `/repos/${this.__repository}/issues/comments/${id}`, {body: comment}, cb);
9191
}
9292

9393
/**
@@ -98,7 +98,7 @@ class Issue extends Requestable {
9898
* @return {Promise} - the promise for the http request
9999
*/
100100
deleteIssueComment(id, cb) {
101-
return this._request('DELETE', `/repos/${this.__repository}/issues/comments/${id}`, null, cb); // jscs:ignore
101+
return this._request('DELETE', `/repos/${this.__repository}/issues/comments/${id}`, null, cb);
102102
}
103103

104104
/**

lib/Markdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Markdown extends Requestable {
2424
/**
2525
* Render html from Markdown text.
2626
* @see https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document
27-
* @param {Object} options
27+
* @param {Object} options - conversion options
2828
* @param {string} [options.text] - the markdown text to convert
2929
* @param {string} [options.mode=markdown] - can be either `markdown` or `gfm`
3030
* @param {string} [options.context] - repository name if mode is gfm

lib/Organization.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Organization extends Requestable {
1919
*/
2020
constructor(organization, auth, apiBase) {
2121
super(auth, apiBase);
22-
this.__name = organization;
22+
this.__name = organization;
2323
}
2424

2525
/**
@@ -58,7 +58,7 @@ class Organization extends Requestable {
5858
/**
5959
* List the users who are members of the company
6060
* @see https://developer.github.com/v3/orgs/members/#members-list
61-
* @param {object} options
61+
* @param {object} options - filtering options
6262
* @param {string} [options.filter=all] - can be either `2fa_disabled` or `all`
6363
* @param {string} [options.role=all] - can be one of: `all`, `admin`, or `member`
6464
* @param {Requestable.callback} [cb] - will receive the list of users

lib/Repository.js

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
import Requestable from './Requestable';
1010
import Utf8 from 'utf8';
11-
import {Base64} from 'js-base64';
11+
import {
12+
Base64
13+
} from 'js-base64';
1214
import debug from 'debug';
1315
const log = debug('github:repository');
1416

@@ -154,7 +156,7 @@ class Repository extends Requestable {
154156
/**
155157
* List the commits on a repository, optionally filtering by path, author or time range
156158
* @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
157-
* @param {Object} [options]
159+
* @param {Object} [options] - the filtering options for commits
158160
* @param {string} [options.sha] - the SHA or branch to start from
159161
* @param {string} [options.path] - the path to search on
160162
* @param {string} [options.author] - the commit author
@@ -221,26 +223,34 @@ class Repository extends Requestable {
221223
return this._request('POST', `/repos/${this.__fullname}/git/blobs`, postBody, cb);
222224
}
223225

226+
/**
227+
* Get the object that represents the provided content
228+
* @param {string|Buffer|Blob} content - the content to send to the server
229+
* @return {Object} the representation of `content` for the GitHub API
230+
*/
224231
_getContentObject(content) {
225232
if (typeof content === 'string') {
226233
log('contet is a string');
227234
return {
228235
content: Utf8.encode(content),
229236
encoding: 'utf-8'
230237
};
238+
231239
} else if (typeof Buffer !== 'undefined' && content instanceof Buffer) {
232240
log('We appear to be in Node');
233241
return {
234242
content: content.toString('base64'),
235243
encoding: 'base64'
236244
};
245+
237246
} else if (typeof Blob !== 'undefined' && content instanceof Blob) {
238247
log('We appear to be in the browser');
239248
return {
240249
content: Base64.encode(content),
241250
encoding: 'base64'
242251
};
243-
} else {
252+
253+
} else { // eslint-disable-line
244254
log(`Not sure what this content is: ${typeof content}, ${JSON.stringify(content)}`);
245255
throw new Error('Unknown content passed to postBlob. Must be string or Buffer (node) or Blob (web)');
246256
}
@@ -258,8 +268,8 @@ class Repository extends Requestable {
258268
*/
259269
updateTree(baseTreeSHA, path, blobSHA, cb) {
260270
let newTree = {
261-
'base_tree': baseTreeSHA,
262-
'tree': [{
271+
base_tree: baseTreeSHA, // eslint-disable-line
272+
tree: [{
263273
path: path,
264274
sha: blobSHA,
265275
mode: '100644',
@@ -279,7 +289,10 @@ class Repository extends Requestable {
279289
* @return {Promise} - the promise for the http request
280290
*/
281291
createTree(tree, baseSHA, cb) {
282-
return this._request('POST', `/repos/${this.__fullname}/git/trees`, {tree, base_tree: baseSHA}, cb); // jscs:ignore
292+
return this._request('POST', `/repos/${this.__fullname}/git/trees`, {
293+
tree,
294+
base_tree: baseSHA // eslint-disable-line
295+
}, cb);
283296
}
284297

285298
/**
@@ -315,7 +328,10 @@ class Repository extends Requestable {
315328
* @return {Promise} - the promise for the http request
316329
*/
317330
updateHead(ref, commitSHA, force, cb) {
318-
return this._request('PATCH', `/repos/${this.__fullname}/git/refs/${ref}`, {sha: commitSHA, force: force}, cb);
331+
return this._request('PATCH', `/repos/${this.__fullname}/git/refs/${ref}`, {
332+
sha: commitSHA,
333+
force: force
334+
}, cb);
319335
}
320336

321337
/**
@@ -371,7 +387,9 @@ class Repository extends Requestable {
371387
*/
372388
getContents(ref, path, raw, cb) {
373389
path = path ? `${encodeURI(path)}` : '';
374-
return this._request('GET', `/repos/${this.__fullname}/contents/${path}`, {ref}, cb, raw);
390+
return this._request('GET', `/repos/${this.__fullname}/contents/${path}`, {
391+
ref
392+
}, cb, raw);
375393
}
376394

377395
/**
@@ -411,7 +429,10 @@ class Repository extends Requestable {
411429
return this.getRef(`heads/${oldBranch}`)
412430
.then((response) => {
413431
let sha = response.data.object.sha;
414-
return this.createRef({sha, ref: `refs/heads/${newBranch}`}, cb);
432+
return this.createRef({
433+
sha,
434+
ref: `refs/heads/${newBranch}`
435+
}, cb);
415436
});
416437
}
417438

@@ -502,33 +523,33 @@ class Repository extends Requestable {
502523
}
503524

504525
/**
505-
* Change all references in a repo from old_path to new_path
526+
* Change all references in a repo from oldPath to new_path
506527
* @param {string} branch - the branch to carry out the reference change, or the default branch if not specified
507-
* @param {string} old_path - original path
508-
* @param {string} new_path - new reference path
528+
* @param {string} oldPath - original path
529+
* @param {string} newPath - new reference path
509530
* @param {Function} cb - will receive the commit in which the move occurred
510531
* @return {Promise} - the promise for the http request
511532
*/
512-
move(branch, old_path, new_path, cb) {
533+
move(branch, oldPath, newPath, cb) {
513534
return this.getRef(`heads/${branch}`)
514535
.then((response) => {
515536
return this.getTree(`${response.data.object.sha}?recursive=true`)
516537
.then((response) => {
517-
var _resp = response;
538+
let _resp = response;
518539
response.data.tree.forEach((ref) => {
519-
if (ref.path === old_path) {
520-
ref.path = new_path;
540+
if (ref.path === oldPath) {
541+
ref.path = newPath;
521542
}
522543
if (ref.type === 'tree') {
523544
delete ref.sha;
524545
}
525546
});
526547
return this.createTree(response.data.tree).then(
527548
(response) => {
528-
return this.commit(_resp.data.sha, response.data.sha, `Renamed '${old_path}' to '${new_path}'`)
529-
.then((response) => {
530-
return this.updateHead(`heads/${branch}`, response.data.sha, true, cb);
531-
});
549+
return this.commit(_resp.data.sha, response.data.sha, `Renamed '${oldPath}' to '${newPath}'`)
550+
.then((response) => {
551+
return this.updateHead(`heads/${branch}`, response.data.sha, true, cb);
552+
});
532553
}
533554
);
534555
});
@@ -542,7 +563,7 @@ class Repository extends Requestable {
542563
* @param {string} path - the path for the file
543564
* @param {string} content - the contents of the file
544565
* @param {string} message - the commit message
545-
* @param {Object} [options]
566+
* @param {Object} [options] - commit options
546567
* @param {Object} [options.author] - the author of the commit
547568
* @param {Object} [options.commiter] - the committer
548569
* @param {boolean} [options.encode] - true if the content should be base64 encoded

0 commit comments

Comments
 (0)