I can't seem to get ESLint to run only on changed files using grunt-contrib-watch.
I was able to do it with JSHint.
Any help to get ESLint doing the same would be greatly appreciated.
I can't seem to get ESLint to run only on changed files using grunt-contrib-watch.
I was able to do it with JSHint.
Any help to get ESLint doing the same would be greatly appreciated.
I managed to set this up the other day, so I'll post a possible solution.
Regardless of whether you're trying to use
grunt.config
or<%= ... %>
templating to dynamically modify the config object (to share data between the tasks), your problem might be thatwatch
, by default, spawns child processes for the triggered tasks, making eslint run in a different context.To get around this, just use the
spawn:false
options flag while configuringwatch
.Basically, configure your tasks as such:
Then attach an event handler to the watch event, setting
changedFiles
:You can also modify
eslint.target
directly in the event handler, but having an attribute carry the changed files makes it available to any number of task that might use them.