Skip to content

Instantly share code, notes, and snippets.

@makenai
Created April 30, 2015 18:26
Show Gist options
  • Save makenai/8fa425316db85e8c73e2 to your computer and use it in GitHub Desktop.
Save makenai/8fa425316db85e8c73e2 to your computer and use it in GitHub Desktop.
Incremental JSHint and LintSpaces checking
var JAVASCRIPT_FILES = ['lib/**/*.js', 'routes/**/*.js', 'public/js/**/*.js'];
grunt.initConfig({
jshint: {
options: {
reporter: require('jshint-stylish'),
force: true,
/* https://github.com/gruntjs/grunt-contrib-jshint
http://jshint.com/docs/options/ */
},
all: {
src: JAVASCRIPT_FILES
},
changed: {
src: JAVASCRIPT_FILES,
filter: function(filePath) {
return grunt.config.get('git.changed').indexOf( filePath ) != -1;
}
}
},
lintspaces: {
all: {
src: JAVASCRIPT_FILES
},
changed: {
src: JAVASCRIPT_FILES,
filter: function(filePath) {
return grunt.config.get('git.changed').indexOf( filePath ) != -1;
}
},
options: {
/* https://www.npmjs.com/package/grunt-lintspaces */
indentation: 'spaces',
spaces: 2,
ignores: [ 'js-comments' ]
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-lintspaces');
grunt.loadNpmTasks('grunt-git-changedfiles');
grunt.registerTask('check', ['git_changedfiles', 'jshint:changed', 'lintspaces:changed']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment