AndyOGo / stylelint-declaration-strict-value

Specify properties for which a variable, function, keyword or value must be used.
MIT License
134 stars 10 forks source link

Optimistic shorthand parsing? #114

Closed ariarzer closed 4 years ago

ariarzer commented 4 years ago

I'm having trouble using shorthand like border: 0;.

I use this config:

    'scale-unlimited/declaration-strict-value': [
      [
        '/color/',
        'fill',
        'stroke',
      ], {
        ignoreValues: [
          'currentColor',
          'transparent',
          'inherit',
        ],
      }
    ],

If i use expandShorthand: true option, I have warning Expected variable, function or keyword for "0" of "border". But, if i don't use this option, I loss warning, like for border: 1px solid #eee;.

Want to make an option for optimistic parsing?

Or I didn’t find it in the documentation, then sorry 😖

Thanks in advance for your reply!)

AndyOGo commented 4 years ago

Hi @ariarzer

Sorry, I just re-read your issue.

Regarding border: 0, it gets expanded by shortcss to ['border-width: 0', 'border-style: 0', 'border-color: 0'] (without recursion). You see shortcss expansion, does not check if the expanded value is valid CSS.

An explanation why this is like that can be found in that repo too: https://github.com/AndyOGo/stylelint-declaration-strict-value#css-shorthand-syntax

AndyOGo commented 4 years ago

Alright, I found a module which offers to validate CSS property/value pairs, though it is still alpha. https://github.com/ben-eb/css-values

AndyOGo commented 4 years ago

Thank you @ariarzer

I have created a PR #115 to address you issue with css-values module. It's support for properties is enough for your border: 0; case, but may be an issue elsewhere. All supported properties can be found here: https://github.com/ben-eb/css-values#property-support

AndyOGo commented 4 years ago

Hi @ariarzer I just released a patch version v1.6.1. This should be now working for you.

ariarzer commented 4 years ago

Thanks you very much!

AndyOGo commented 4 years ago

You are welcome.

Apologize my initial reply, I was distracted and in a hurry and miss-read your message.

Enjoy your day.