jshint.js 979 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* global module */
  2. /* global require */
  3. 'use strict';
  4. var tools = require( './res/tools' );
  5. module.exports = function( grunt ) {
  6. // Base task configuration, targeting "all" by default.
  7. var config = {
  8. all: [ '**/*.js' ],
  9. options: defaultConfig
  10. };
  11. // Get information about the task being executed.
  12. var isGitTask = ( grunt.cli.tasks.indexOf( 'jshint:git' ) > -1 ),
  13. isDefaultTask = ( grunt.cli.tasks.indexOf( 'default' ) > -1 ) || !grunt.cli.tasks.length,
  14. // Hacking grunt hard.
  15. isDefaultAndGit = isDefaultTask && ( grunt.task._tasks.default.info.indexOf( '"jshint:git"' ) > -1 );
  16. // Create the :git configuration on the fly, if necessary.
  17. if ( isGitTask || isDefaultAndGit ) {
  18. delete config.all;
  19. config.git = tools.getGitDirtyFiles();
  20. }
  21. // Merge with configurations set in gruntfile.js.
  22. grunt.config.merge( {
  23. jshint: config
  24. } );
  25. grunt.loadNpmTasks( 'grunt-contrib-jshint' );
  26. };
  27. var defaultConfig = {
  28. 'globalstrict': true,
  29. 'validthis': true
  30. };