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

Add tally of fixable problems to string and verbose formatters #7539

Merged
merged 9 commits into from Feb 28, 2024

Conversation

m-allanson
Copy link
Member

Which issue, if any, is this issue related to?

Closes #7338

Is there anything in the PR that needs further explanation?

This PR adds a count of potentially fixable problems to the string formatter's output. e.g.

file.css
  1:2  ×  Unexpected foo  no-foo
  1:2  ×  Unexpected bar  no-bar
  1:2  ‼  Unexpected baz  no-baz

× 3 problems (2 errors, 1 warning)
  1 error and 1 warning potentially fixable with the "--fix" option.

The line 1 error and 1 warning potentially fixable with the "--fix" option. is new.

In adddition, I've adjusted the formatting slighty, to ensure that the most important line (the problem count) is still visually distinct. This new formatting imitates eslint's default output.

The formatting changes are:

  • add an × in front of the problem count, to highlight that line
  • indent the list of problems, so that the line numbers are vertically aligned with the problem count and fix count text.
Formatting examples

Here are examples of the formatting changes, excluding the new fixable counts.

Old formatting:

file.css
 1:2  ×  Unexpected foo  no-foo
 1:2  ×  Unexpected bar  no-bar
 1:2  ‼  Unexpected baz  no-baz

3 problems (2 errors, 1 warning)

New formatting:

file.css
  1:2  ×  Unexpected foo  no-foo
  1:2  ×  Unexpected bar  no-bar
  1:2  ‼  Unexpected baz  no-baz

× 3 problems (2 errors, 1 warning)

Copy link

changeset-bot bot commented Feb 25, 2024

🦋 Changeset detected

Latest commit: ef51335

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
stylelint Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ybiquitous
Copy link
Member

@m-allanson Thanks for the pull request.

  • add an × in front of the problem count, to highlight that line

That sounds good to me. But I am concerned about a case of 0 errors and some warnings, e.g.

file.css
 1:2  ‼  Unexpected baz  no-baz

× 1 problem (0 errors, 1 warning)

In this case, using instead of × seems a bit more consistent and readable for me. What do you think?

@ybiquitous ybiquitous changed the title Show a count of fixable problems in the string formatter Add tally of fixable problems to string and verbose formatters Feb 26, 2024
@m-allanson
Copy link
Member Author

Thanks for the review @ybiquitous 👍 This is updated and ready for another look.

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

Thank you. This PR is almost okay. But I just commented on a refactoring, so can you take a look?

lib/formatters/stringFormatter.mjs Outdated Show resolved Hide resolved
Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM 👍🏼

Copy link
Contributor

@Mouvedia Mouvedia left a comment

Choose a reason for hiding this comment

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

The tests look good to me.

@ybiquitous ybiquitous merged commit b644609 into stylelint:main Feb 28, 2024
16 checks passed
@m-allanson m-allanson deleted the issue-7338 branch March 25, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add tally of fixable problems to string formatter
3 participants