Skip to content
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(linter): add error and warning statistics #18313

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

SimeonC
Copy link
Contributor

@SimeonC SimeonC commented Jul 26, 2023

Outputs the error and warning count statistics including how many can be auto-fixed, something I found useful before - especially when changing eslint configs which can generate a lot of errors.

I have noticed that this is only useful in 2 cases;

  • Sending the output to a file so eslint statistics aren't shown
  • a lot of errors/warnings are being output and the output is truncated in the console

Current Behavior

Linter outputs only whether there are 1 or more errors or warnings.

Lint warnings found in the listed files.

Lint errors found in the listed files.

Expected Behavior

We should get the error/warning count and also the number of fixable error/warnings.

8 Lint warnings found in the listed files.

2306 Lint errors found in the listed files. (740 are fixable)

@SimeonC SimeonC requested a review from a team as a code owner July 26, 2023 07:23
@SimeonC SimeonC requested a review from JamesHenry July 26, 2023 07:23
@vercel
Copy link

vercel bot commented Jul 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview 💬 Add feedback Feb 1, 2024 1:23am

@JamesHenry
Copy link
Collaborator

I'm so sorry for the delay in you receiving a review here @SimeonC! This seems like a good change to me, would it be possible for you to fix up the conflicts please? I'll keep an eye on this one so we can get it merged straight away

@SimeonC
Copy link
Contributor Author

SimeonC commented Jan 30, 2024

@JamesHenry I admit I had kinda forgotten about this. Looks like I'm a bit fortunate this time and the "conflicts" are just that git has too many commits and a rebase worked.

Copy link
Collaborator

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sorry to be a pain, but can we align it a bit more with ESLint's own output and mention the --fix flag, as well as not have the . before the parens

Their logic looks like this:

 output += chalk[summaryColor].bold([
                "  ", fixableErrorCount, pluralize(" error", fixableErrorCount), " and ",
                fixableWarningCount, pluralize(" warning", fixableWarningCount),
                " potentially fixable with the `--fix` option.\n"
            ].join(""));

from https://github.com/eslint/eslint/blob/98b5ab406bac6279eadd84e8a5fd5a01fc586ff1/lib/cli-engine/formatters/stylish.js#L91

It doesn't have to be exactly that (e.g. we don't have the chalk dep in linter I don't think, but potentially fixable with the `--fix` option is preferable language please

@SimeonC SimeonC force-pushed the add-linter-fixable-stats branch 2 times, most recently from 4351cc6 to 3598aa6 Compare January 31, 2024 01:22
@SimeonC
Copy link
Contributor Author

SimeonC commented Jan 31, 2024

@JamesHenry Thanks for the feedback, I went with updating to match the stylish formatted output as much as possible

@SimeonC
Copy link
Contributor Author

SimeonC commented Jan 31, 2024

Oh, I see that the success message is used in a lot of other tests. @JamesHenry would you prefer I revert the success message change or update the tests to use the stylish formatted success message?

@JamesHenry
Copy link
Collaborator

@SimeonC I think you can just do find an replace on toContain('All files pass linting.') with toContain('All files pass linting') (i.e. just remove the period at the end, I think that's the only difference)

@SimeonC
Copy link
Contributor Author

SimeonC commented Jan 31, 2024

@JamesHenry Thanks, did that.

@JamesHenry
Copy link
Collaborator

JamesHenry commented Jan 31, 2024

@SimeonC did you push with --no-verify? You have failed CI with a commit check that would have run automatically prepush

@SimeonC
Copy link
Contributor Author

SimeonC commented Jan 31, 2024 via email

@JamesHenry
Copy link
Collaborator

It's your git commit message, you just need to do a commit --amend and add a valid scope to the commit

image

The check is way too expensive (it does a lot of things) to apply to a precommit hook, that is why it is done prepush

Outputs the error and warning count statistics including how many can be auto-fixed
@SimeonC
Copy link
Contributor Author

SimeonC commented Feb 1, 2024

Thanks, my git client just shows "Some refs failed to push", when running git push from the command line I get the correct errors and could fix it.

Copy link
Collaborator

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @SimeonC!

@JamesHenry JamesHenry enabled auto-merge (squash) February 1, 2024 07:35
@JamesHenry JamesHenry merged commit ec4f7c5 into nrwl:master Feb 1, 2024
6 checks passed
FrozenPandaz pushed a commit that referenced this pull request Feb 2, 2024
Copy link

github-actions bot commented Feb 7, 2024

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants