Closed calvinjuarez closed 6 years ago
I'm using this in tandem with grunt-contrib-watch and trying to get Grunt to only lint the file that changed.
grunt-contrib-watch
Gruntfile.js
module.exports = function(grunt) { grunt.initConfig({ //... eslint: { target: ['path/to/js/'], options: { configFile: '.eslintrc.js', }, }, //... watch: { //... eslint: { files: ['path/to/js/**/*.js'], tasks: ['eslint'], options: { event: ['changed','added'], }, }, }, }) grunt.event.on('watch', function(action, filepath) { grunt.config('eslint.target', filepath) // when 'watch' triggers, set the eslint.target to just the changed file }) //... }
But when I save a file matching the pattern, it lints every file, not just the one that changed. What am I doing wrong?
Note that this example was lifted almost verbatim from the recommendation made by grunt-contrib-watch at https://github.com/gruntjs/grunt-contrib-watch#compiling-files-as-needed.
This question is better asked on Stack Overflow or the grunt-contrib-watch repo. This is just a normal Grunt task. Any issues with watching are with grunt-contrib-watch or your config.
I'm using this in tandem with
grunt-contrib-watch
and trying to get Grunt to only lint the file that changed.Gruntfile.js
But when I save a file matching the pattern, it lints every file, not just the one that changed. What am I doing wrong?
Note that this example was lifted almost verbatim from the recommendation made by grunt-contrib-watch at https://github.com/gruntjs/grunt-contrib-watch#compiling-files-as-needed.