mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-17 15:53:28 +02:00
Use ESLint CLIEngine directly instead of gulp-eslint because it doesn't support caching yet.
Added new eslint-cli task with cache.
This commit is contained in:
@@ -11,3 +11,4 @@ res/build/
|
||||
rethinkdb_data/
|
||||
temp/
|
||||
tmp/
|
||||
.eslintcache
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@
|
||||
/rethinkdb_data/
|
||||
/temp/
|
||||
/tmp/
|
||||
.eslintcache
|
||||
|
||||
38
gulpfile.js
38
gulpfile.js
@@ -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')
|
||||
@@ -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.
|
||||
@@ -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'])
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user