I often perform an eslint .
in an entire directory of files. I would like an option to output a list of only the filenames of files containing lint so that I can use a shell command to open them all in my editor at once (using vim is something like: "vi !!
")
This would be similar to the ack
command: ack ... -l
.
This sounds like a good use case for a custom formatter. Basically, you can create your own formatter to output whatever format you want. Just take one of the existing ones, modify it to do what you want, and use the -f
command line option to use it, such as:
eslint -f ../my/custom/formatter.js
I'd suggest looking at this one as an example: https://github.com/eslint/eslint/blob/master/lib/formatters/compact.js
I suggest to use unix pipe, like
eslint . | grep /home
So it will display only lines with "/home" string that will be filepaths!)
very cool! Here's what I used as my formater:
// only print filenames
module.exports = function(results) {
return results
.filter(result => result.messages.length > 0)
.map(result => result.filePath).join('\n');
};
Most helpful comment
I suggest to use unix pipe, like
So it will display only lines with "/home" string that will be filepaths!)