postcss / postcss-custom-properties

Use Custom Properties in CSS
https://postcss.github.io/postcss-custom-properties
MIT License
596 stars 77 forks source link

Incorrect docs on 'warning' option #84

Closed ZhangYiJiang closed 6 years ago

ZhangYiJiang commented 6 years ago

warnings

Default: true Type: Boolean|Object

Allows you to enable/disable warnings. If true, will enable all warnings. For now, it only allow to disable messages about custom properties definition not scoped in a :root selector.

The Object type originally made me assume that we could configure specific warnings to silence, but after checking the source it seems that it is merely a boolean value. Was this the intention? Either way, I'd like to open a PR to fix this (either the docs, or to implement the object option).

My preference would be to make it toggle all if the value is boolean, and to toggle specific warnings if it is an object. We just made a mess of our project because we turned warnings off and it silenced an error that would have told us something was wrong.

(Long story: We wanted to implement night mode using CSS custom properties, but fallback to the default (non-night mode) values for browsers that don't support this. Due to conflicts with another CSS processor above the chain some of the variables were not set properly, but we did not notice this because we had silenced warnings because this plugin was generating a lot of warning for custom properties definition not scoped in a :root selector, which we were fine with.

So we basically broke our site for a small number of our users. Not the fault of this plugin really, but it would have been nice to have been able to only silence the warning that we were okay with ignoring.)

jonathantneal commented 6 years ago

@ZhangYiJiang, thank you for pointing out this error in the documentation! I’m really sorry it gave you all any trouble. While I haven’t managed this project before and I’m not prepared for flesh out a warning object, I’ve made a PR to prevent others from experiencing similar trouble. See #91