mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
🛠 Gulp lint task (#7458)
refs #7427 Adds a `gulp lint` task, as well as subtasks `gulp jshint`, `gulp jscs` and `gulp json` which can be started independently.
This commit is contained in:
parent
c87e680764
commit
43a2220298
2 changed files with 67 additions and 0 deletions
62
gulpfile.js
62
gulpfile.js
|
@ -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)),
|
||||
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue