Skip to content

Commit

Permalink
Use ESLint CLIEngine directly instead of gulp-eslint because it doesn…
Browse files Browse the repository at this point in the history
…'t support caching yet.

Added new eslint-cli task with cache.
  • Loading branch information
gunta committed Jan 20, 2016
1 parent 6d46132 commit 42e9648
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ res/build/
rethinkdb_data/
temp/
tmp/
.eslintcache
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
/rethinkdb_data/
/temp/
/tmp/
.eslintcache
38 changes: 35 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var gulp = require('gulp')
var gutil = require('gulp-util')
var jsonlint = require('gulp-jsonlint')
var eslint = require('gulp-eslint')
var EslintCLIEngine = require('eslint').CLIEngine
var webpack = require('webpack')
var webpackConfig = require('./webpack.config').webpack
var webpackStatusConfig = require('./res/common/status/webpack.config')
Expand All @@ -28,13 +29,14 @@ gulp.task('jsonlint', function() {
.pipe(jsonlint.reporter())
})

// Try to use eslint-cli directly instead of eslint-gulp
// since it doesn't support cache yet
gulp.task('eslint', function() {
return gulp.src([
'lib/**/*.js'
, 'res/**/*.js'
, '!res/bower_components/**'
, '*.js'
, '!node_modules/**'
])
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
Expand All @@ -47,7 +49,33 @@ gulp.task('eslint', function() {
.pipe(eslint.failAfterError())
})

gulp.task('lint', ['jsonlint', 'eslint'])
gulp.task('eslint-cli', function(done) {
var cli = new EslintCLIEngine({
cache: true
})

var report = cli.executeOnFiles([
'lib/**/*.js'
, 'res/app/**/*.js'
, 'res/auth/**/*.js'
, 'res/common/**/*.js'
, 'res/test/**/*.js'
, 'res/web_modules/**/*.js'
, '*.js'
])
var formatter = cli.getFormatter()
console.log(formatter(report.results))

if (report.errorCount > 0) {
done(new gutil.PluginError('eslint-cli', new Error('ESLint error')))
}
else {
done()
}
})


gulp.task('lint', ['jsonlint', 'eslint-cli'])
gulp.task('test', ['lint', 'run:checkversion'])
gulp.task('build', ['clean', 'webpack:build'])

Expand Down Expand Up @@ -222,5 +250,9 @@ gulp.task('translate:pull', function() {
})

gulp.task('clean', function(cb) {
del(['./tmp', './res/build'], cb)
del([
'./tmp'
, './res/build'
, '.eslintcache'
], cb)
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"chai": "^3.4.1",
"css-loader": "^0.23.1",
"del": "^2.0.1",
"eslint": "^1.10.3",
"eslint-loader": "^1.2.0",
"event-stream": "^3.3.2",
"exports-loader": "^0.6.2",
Expand Down

0 comments on commit 42e9648

Please sign in to comment.