-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Pass --max-warnings value to formatters #16348
Conversation
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
I would suggest to update the definition of Lines 40 to 44 in 2dc338a
The definition of Lines 193 to 199 in 2dc338a
|
@@ -132,13 +132,18 @@ Each `message` object contains information about the ESLint rule that was trigge | |||
The formatter function receives an object as the second argument. The object has two properties: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The object has two properties:
+ The object has two or three properties:
or maybe just "the following properties"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this! Fixed in c772b6c.
Originally suggested by @fasttime in #16348 (comment).
Originally suggested by @fasttime in #16348 (comment). Internally, I define two types, `MaxWarningsExceeded` and `ResultsMeta`, that the updated `LoadedFormatter` and `FormatterFunction` types can use. I'm then able to reuse the `ResultsMeta` type instead of the generic `Object` type in `ESLint` and `FlatESLint`'s `format` wrapper functions. Externally in the Node.js API docs, I describe the new second argument to `LoadedFormatter`'s `format` method inline rather than separately documenting the new types. While working on this, I noticed that `FlatESLint` is using the pre-PR #15727 `Formatter` type rather than `LoadedFormatter` and `FormatterFunction`. I'll fix that in a follow-up PR to keep this PR scoped to passing `maxWarningsExceeded` info.
I updated the typedefs in 5624b0b; see that commit message for more details, including why I'll be doing a follow-up PR to further improve formatter typedefs as used by |
Thanks @btmills! Nice work 👍🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [eslint](https://eslint.org) ([source](https://github.com/eslint/eslint)) | devDependencies | minor | [`8.24.0` -> `8.25.0`](https://renovatebot.com/diffs/npm/eslint/8.24.0/8.25.0) | --- ### Release Notes <details> <summary>eslint/eslint</summary> ### [`v8.25.0`](https://github.com/eslint/eslint/releases/tag/v8.25.0) [Compare Source](eslint/eslint@v8.24.0...v8.25.0) #### Features - [`173e820`](eslint/eslint@173e820) feat: Pass --max-warnings value to formatters ([#​16348](eslint/eslint#16348)) (Brandon Mills) - [`6964cb1`](eslint/eslint@6964cb1) feat: remove support for ignore files in FlatESLint ([#​16355](eslint/eslint#16355)) (Milos Djermanovic) - [`1cc4b3a`](eslint/eslint@1cc4b3a) feat: `id-length` counts graphemes instead of code units ([#​16321](eslint/eslint#16321)) (Sosuke Suzuki) #### Documentation - [`90c6028`](eslint/eslint@90c6028) docs: Conflicting fixes ([#​16366](eslint/eslint#16366)) (Ben Perlmutter) - [`5a3fe70`](eslint/eslint@5a3fe70) docs: Add VS to integrations page ([#​16381](eslint/eslint#16381)) (Maria José Solano) - [`49bd1e5`](eslint/eslint@49bd1e5) docs: remove unused link definitions ([#​16376](eslint/eslint#16376)) (Nick Schonning) - [`3bd380d`](eslint/eslint@3bd380d) docs: typo cleanups for docs ([#​16374](eslint/eslint#16374)) (Nick Schonning) - [`b3a0837`](eslint/eslint@b3a0837) docs: remove duplicate words ([#​16378](eslint/eslint#16378)) (Nick Schonning) - [`a682562`](eslint/eslint@a682562) docs: add `BigInt` to `new-cap` docs ([#​16362](eslint/eslint#16362)) (Sosuke Suzuki) - [`f6d57fb`](eslint/eslint@f6d57fb) docs: Update docs README ([#​16352](eslint/eslint#16352)) (Ben Perlmutter) - [`7214347`](eslint/eslint@7214347) docs: fix logical-assignment-operators option typo ([#​16346](eslint/eslint#16346)) (Jonathan Wilsson) #### Chores - [`1f78594`](eslint/eslint@1f78594) chore: upgrade [@​eslint/eslintrc](https://github.com/eslint/eslintrc)[@​1](https://github.com/1).3.3 ([#​16397](eslint/eslint#16397)) (Milos Djermanovic) - [`8476a9b`](eslint/eslint@8476a9b) chore: Remove CODEOWNERS ([#​16375](eslint/eslint#16375)) (Nick Schonning) - [`720ff75`](eslint/eslint@720ff75) chore: use "ci" for Dependabot commit message ([#​16377](eslint/eslint#16377)) (Nick Schonning) - [`42f5479`](eslint/eslint@42f5479) chore: bump actions/stale from 5 to 6 ([#​16350](eslint/eslint#16350)) (dependabot\[bot]) - [`e5e9e27`](eslint/eslint@e5e9e27) chore: remove `jsdoc` dev dependency ([#​16344](eslint/eslint#16344)) (Milos Djermanovic) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMjEuMSIsInVwZGF0ZWRJblZlciI6IjMyLjIyNi4wIn0=--> Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1577 Reviewed-by: crapStone <crapstone@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
This fixes #14881 by giving formatters access to the
--max-warnings
threshold when it is exceeded. ThemaxWarningsExceeded
property matches whatstylelint
uses.I had hoped to disable ESLint's own output message if the formatter provides its own message, but that would require even more API, so that's left as a future possibility if we get a request for it.
Is there anything you'd like reviewers to focus on?
execute()
method because that's where we're already doing thetooManyWarnings
exit code calculation. We could instead pass themaxWarnings
threshold through toESLint
/FlatESLint
and have them replicate that calculation to create themaxWarningsExceeded
object, but that seemed worse. I tested this logic as part of the CLI's formatter tests rather than the--max-warnings
tests, though the logic is adjacent.maxWarningsExceeded
arg and piping that through, I put it in aresultsMeta
object in case we want to add something else to it in the future.stylelint
'smaxWarningsExceeded
property only exists if the threshold was exceeded. We could set it tonull
orfalse
instead of omitting it, but I matchedstylelint
's behavior.ESLint
as well asFlatESLint
because I only had to pass through theresultsMeta
object. If we feel like we need more carrots to encourage switching toFlatESLint
and that this would be a good one, I could remove it.