lint.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. const gulp = require('gulp')
  2. const shell = require('gulp-shell')
  3. const eslint = require('gulp-eslint')
  4. const tslint = require('gulp-tslint')
  5. const tslintLib = require('tslint')
  6. const tslintProgram = tslintLib.Linter.createProgram('./tsconfig.json')
  7. gulp.task('lint', [
  8. 'lint:ts',
  9. 'lint:js:built',
  10. 'lint:js:node',
  11. 'lint:js:tests',
  12. 'lint:dts'
  13. ])
  14. gulp.task('lint:ts', function() {
  15. return gulp.src([
  16. 'src/**/*.ts',
  17. 'plugins/**/*.ts'
  18. ])
  19. .pipe(
  20. tslint({ // will use tslint.json
  21. formatter: 'verbose',
  22. program: tslintProgram // for type-checking rules
  23. })
  24. )
  25. .pipe(tslint.report())
  26. })
  27. gulp.task('lint:js:built', [ 'webpack' ], function() {
  28. return gulp.src([
  29. 'dist/*.js',
  30. '!dist/*.min.js'
  31. ])
  32. .pipe(
  33. eslint({ // only checks that globals are properly accessed
  34. parserOptions: { 'ecmaVersion': 3 }, // for IE9
  35. envs: [ 'browser', 'commonjs', 'amd' ],
  36. rules: { 'no-undef': 2 }
  37. })
  38. )
  39. .pipe(eslint.format())
  40. .pipe(eslint.failAfterError())
  41. })
  42. gulp.task('lint:js:node', function() {
  43. return gulp.src([
  44. '*.js', // config files in root
  45. 'tasks/**/*.js'
  46. ])
  47. .pipe(
  48. eslint({
  49. configFile: 'eslint.json',
  50. envs: [ 'node' ]
  51. })
  52. )
  53. .pipe(eslint.format())
  54. .pipe(eslint.failAfterError())
  55. })
  56. gulp.task('lint:js:tests', function() {
  57. return gulp.src([
  58. 'tests/automated/**/*.js'
  59. ])
  60. .pipe(
  61. eslint({
  62. configFile: 'eslint.json',
  63. envs: [ 'browser', 'jasmine', 'jquery' ],
  64. globals: [
  65. 'moment',
  66. 'karmaConfig',
  67. 'pushOptions',
  68. 'describeOptions',
  69. 'describeTimezones',
  70. 'describeValues',
  71. 'pit',
  72. 'affix',
  73. 'getCurrentOptions',
  74. 'initCalendar',
  75. 'currentCalendar',
  76. 'spyOnMethod',
  77. 'spyOnCalendarCallback',
  78. 'spyCall',
  79. 'oneCall'
  80. ]
  81. })
  82. )
  83. .pipe(eslint.format())
  84. .pipe(eslint.failAfterError())
  85. })
  86. // runs the definitions file through the typescript compiler with strict settings
  87. // tho we don't do a require('typescript'), we need the tsc executable
  88. gulp.task('lint:dts', [ 'ts-types' ], shell.task(
  89. './node_modules/typescript/bin/tsc --strict dist/fullcalendar.d.ts'
  90. ))