CSSLint complains 'Rule is empty' when defining variables



Firefox OS
4 years ago
5 months ago


(Reporter: wilsonpage, Unassigned)


Firefox Tracking Flags

(Not tracked)




4 years ago

:root {
  --my-color: red;

Error: 'Rule is empty. line 1, col 1'
This is an issue with CSSLint, we should report it at https://github.com/CSSLint/csslint/issues.

We could also disable the empty-rules check in our config. I'd prefer to see this fixed in CSSLint.


4 years ago
Duplicate of this bug: 1062594

Comment 3

4 years ago
Filed [1]. I'm curious to know how files like [2] got past the linter when it includes a :root selector with only CSS variables, which should be considered empty.

Also, I'm not sure how active csslint is lately, and I've got something I'll need to land for 2.1 using one of these variables. At this point, I would like to be able to commit without breaking builds. How would you feel about adding a hack to make the rule non-empty for the purpose of committing with the intent to remove? Something like:

  :root {
    display: block; /* The :root html element is display: block anyway, so this should be harmless */
    --software-home-button-height: 4.5rem;

It's either that or disabling the empty-rules check. Thoughts?

[1] https://github.com/CSSLint/csslint/issues/538
[2] https://github.com/mozilla-b2g/gaia/blob/master/shared/elements/gaia-theme/style.css#L8
Flags: needinfo?(anthony)
You can add known errors for this file while we wait for CSSLint feedback.

See https://github.com/mozilla-b2g/gaia/blob/2bac78bdd09552ce42fa4eee88d96483b0a66dcf/build/csslint/xfail.list#L77
Flags: needinfo?(anthony)

Comment 5

4 years ago
I've also just found that you can use a comment ignore as well:

  /*csslint empty-rules: false*/

Would the xfail.list still be preferable?
Is this comment disabling empty-rules for the whole file or just a rule? If it's the whole file, I think xfail.list is preferable.

Comment 7

5 months ago
Firefox OS is not being worked on
Last Resolved: 5 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.