csstree / stylelint-validator

Stylelint plugin to validate CSS syntax
MIT License
93 stars 11 forks source link

`inherit` should be accepted for `color` #27

Closed silverwind closed 3 years ago

silverwind commented 3 years ago

According to the spec, inherit is a valid value for the color property but it's being rejected:

a { color: inherit } /* Invalid value for `color` */

I assume this is an issue for many if not all properties that can take <color>.

lahmatiy commented 3 years ago

That's definitely a bug and affects all the properties.

silverwind commented 3 years ago

Seems correct. MDN also says it can be applied to any CSS property.

lahmatiy commented 3 years ago

@silverwind I checked it right now and can't reproduce. May be you have some specific conditions?

silverwind commented 3 years ago

Hmm, can't reproduce either with a fresh repo. Will check further.

silverwind commented 3 years ago

Actually it seems it's an error on my side. I was liniting a Less source and the plugin was outputting a wrong line number and I saws color: inherit near the reported line so I assumed it was that.

I've reduced the file down to the error and found out it's actually color: lighten(#000000, 70%) that is causing the error and I guess that may just be expected because this plugin is probably not aware of Less functions.

The wrong line numbers are probably a different bug, maybe it has to do something with Less being involved.

jeddy3 commented 3 years ago

I guess that may just be expected because this plugin is probably not aware of Less functions.

I believe you can extend type definition dictionary, if you want.

For example:

{
  "plugins": [
    "stylelint-csstree-validator"
  ],
  "rules": {
    "csstree/validator": {
      "types": {
        "color": "| lighten(<color>, <percentage>)"
      }
    }
  }
}
silverwind commented 3 years ago

Yeah, I think it should be possible to create a config to cover Less/Sass extensions with that, thanks.