Add `--max-warning-count` result object to the `data` argument in formatter function
See original GitHub issueThe version of ESLint you are using. 7.32
The problem you want to solve. Currently, there is no way to format “ESLint found too many warnings (maximum: %s).” message.
Your take on the correct solution to problem.
Similarly to how e.g. stylelint works, if --max-warnings
is passed formatter function should pass a bonus object in the second argument (data
).
Referring to the documentation:
The exported function receives an optional second argument named data. The data object provides extended information related to the analysis results. Currently, the data object consists of a single property named rulesMeta.
If the requested feature is already possible, then the documentation should be updated.
Are you willing to submit a pull request to implement this change? I would be happy to if someone could point me in the right direction.
Issue Analytics
- State:
- Created 2 years ago
- Comments:23 (19 by maintainers)
Top GitHub Comments
I’ll take it 🖐️ This is a core API change, but it’s pretty small, so I’ll write up a proposal here and see if that’s sufficient. I can turn it into a full RFC if necessary.
Goal: Allow formatters to take over output of the “ESLint found too many warnings” message.
Design: Add a
maxWarnings
field to thecontext
object that gets passed to formatters. Internally,maxWarnings
is a getter that, when read, sets a boolean flag,formatterReadMaxWarnings
. ESLint will not output the “too many warnings” message ifformatterReadMaxWarnings
is set.As an optional extension, we could include
errorCount
,fatalErrorCount
, andwarningCount
fromcountErrors()
incontext
as well so that formatters wishing to usemaxWarnings
don’t need to redundantly count results.Documentation: Add the new fields to the
context
object’s documentation and update the detailed formatter example to readmaxWarnings
.Backwards compatibility: Behavior will be identical unless a formatter is updated to read
context.maxWarnings
.Alternatives: Developers might not expect that reading
context.maxWarnings
would alter ESLint’s behavior. We could instead turn it into a method named to indicate the side effect or ask formatters to provide asupportsMaxWarnings
flag that would silence ESLint’s built-in log output.👍 to stylelint’s approach