#7492·stylelint

Add `at-charset-rule-no-invalid`

Author: firefoxicCreated Jan 23, 2024Updated Sep 13, 2026
Labelsstatus: wipsubtype: new rule

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 is utf-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:

  1. should be in Stylelint itself, not in the plugin;
  2. should have one single option — the value true;
  3. should be added not even to the standard, but to the recommended config.

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.