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 at-charset-rule-no-invalid
#7492
Comments
@firefoxic Thanks for the proposal. Very interesting to me. Before looking into this issue and
So, I wonder if a new rule should disallow the use of @charset "UTF-8"; /* Unexpected deprecated "@charset" (no-charset) */ This rule might be expected to be put in the recommended config, as you suggest. |
I'm not sure about this. The same article https://developer.mozilla.org/en-US/docs/Web/CSS/@charset also mentions this:
Maybe someone can rely on such an encoding declaration. On the other hand, it's just one way to determine encoding. And if it really is deprecated, linter would be better off not allowing it at all. Then yes, the rule would be better called But if it is possible to specify
That is, there must be double quotes ( |
Yes, this matters. We want the rationale of this deprecation, maybe somewhere in CSS specs? |
I think this is an error/ambiguity in the mdn docs. In CSS 2.1 https://www.w3.org/TR/css-syntax-3/#charset-rule So the deprecation is limited to how If I am reading everything correctly |
Thanks. These MDN docs seemed to be updated by PR mdn/content#31076 |
@SelenIT maybe you can help with this vague wording? |
I've opened an issue to ask the spec editors directly : w3c/csswg-drafts#9838 |
Given the answer, it seems that the rule would still make sure that |
And preceding content :
|
@romainmenke Thanks for the effort. I now understand the syntax spec. But I still wonder if |
As far as I understand it, if the developer even crookedly wrote something like There is no necessity for |
Correct, the default is The primary use case is:
In that very specific case you can use Today it would be exceedingly rare to need this given that everything has become I think there can be general guidance that |
You can have |
I have already started to think about how much, what and how I will have to change in the plugin in view of everything discussed here. But I decided to take a look at the Stylelint code — it turns out that it also needs a lot of changes. For example: And if in the readme files in the code examples Also, considering that Looks like I've opened a closet whose junk has us all in over our heads 🤪 |
@firefoxic @romainmenke Thanks for your kind explanation. I understand the necessity to lint However, I still wonder whether we should implement the new rule and include it in the recommended config. If it's rarely used, is it worth implementing it? Wouldn't a plugin be enough? |
About the presence of a rule in Stylelint and in the config I think it is necessary to decide separately. Although it's not for me to decide, but my opinion is as follows: the rule should be in Stylelint itself, if only because it's about syntax, not preferences. And also because the logic of this rule should (in my opinion) affect fixes in other parts of Stylelint code (and plugins like mine). On the config, my opinion would be even less relevant. But if the rule appears in Stylelint, it would make more sense to me to see it in |
Okay, there seems to be some rationale in the new rule. Additionally, I'd like to clarify a few more things:
Of course, as far as we know now. |
charset-syntax-correct
ruleat-charset-rule-no-invalid
What is the problem you're trying to solve?
I went to fix this bug. And found out that
@charset
is not even an at-rule, but a special construct with much stricter syntax requirements than at-rules. And it doesn't seem to be about choosing a formatting style at all. After all, if the quotes are single, the parser will just pass it by without recognizing it as an encoding declaration. It is good if the encoding isutf-8
, which is the default encoding. But if another encoding is used, it will probably cause an error.So it's so much a matter of syntax (rather than formatting style) that the rule controlling
@charset
:true
;What solution would you like to see?
Add a separate rule to control the
@charset
syntax, which would take into account the character set of this declaration, its location in the style file, and maybe something else I may not know about yet.The text was updated successfully, but these errors were encountered: