jshint.js 962 B

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