Skip to content
This repository was archived by the owner on Oct 28, 2020. It is now read-only.

Commit eb59524

Browse files
committed
feat(lint): added es6 eslint rules
closes #14
1 parent 2099dd0 commit eb59524

4 files changed

Lines changed: 65 additions & 57 deletions

File tree

.eslintrc.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,19 @@
130130
"wrap-regex": 2,
131131
"semi": 2,
132132
// es6
133-
// "semi": 2,
134-
// "semi": 2,
135-
// "semi": 2,
136-
// "semi": 2,
137-
// "semi": 2,
138-
// "semi": 2,
139-
// "semi": 2,
140-
// "semi": 2,
133+
"arrow-body-style": [2, "always"],
134+
"no-confusing-arrow": 2,
135+
"no-duplicate-imports": [2, {"includeExports": true}],
136+
"no-useless-computed-key": 2,
137+
"no-useless-constructor": 2,
138+
"no-var": 2,
139+
"prefer-arrow-callback": 2,
140+
"prefer-reflect": 2,
141+
"prefer-rest-params": 2,
142+
"prefer-spread": 2,
143+
"prefer-template": 2,
144+
"sort-imports": 2,
145+
// default overrides
141146
"no-console": [2, {"allow": ["log"]}]
142147
}
143148
}

