6

I'm working with a CSS file that uses Mozilla's -moz-element(#element) directive for a background-image. The code looks like:

#foo {background-image: -moz-element(#element);}

When I run this through CSSLint, it tells me that the "Rule is empty", despite the fact that it's obviously not. I could attempt to run CSSLint via command line and use --ignore, but what I'm really looking for is a way to ignore just that single line from within my CSS file. Is there a way to do that?

And just for clarity, what I'm looking for is the analogue to how JSHint does things, which looks like this:

var notChecked = 'This line won't get checked'; // jshint ignore:line

Funktr0n
  • 1,711
  • 2
  • 16
  • 23
  • I don't know CSSList, but if it really treats -moz- prefixed names as not there, you might get away with putting this line inside a `@-moz-document` rule. See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/@document). – Mr Lister Mar 25 '15 at 10:27
  • Not really looking for a way to hack my code to get it to work with CSSLint (I'd just disable CSSLint completely before I did that). Looking for an elegant one-line ignore that keeps things nice. Thanks tho. – Funktr0n Mar 25 '15 at 18:25
  • Wouldn't it be better to figure out why CSSLint reports a spurious warning for that line, and fix that issue, rather than trying to ignore the line? – augurar Apr 20 '21 at 00:11

4 Answers4

8

Using an embedded ruleset:

/*csslint important: false*/

.example {
  display: none ! important 
}

/*csslint important: true*/
peterorum
  • 1,401
  • 2
  • 15
  • 21
  • 1
    Status: **Not worked** for me. // **1.** It's [**not documented**](https://github.com/CSSLint/csslint/wiki/Ignoring-parts-of-CSS-during-linting). // **2.** It doesn't worked, if I needed to ignore 2 or more rules in the same file. [**Example**](https://www.pastery.net/xnusrs/). // Thanks. – Саша Черных Oct 13 '19 at 14:54
2

CSSLint does not currently support a single-line ignore function from within a CSS file. Hopefully (would be awesome!) this changes in the future.

Funktr0n
  • 1,711
  • 2
  • 16
  • 23
0

One can also ignore sections with:

/* csslint ignore:start */
@import('normalize.css');
/* csslint ignore:end */

And also allow:

.foo.bar { /* csslint allow: adjoining-classes */
  margin: 0;
}
Robert Brisita
  • 5,461
  • 3
  • 36
  • 35
  • v0.5 came out 5 years ago (July 29, 2011 - v0.5.0). I suggest you upgrade to v1.0. – Robert Brisita Dec 16 '16 at 23:38
  • Doesn't work for me in 1.0.4. For example: /* csslint ignore:start */ section { display: grid; grid-template-columns: 1fr 3fr; } / * csslint ignore:end */ – Sam Dutton Mar 29 '18 at 16:55
  • The GitHub repository is linked in the answer. Feel free to review the current issues and create a new one if none exists. – Robert Brisita Mar 29 '18 at 22:44
-2

In version 0.9.10+ you can use "embedded rulesets" directly in the CSS file.

If that doesn't work, you could try placing that line in a CSS comment, for example:

/* #foo {background-image: -moz-element(#element);} */
Tom
  • 74
  • 9