Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print out only the number of eslint errors in the terminal?

The project I'm working with has a huge code-base, which means that if I do eslint *.js in the terminal, I get thousands of lines in the output. I want to tweak this command only to print out the number of errors, not to actually list all the errors one by one.

What to do to make my results similar to this:

96 problems
like image 992
krcky Avatar asked Nov 15 '25 17:11

krcky


1 Answers

Thinking a bit more, if you really just want a single number, then create your own formatter that would look something like this.

const errorsInFile = (el, currentEl) =>
  el + currentEl.errorCount

module.exports = (results) =>
  `${results.reduce(errorsInFile, 0)} problems`

Or just for fun, we could do it functionally with Ramda

import { map, pipe, prop, reduce, sum } from 'ramda'

const sumArgs = (...args) => sum(args)
const nProblems = n => `${n} problems`

module.exports = pipe(
  map(prop(‘errorCount’),
  reduce(sumArgs),
  nProblems,
)
like image 173
David Bradshaw Avatar answered Nov 17 '25 08:11

David Bradshaw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!