Skip to content

Commit b7db462

Browse files
added eslint gulp task
1 parent 4dd0846 commit b7db462

12 files changed

Lines changed: 67 additions & 46 deletions

File tree

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/node_modules/**
2+
**/cert/**
3+
**/static/**
4+
**/test/**
File renamed without changes.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ git clone https://github.com/SystangoTechnologies/Koach.git
4242
* [apidoc](http://apidocjs.com/)
4343
* [Babel](https://github.com/babel/babel)
4444
* [ESLint](http://eslint.org/)
45+
* [Gulp](https://github.com/gulpjs/gulp/)
4546

4647
## Structure
4748
```

bin/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ modules(app)
5858
http2
5959
.createServer(options, app.callback())
6060
.listen(config.port, () => {
61-
console.log(`Server started on ${config.port}`)
61+
console.log(`Server started on ${config.port}`)
6262
})
6363

6464
//app.listen(config.port, () => {

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const RequireDir = require('require-dir')
66
// Load tasks
77
RequireDir('./tasks')
88

9-
Gulp.task('dev', ['dotenv', 'yaml2json', 'nodemon'])
10-
Gulp.task('prod', ['pm2'])
9+
Gulp.task('dev', ['lint', 'dotenv', 'yaml2json', 'nodemon'])
10+
Gulp.task('prod', ['lint', 'pm2'])
1111

1212
Gulp.task('default', ['dev'])

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@
3838
"babel-preset-es2015-node5": "^1.2.0",
3939
"babel-preset-stage-0": "^6.5.0",
4040
"bcrypt": "^1.0.2",
41+
"eslint-plugin-import": "^2.6.1",
42+
"eslint-plugin-node": "^5.1.0",
4143
"glob": "^7.0.0",
4244
"gulp": "^3.9.1",
45+
"gulp-eslint": "^4.0.0",
4346
"gulp-watch": "^4.3.11",
4447
"http2": "^3.3.6",
4548
"jsonwebtoken": "^7.1.9",

src/modules/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exports = module.exports = function initModules (app) {
2222
const lastHandler = handlers.pop()
2323

2424
instance[method.toLowerCase()](route, ...handlers, async function(ctx) {
25-
return await lastHandler(ctx)
25+
await lastHandler(ctx)
2626
})
2727

2828
app

tasks/dotenv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ const Gulp = require('gulp')
44
const dotenv = require('dotenv')
55

66
Gulp.task('dotenv', function () {
7-
dotenv.config()
7+
dotenv.config()
88
})

tasks/lint.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict'
2+
3+
const Gulp = require('gulp')
4+
const Eslint = require('gulp-eslint')
5+
6+
Gulp.task('lint', function () {
7+
return Gulp.src('*/**')
8+
.pipe(Eslint({
9+
fix: true
10+
}))
11+
.pipe(Eslint.format())
12+
.pipe(Eslint.failAfterError())
13+
})

tasks/nodemon.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ const Gulp = require('gulp')
33
const Nodemon = require('gulp-nodemon')
44

55
Gulp.task('nodemon', function () {
6-
const nodeArgs = []
7-
if (process.env.DEBUGGER) {
8-
nodeArgs.push('--inspect')
9-
}
6+
const nodeArgs = []
7+
if (process.env.DEBUGGER) {
8+
nodeArgs.push('--inspect')
9+
}
1010

11-
Nodemon({
12-
script: 'index.js',
13-
ignore: [
14-
'node_modules/',
15-
'test/'
16-
],
17-
nodeArgs: nodeArgs
18-
}).on('restart', function (files) {
19-
console.log('change detected:', files)
20-
})
11+
Nodemon({
12+
script: 'index.js',
13+
ignore: [
14+
'node_modules/',
15+
'test/'
16+
],
17+
nodeArgs: nodeArgs
18+
}).on('restart', function (files) {
19+
console.log('change detected:', files)
20+
})
2121
})

0 commit comments

Comments
 (0)