CSSLint / csslint

Automated linting of Cascading Stylesheets
http://csslint.net
Other
4.76k stars 483 forks source link

Ignore doesn't ignore? #685

Closed gaggle closed 6 years ago

gaggle commented 7 years ago

Hi,

When linting this .css file:

/* csslint ignore:start */
h1 {
  color: #f00;
}
h1 {
  color: #00f;
}
/* csslint ignore:end */

This error is produced:

npm-exec csslint public/main.css 
csslint: There is 1 problem in main.css.

main.css
1: warning
You have 2 h1s defined in this stylesheet.

Why is it not silenced by the csslint ignore clause?

frvge commented 7 years ago

The issue seems to be that rollups are not taking ignore into account. I don't think the Reporter can couple calls for rules (that are properly ignored) via report() with calls for the rollup because the context, like line number and column is missing.

There are only 5 occurences of rollupWarn and 1 for rollupError, so that's refactorable. Would you mind making a PR?

FYI: @XhmikosR .

gaggle commented 7 years ago

Hi @frvge,

I'm not sure exactly how to do this, will need more handholding. I've made a test to identify current behaviour, does this look like the right direction? https://github.com/gaggle/csslint/commit/41759bc0cde806f4b1f61b8599f9ec01f0eec072

I'm not yet sure what your comment on rollupWarn and rollupError implies, but maybe once I understand the tests..

SilkAndSlug commented 7 years ago

Hi @frvge,

Any chance this is going to be included in a release?

frvge commented 7 years ago

@SilkAndSlug , I'll try to do a minor change to the PR this weekend and then I'll see if someone can release it.

samdutton commented 6 years ago

I still have a similar problem using 1.0.4.

For example:

/* csslint ignore:start */
section {
  display: grid;
  grid-gap: 10px 20px;
  grid-template-columns: 1fr 3fr;
}
/* csslint ignore:end */

I get this:

>> ERROR: Unexpected token '1fr' at line 21, col 26. This rule looks for recoverable syntax errors. (errors) Browsers: All

Oddly, this does get rid of the following:

Unknown property 'grid-gap'.

frvge commented 6 years ago

fr is not supported yet by the parserlib dependency :(