-
Notifications
You must be signed in to change notification settings - Fork 77
Bring back warning option #159
Comments
Hey there, I understand your concerns. I do recommend that you use a linter. It sounds like it would have resolved your issues. I’m not sure why you would want these things linted while you would not want a linter to tell you. You’ve made some assumptions about how folks use Custom Properties, which I think are fair assumptions if you were accustomed to Sass variables, but do not necessarily apply to the dynamic abilities of Custom Properties.
It is recommended that this plugin be used with a browserslist, and to be forward-compliant, it gracefully allows spec-compliant variables even if they cannot be detected. However, a fair number of PostCSS Preset Env users are not providing Custom Property fallbacks for IE, because their browserslist does not include IE.
An unmatched Custom Property will not break any rule in CSS. Custom Properties can and do sit around waiting for something to activate them, usually via JavaScript.
This isn’t necessarily so, if the Custom Properties are coming from non-PostCSS styles or third-party styles or if they are activated via JavaScript. |
In that case, wouldn't PostCSS Preset Env just exclude this plugin altogether? Why perform redundant work, and duplicate custom property values if you are developing for a browser which supports them without transformation? |
I’m always willing to listen to new ideas and arguments, as well as rehash old ones, but I consider it bad form to open new issues and also critique what I’m saying on dead issues. I do see that you commented there and then here. Thank you for correcting me. I need to figure out how to lock dead issues, as I errantly became very worried you would create multiple threads for me to respond to. |
I’m re-opening the issue so others can contribute. I still feel the same way that your suggestion is best covered by a linter, but I don’t want my misunderstanding to get in the way of proper discussions and development. |
I understand the concern. :) OSS development is a thankless job, and developers can be entitled brats. |
I think the warnings should be brought back as well. Since this plugin statically compiles the variables, if the plugin can't find it, it should emit a warning. I think the linting rule is appropriate for catching missing variables when using the native custom-properties feature (dynamic CSS variables), but isn't appropriate to catch compilation errors. |
I need to remind you all that it’s not a compilation error. You don’t have to have Custom Properties defined to use them. |
But again, why would you be using this plugin if you are developing for a browser which supports custom properties natively? I think in cases like this, it helps to think of the average use-case. I can't say for sure, but I would reckon that the majority of users of this plugin are developing for at least one browser which doesn't support native custom properties. As such, if they have a custom property lacking a definition, they will get unexpected behavior when they deploy their code (e.g. why isn't this font |
@jonathantneal I was looking around for info on how to report (warn or bail) the use of undefined properties (with or without fallback) and also the declaration of unused ones. Do you know the existence of such rules/plugins for stylelint? If not, is it even possible? — How would a stylelint plugin match property declarations to I feel these features are worth to be included here because they are very implementation-specific. |
All of this is possible with: https://www.npmjs.com/package/stylelint-value-no-unknown-custom-properties And it uses the same style of options as this plugin. |
Alright, it is implemented as I expected. Not ideal, but works nonetheless. 😄 I will try to create one for the unused ones. Or does it exist already? |
I'm gonna go out on a limb here and say that the
warning
option should be brought back. I understand that you think it is the job of a linter, but I kindly disagree. :) Follow with me, and please correct me if I'm wrong on any of these points:Why leave this type of thing up to a linter? Just this week I ran into an issue where custom properties were not being replaced, and didn't realize it until trying my code in IE. The
warning
option already defaulted tofalse
, so it didn't bother anyone who didn't specifically opt-in to it, so why remove it for those who want to use it?From the release notes:
I appreciate the forward-thinkingness, but if you think the browser climate is so good, shouldn't you just deprecate this plugin as it's not needed anymore? 🤷♂️
The majority of developers have to write code for browsers without custom properties support. Why not give them hints about conditions which could break their code?
Thanks!
Related #153, #117.
The text was updated successfully, but these errors were encountered: