lint.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. var gulp = require('gulp');
  2. var jshint = require('gulp-jshint');
  3. var jscs = require('gulp-jscs');
  4. // different types of jshint configs
  5. var jshintConfig = require('../.jshint.js');
  6. var jshintBase = jshintConfig.base;
  7. var jshintBrowser = jshintConfig.browser;
  8. var jshintBuilt = jshintConfig.built;
  9. // don't let gulp-jshint search for .jshintrc files
  10. jshintBase.lookup = false;
  11. jshintBrowser.lookup = false;
  12. jshintBuilt.lookup = false;
  13. gulp.task('lint', [
  14. 'jshint:base',
  15. 'jshint:browser',
  16. 'jshint:built',
  17. 'jscs:strict',
  18. 'jscs:relaxed'
  19. ]);
  20. // for non-browser JS
  21. gulp.task('jshint:base', function() {
  22. return gulp.src([
  23. '*.js', // like gulpfile and root configs
  24. 'tasks/*.js',
  25. 'tests/automated/*.js'
  26. ])
  27. .pipe(jshint(jshintBase))
  28. .pipe(jshint.reporter('default'))
  29. .pipe(jshint.reporter('fail'));
  30. });
  31. // for browser JS, before concat
  32. gulp.task('jshint:browser', function() {
  33. return gulp.src([
  34. 'src/**/*.js',
  35. '!src/intro.js', // exclude
  36. '!src/outro.js', // "
  37. 'locale/*.js',
  38. ])
  39. .pipe(jshint(jshintBrowser))
  40. .pipe(jshint.reporter('default'))
  41. .pipe(jshint.reporter('fail'));
  42. });
  43. // for browser JS, after concat
  44. gulp.task('jshint:built', [ 'modules', 'locale:all' ], function() {
  45. return gulp.src([
  46. 'dist/*.js',
  47. '!dist/*.min.js', // exclude
  48. '!dist/locale-all.js' // "
  49. ])
  50. .pipe(jshint(jshintBuilt))
  51. .pipe(jshint.reporter('default'))
  52. .pipe(jshint.reporter('fail'));
  53. });
  54. // files we want to lint to a higher standard
  55. gulp.task('jscs:strict', function() {
  56. return gulp.src([
  57. 'tests/automated/*.js'
  58. ])
  59. .pipe(jscs({
  60. configPath: '.jscs.strict.js' // needs to be an external config
  61. }))
  62. .pipe(jscs.reporter())
  63. .pipe(jscs.reporter('fail'));
  64. });
  65. // more relaxed linting. eventually move these to strict
  66. gulp.task('jscs:relaxed', function() {
  67. return gulp.src([
  68. '*.js', // like gulpfile and root configs
  69. 'tasks/*.js',
  70. 'src/**/*.js',
  71. '!src/intro.js', // exclude
  72. '!src/outro.js', // "
  73. 'locale/*.js'
  74. ])
  75. .pipe(jscs({
  76. configPath: '.jscs.js' // needs to be an external config
  77. }))
  78. .pipe(jscs.reporter())
  79. .pipe(jscs.reporter('fail'));
  80. });