question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `--max-warning-count` result object to the `data` argument in formatter function

See original GitHub issue

The 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:closed
  • Created 2 years ago
  • Comments:23 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
btmillscommented, Aug 20, 2022

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 the context 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 if formatterReadMaxWarnings is set.

As an optional extension, we could include errorCount, fatalErrorCount, and warningCount from countErrors() in context as well so that formatters wishing to use maxWarnings 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 read maxWarnings.

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 a supportsMaxWarnings flag that would silence ESLint’s built-in log output.

0reactions
nzakascommented, Aug 30, 2022

👍 to stylelint’s approach

Read more comments on GitHub >

github_iconTop Results From Across the Web

Step 22: Custom Formatters - Documentation - SAPUI5 SDK
We will now add a localized status with a custom formatter, because the status in our data model is in a rather technical...
Read more >
Custom formatters in ASP.NET Core Web API - Microsoft Learn
Use a custom formatter to add support for a content type that isn't handled by the built-in formatters. Overview of how to create...
Read more >
Set a column format with a formatter function - R-Project.org
The fmt() function provides a way to execute custom formatting functionality with raw data values in a way that can consider all output...
Read more >
Format by simply passing data through — fmt_passthrough • gt
A table object that is created using the gt() function. columns. The columns to format. Can either be a series of column names...
Read more >
format function - RDocumentation
Arguments · x. any R object (conceptually); typically numeric. · trim. logical; if FALSE , logical, numeric and complex values are right-justified to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found