SimenB / stylint

Improve your Stylus code with Stylint
https://simenb.github.io/stylint/
GNU General Public License v2.0
348 stars 61 forks source link

Multiple checkers fail on nested hash structures #251

Open thybzi opened 8 years ago

thybzi commented 8 years ago

Having this:

$icons = {
  about: {
    size: 15px
    color: #bada55
  }
  search: {
    size: 17px
    color: #90091e
  }
}

Linter output:

Warning: unecessary bracket
File: test.styl
Line: 6: search: {

Warning: property is not valid
File: test.styl
Line: 6: search: {

Warning: hexidecimal color should be a variable
File: test.styl
Line: 8: color: #90091e

Warning: unecessary bracket
File: test.styl
Line: 9: }

Warning: unecessary bracket
File: test.styl
Line: 10: }

Warnings for about and search "invalid properties" can be suppressed by quoting these keys: 'about' and 'search'. For nested keys like size even quoting doesn't make any sense.

P.S. However, single-level hash passes every linter:

$icon-about = {
  size: 15px
  color: #bada55
}
thybzi commented 8 years ago

Also it's quite wierd that linter doesn't pay attention to color values in the first nested hash (I think that could be somehow connected with successful passing for single-level hash)

This rule also applies if I have two color items in each nested hash. In the following construct both colors for search item are reported, and both for about item aren't reported:

$icons = {
  about: {
    size: 15px
    color: #bada55
    background: #90091e
  }
  search: {
    size: 17px
    color: #90091e
    background: #bada55
  }
}

(And if I swap search and about order, so the search is first, only about's color are reported)