gulpfile.js

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"use strict";
2-
var Promise = require('bluebird');
3-
var fs = Promise.promisifyAll(require('fs'));
4-
var readFile = Promise.promisify(fs.readFile);
5-
var writeFile = Promise.promisify(fs.writeFile);
6-
var pkg = Promise.promisify(require('read-package-json'));
7-
var exec = require('child_process').exec;
8-
var path = require('path');
9-
var gulp = require('gulp');
10-
var nsp = require('gulp-nsp');
11-
var esdoc = require('gulp-esdoc');
12-
var ghPages = require('gulp-gh-pages');
2+
let Promise = require('bluebird');
3+
let fs = Promise.promisifyAll(require('fs'));
4+
let readFile = Promise.promisify(fs.readFile);
5+
let writeFile = Promise.promisify(fs.writeFile);
6+
let pkg = Promise.promisify(require('read-package-json'));
7+
let exec = require('child_process').exec;
8+
let path = require('path');
9+
let gulp = require('gulp');
10+
let nsp = require('gulp-nsp');
11+
let esdoc = require('gulp-esdoc');
12+
let ghPages = require('gulp-gh-pages');
1313
let eslint = require('gulp-eslint');
1414
let excludeGitignore = require('gulp-exclude-gitignore');
15-
var paths = {
15+
let paths = {
1616
"pkg": "./package.json",
1717
"docs": "./build/docs",
1818
"manual": "./build/manual"
@@ -29,10 +29,12 @@ var paths = {
2929
function execp(cmd, opts = {}) {
3030
return new Promise((resolve, reject) => {
3131
const child = exec(cmd, opts,
32-
(err, stdout, stderr) => err ? reject(err) : resolve({
33-
"stdout": stdout,
34-
"stderr": stderr
35-
}));
32+
(err, stdout, stderr) => {
33+
return err ? reject(err) : resolve({
34+
"stdout": stdout,
35+
"stderr": stderr
36+
});
37+
});
3638

3739
if (opts.stdout) {
3840
child.stdout.pipe(opts.stdout);
@@ -43,79 +45,79 @@ function execp(cmd, opts = {}) {
4345
});
4446
}
4547

46-
gulp.task('changelog', function () {
48+
gulp.task('changelog', () => {
4749
return execp('mkdir -p ./build/manual && conventional-changelog -p angular -i ./build/manual/changelog.md -s -r 0');
4850
});
4951

50-
gulp.task('manual', ['changelog'], function () {
52+
gulp.task('manual', ['changelog'], () => {
5153
// parse github readme for available sections
52-
return readFile('./README.md', 'utf8').then(function (response) {
54+
return readFile('./README.md', 'utf8').then((response) => {
5355
// split file based on headers (##) and generate mapping
54-
var blocks = response.split(/\n##\s[^\n]+\n\n/i).map(function (element) {
56+
let blocks = response.split(/\n##\s[^\n]+\n\n/i).map((element) => {
5557
return element;
5658
});
5759

58-
return readFile(paths.manual + '/changelog.md', 'utf8').then(function (response) {
59-
var versions = response.split(/<a name="(?:(?:0|[1-9]\d*)\.){2}(?:0|[1-9]\d*)"><\/a>/i);
60+
return readFile(`${paths.manual}/changelog.md`, 'utf8').then((response) => {
61+
let versions = response.split(/<a name="(?:(?:0|[1-9]\d*)\.){2}(?:0|[1-9]\d*)"><\/a>/i);
6062
versions.splice(0, 1);
6163

6264
return versions.join('');
63-
}).then(function (response) {
64-
var bindings = {
65-
"index": blocks[0] + "\n\n" + blocks[1] + "\n\n## LICENSE\n" + blocks[6],
65+
}).then((response) => {
66+
let bindings = {
67+
"index": `${blocks[0]}\n\n${blocks[1]}\n\n## LICENSE\n${blocks[6]}`,
6668
"installation": blocks[2],
6769
"usage": blocks[3],
6870
"configuration": blocks[4],
6971
"examples": blocks[5],
7072
"changelog": response
7173
};
7274

73-
var log = [];
75+
let log = [];
7476

7577
// create async file write array
7678
for (let key in bindings) {
77-
if (Object.prototype.hasOwnProperty.call(bindings, key)) {
78-
let path = paths.manual + '/' + key + '.md';
79+
if (Reflect.getOwnPropertyDescriptor(bindings, key)) {
80+
let path = `${paths.manual}/${key}.md`;
7981
let data = bindings[key];
8082
log.push(fs.writeFileSync(path, data));
8183
}
8284
}
8385

84-
return Promise.all(log).then(function (response) {
86+
return Promise.all(log).then((response) => {
8587
return response;
8688
});
8789
});
8890
});
8991
});
9092

91-
gulp.task('doc', ['manual'], function () {
92-
var config = {
93+
gulp.task('doc', ['manual'], () => {
94+
let config = {
9395
"destination": paths.docs,
9496
"title": "GitHub Issues Label Sync Module",
95-
"index": paths.manual + "/index.md",
97+
"index": `${paths.manual}/index.md`,
9698
"manual": {
97-
"installation": [paths.manual + "/installation.md"],
98-
"configuration": [paths.manual + "/configuration.md"],
99-
"usage": [paths.manual + "/usage.md"],
100-
"example": [paths.manual + "/examples.md"],
101-
"changelog": [paths.manual + "/changelog.md"]
99+
"installation": [`${paths.manual}/installation.md`],
100+
"configuration": [`${paths.manual}/configuration.md`],
101+
"usage": [`${paths.manual}/usage.md`],
102+
"example": [`${paths.manual}/examples.md`],
103+
"changelog": [`${paths.manual}/changelog.md`]
102104
}
103105
};
104106

105107
return gulp.src('./lib')
106108
.pipe(esdoc(config));
107109
});
108110

109-
gulp.task('predeploy', ['doc'], function () {
110-
return pkg(paths.pkg, console.log, true).then(function (data) {
111-
var pkgName = data.name;
112-
var pkgUser = data.repository.url.match(/github\.com\/([^\/]+)\//i)[1];
111+
gulp.task('predeploy', ['doc'], () => {
112+
return pkg(paths.pkg, console.log, true).then((data) => {
113+
let pkgName = data.name;
114+
let pkgUser = data.repository.url.match(/github\.com\/([^\/]+)\//i)[1];
113115

114116
return writeFile(`${paths.docs}/CNAME`, `${pkgName}-package.${pkgUser}.xyz`);
115117
});
116118
});
117119

118-
gulp.task('deploy', ['predeploy'], function () {
120+
gulp.task('deploy', ['predeploy'], () => {
119121
if (!process.env.COVERAGE_REPORT) {
120122
return false;
121123
}
@@ -124,27 +126,28 @@ gulp.task('deploy', ['predeploy'], function () {
124126
.pipe(ghPages());
125127
});
126128

127-
gulp.task('lint', function () {
129+
gulp.task('lint', () => {
128130
return gulp.src(['**/*.js', '!node_modules/**'])
129131
.pipe(excludeGitignore())
130132
.pipe(eslint())
131133
.pipe(eslint.format())
132134
.pipe(eslint.failAfterError());
133135
});
134136

135-
gulp.task('nsp', function (cb) {
137+
gulp.task('nsp', (cb) => {
136138
nsp({"package": path.resolve('package.json')}, cb);
137139
});
138140

139-
gulp.task('bithound', function () {
141+
gulp.task('bithound', () => {
140142
if (!process.env.CI) {
141-
return;
143+
return false;
142144
}
143145

144-
exec('bithound check git@github.com:superleap/github-issues-label-sync.git', function (error, stdout, stderr) {
146+
return exec('bithound check git@github.com:superleap/github-issues-label-sync.git', (error, stdout, stderr) =>{
145147
console.log(stdout);
146148
console.log(stderr);
147149
});
148150
});
149151

150152
gulp.task('prepublish', ['nsp', 'bithound']);
153+
gulp.task('default', ['prepublish', 'lint']);

lib/LabelSync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export default class GithubIssuesLabelSync {
220220
"repo": this.repo
221221
}).then((response) => {
222222
if (true !== meta) {
223-
delete response.meta;
223+
Reflect.deleteProperty(response, 'meta');
224224
}
225225

226226
this.labels = response;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"node": ">=4"
77
},
88
"scripts": {
9-
"test": "",
9+
"test": "gulp",
1010
"deploy": "gulp deploy",
1111
"prepublish": "gulp prepublish",
1212
"semantic-release": "semantic-release pre && npm publish && semantic-release post"

0 commit comments

Comments
 (0)