Skip to content

Conversation

@ehzhang
Copy link

@ehzhang ehzhang commented Dec 15, 2018

Notable Changes

👋
This adds an emitWarningsAsErrors option to the postcss-loader config, which would (as the name suggests) emit warnings coming from postcss plugins as errors.

We're interested enforce issues coming as warnings to our build pipelines (and development workflows) and fail. For example, we might have typos in imported variable names var(--foobar), which get emitted as warnings and kind of hidden amongst the webpack output. We'd like to be extra strict for our css warnings 😬

An alternative on our end might be to check stats.warnings ourselves, but it would be nice to not have to filter through all other warnings that might not be coming from postcss-loader. Very welcome to feedback/discussion for this - would like to know what you might prefer/if this makes sense as a configuration option on this loader.

Thanks in general for maintaining this library :)

Commit Message Summary (CHANGELOG)

  • Adds an emitWarningsAsErrors flag to emit plugin warnings as errors

Type

ℹ️ What type of changes does your code introduce?

  • CI
  • Fix
  • Perf
  • Docs
  • Test
  • Style
  • Build
  • Chore
  • Feature
  • Refactor

Issues

ℹ️ What issue(s) (if any) are closed by your PR?

  • Fixes #1

SemVer

ℹ️ What changes to the current semver range does your PR introduce?

  • Fix (:label: Patch)
  • Feature (:label: Minor)
  • Breaking Change (:label: Major)

Checklist

ℹ️ You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. This is a reminder of what we are going to look for before merging your code.

  • Lint and unit tests pass with my changes
  • I have added tests that prove my fix is effective/works (if needed)
  • I have added necessary documentation (if appropriate)
  • Any dependent changes are merged and published in downstream modules

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 87.629% when pulling 634681e on ehzhang:ehzhang/error-on-warnings into 7647ac9 on postcss:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 87.629% when pulling 634681e on ehzhang:ehzhang/error-on-warnings into 7647ac9 on postcss:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 87.629% when pulling 634681e on ehzhang:ehzhang/error-on-warnings into 7647ac9 on postcss:master.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

No sure it is good idea, we need implement result.errors() (if it is available in postcss) or add property error to warning and use emitError for this case

@ehzhang
Copy link
Author

ehzhang commented Dec 17, 2018

Is it the implementation that isn't a good idea, or the addition of this config value?

I'm not sure what you mean by implementing result.errors() - my use case here is to effectively set the "log level" for warnings and escalate them from warnings to errors (and I use emitError with the Warning class)

@alexander-akait
Copy link
Member

alexander-akait commented Dec 18, 2018

@ehzhang it is good practice emit warnings as warnings and errors as errors (all loaders and plugins do it), maybe good idea create issue/PR in webpack and implement this feature in core, not in loaders/plugins (otherwise we need implement this option in all loaders/plugins and it is not good)

@ehzhang
Copy link
Author

ehzhang commented Dec 20, 2018

Sounds reasonable - kind of the response that I would've expected. I did notice that not many loaders do this (maybe the only exception would be one like ts-loader, that allows setting error levels).

I'll close this - thanks for taking the time to look it over!

@ehzhang ehzhang closed this Dec 20, 2018
@ehzhang ehzhang deleted the ehzhang/error-on-warnings branch December 20, 2018 05:51
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.

3 participants