Skip to content

Commit

Permalink
🛠 Gulp lint task (#7458)
Browse files Browse the repository at this point in the history
refs #7427

Adds a `gulp lint` task, as well as subtasks `gulp jshint`, `gulp jscs` and `gulp json` which can be started independently.
  • Loading branch information
aileen authored and kirrg001 committed Oct 3, 2016
1 parent c87e680 commit 43a2220
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
62 changes: 62 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ var gulp = require('gulp'),
livereload = require('gulp-livereload'),
nodemon = require('gulp-nodemon'),
gutil = require('gulp-util'),
jscs = require('gulp-jscs'),
jshint = require('gulp-jshint'),
jsonlint = require('gulp-jsonlint'),
chalk = require('chalk'),
runSequence = require('run-sequence').use(gulp),
argv = require('minimist')(process.argv.slice(2)),
Expand Down Expand Up @@ -451,6 +454,65 @@ gulp.task('setup', function (cb) {
}
});

gulp.task('jscs', function () {
return gulp.src(
[
'*.js',
'!config*.js',
'core/*.js',
'core/server/**/*.js',
'core/test/**/*.js',
'!core/test/coverage/**',
'!core/shared/vendor/**/*.js'
])
.pipe(jscs('.jscsrc'))
.pipe(jscs.reporter())
.pipe(jscs.reporter('failImmediately'));
});

gulp.task('jshint', function () {
return gulp.src(
[
'*.js',
'!config*.js',
'core/*.js',
'core/server/**/*.js',
'core/test/**/*.js',
'!core/test/coverage/**',
'!core/shared/vendor/**/*.js'
])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});

gulp.task('json', function () {
return gulp.src(
[
'*.json',
'core/*.json',
'core/server/**/*.json',
'core/test/**/*.json',
'!core/test/utils/fixtures/import/zips/**/*.json',
'!core/test/coverage/**',
'!core/shared/vendor/**/*.json'
])
.pipe(jsonlint())
.pipe(jsonlint.reporter());
});

gulp.task('lint', function (cb) {
console.info(chalk.cyan('Starting linting and code style checker 🎨 ...'));
runSequence(['jscs', 'jshint', 'json'], function (err) {
if (err) {
swallowError(err, false);
} else {
console.info(chalk.green('No code or style errors ✅'));
cb();
}
});
});

// Default task at the moment is development.
// TODO: As soon as we have a production build task, we should
// check the current environment and use the production build as
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,15 @@
"grunt-update-submodules": "0.4.1",
"gulp": "3.9.1",
"gulp-git-submodule": "1.0.1",
"gulp-jscs": "4.0.0",
"gulp-jshint": "2.0.1",
"gulp-jsonlint": "1.1.2",
"gulp-livereload": "3.8.1",
"gulp-nodemon": "2.1.0",
"gulp-util": "3.0.7",
"istanbul": "0.4.5",
"jshint": "2.9.3",
"jshint-stylish": "2.2.1",
"matchdep": "1.0.1",
"minimist": "1.2.0",
"mocha": "3.1.0",
Expand Down

0 comments on commit 43a2220

Please sign in to comment.