sh-waqar / stylelint-declaration-use-variable

A stylelint custom rule to check the use of scss variable on declaration.
MIT License
82 stars 18 forks source link

Multiple properties only works if property array is nested within another array #8

Open anglepoised opened 8 years ago

anglepoised commented 8 years ago

The multiple properties example in the README doesn't work for me:

// .stylelintrc
"rules": {
  // ...
  "declaration-use-variable": ["/color/", "z-index", "font-size"],
  // ...
}

I only get lint results for the first property (in this case, /color/). However, if I add another array to the rule:

// .stylelintrc
"rules": {
  // ...
  "declaration-use-variable": [
      [
        "/color/",
        "z-index",
        "font-size"
    ]
  ],
  // ...
}

...everything works as expected (i.e. I get lint errors for all properties in the array).

Seems to be the same as at https://github.com/sh-waqar/stylelint-declaration-use-variable/issues/1#issuecomment-222474593. Discovered this while playing around with setting severity to warning, so this is my full, working rule object:

"rules": {
  "declaration-use-variable": [
    [
     "/color/",
     "z-index",
     "font-size",
     "font-family"
    ],
    {
      "severity": "warning"
    }
  ]
}

May be something to do with how rule options are determined?

I'm using:

Happy to provide an isolated test-case and run against other versions of node, stylelint etc if you think doing this would be useful.

pascalduez commented 8 years ago

Same here, only the first item of the array is used. Probably it's just about updating the readme :)

anglepoised commented 8 years ago

I wonder if for consistency it should follow the same pattern for options as the core stylelint rules that accept either a string or an array, e.g. function-whitelist?

Either way, this is a very useful plugin. Thanks, @sh-waqar!

rvetere commented 8 years ago

So.. we should just update the readme right?

sh-waqar commented 8 years ago

@rvetere - I already have updated the readme. In commit 5f38e4e584410c4ca7f8d072da12ce481e3b57f3

rvetere commented 8 years ago

ah true i see it now - so then close this issue i would say ;) Is there already a new version available with the latest merges? So i could change back to a version in my package.json instead of referencing my github fork ;)

sh-waqar commented 8 years ago

@rvetere - Actually the [[]] method is just a way around to solve the issue. To make this work as per the stylelint guideline and rule standard I have to update the plugin a little. Refer the issue here: https://github.com/stylelint/stylelint/issues/1579

sh-waqar commented 8 years ago

I am updating the npm package right now. :smile: