jshint.js 800 B

12345678910111213141516171819202122232425262728
  1. var jshint = require('gulp-jshint');
  2. var notify = require('gulp-notify');
  3. var gulp = require('gulp');
  4. gulp.task('lint', function() {
  5. gulp.src('/src/**/*.js')
  6. .pipe(jshint())
  7. // Use gulp-notify as jshint reporter
  8. .pipe(notify(function (file) {
  9. if (file.jshint.success) {
  10. // Don't show something if success
  11. return false;
  12. }
  13. var errors = file.jshint.results.map(function (data) {
  14. if (data.error) {
  15. return "(" + data.error.line + ':' + data.error.character + ') ' + data.error.reason;
  16. }
  17. }).join("\n");
  18. return file.relative + " (" + file.jshint.results.length + " errors)\n" + errors;
  19. }));
  20. });
  21. gulp.task('watch', ['lint'], function() {
  22. gulp.watch('/src/**/*.js', ['lint']);
  23. });
  24. gulp.task('default', ['lint']);