Eslint: Add 'filenames only' output to CLI

Created on 11 Feb 2015  路  3Comments  路  Source: eslint/eslint

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.

archived due to age

Most helpful comment

I suggest to use unix pipe, like

eslint . | grep /home

So it will display only lines with "/home" string that will be filepaths!)

All 3 comments

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');
};
Was this page helpful?
0 / 5 - 0 ratings