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

Should also report errors by default #75

Merged
merged 3 commits into from Jan 16, 2024
Merged

Should also report errors by default #75

merged 3 commits into from Jan 16, 2024

Conversation

onigoetz
Copy link
Contributor

Hi, it seems that at some point ( 56a8e5a ) there was a change that hid .type === "error" reports.

This is a surprising behaviour and definitely looks like a bug to me

@ai
Copy link
Member

ai commented Jan 15, 2024

Right now, we recommend to throwing errors by Node#error().

Do you have use case for messages for errors?

@onigoetz
Copy link
Contributor Author

oh interesting, I did not know of this method.

My use case is to make a series of checks on a bundle (so Stylelint is not applicable here).
Then report them all in a nice way and stop the build if there was at least an error.

I'm not interested in just reporting a single error at a time.

@ai
Copy link
Member

ai commented Jan 15, 2024

Hm. In this case, we should throw some error from postcss-reporter to have non-zero exit code for the app.

Maybe it is better to create your own custom plugin because we will need think a lot to create a good design for that for everyone.

@onigoetz
Copy link
Contributor Author

This is already handled here : https://github.com/postcss/postcss-reporter/blob/main/lib/reporter.js#L83-L89

although I am a bit puzzled that it would also throw on a warning, but I guess this is a matter of taste.
Some other tools like gulp-stylelint or gulp-eslint-new have a failAfterError option that fails only if an error was reported.

@ai
Copy link
Member

ai commented Jan 15, 2024

This is already handled here : https://github.com/postcss/postcss-reporter/blob/main/lib/reporter.js#L83-L89

In this case we should have thrown always on error and update docs to highlight that that option is about warnings.

And change error message.

@onigoetz
Copy link
Contributor Author

I can add this to this PR (or a separate PR if you prefer)

@ai
Copy link
Member

ai commented Jan 15, 2024

Let's have one feature PR where feature will be done to check the final design before merging

@onigoetz
Copy link
Contributor Author

sure!

In the meantime is the current PR ok for you?

@ai
Copy link
Member

ai commented Jan 15, 2024

It is hard to say, because in PR I look for overall changes.

Let's finish all changes first.

@ai
Copy link
Member

ai commented Jan 15, 2024

BTW, how we will format errors?

@onigoetz
Copy link
Contributor Author

ah okay, so I misunderstood what you said earlier, I'll add the changes to errors here as well.

Currently, errors use the same behaviour as a warning, it's an entry with text, there isn't any stacktrace

@ai
Copy link
Member

ai commented Jan 15, 2024

We don't need a stacktrace, but we need a different color and icon to separate them from warnings

@onigoetz
Copy link
Contributor Author

Indeed, I'll include that and make a proposal for that as well

@onigoetz
Copy link
Contributor Author

Hi, I made the following changes

  • Added a cross icon for errors when formatting
  • Always throw an error when an error is present in the messages
  • The throwError option still exists but will make it also throw when a warning is reported (kept the name for backwards compatibility)
  • Added a summary at the end of the report

Here is how the summary looks like :
image

image

One thing I'm unclear on at this stage is :

  • Should the option to throw on warnings be renamed?
  • Should there be an option not to throw on error?

@ai ai merged commit 7109853 into postcss:main Jan 16, 2024
5 checks passed
@ai
Copy link
Member

ai commented Jan 16, 2024

Looks amazing. I am going to release it today.

@ai
Copy link
Member

ai commented Jan 16, 2024

This feature was released in 7.1.

@onigoetz
Copy link
Contributor Author

Awesome, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants