sass / linter

An experimental Sass linter written using the Dart Sass AST
MIT License
39 stars 6 forks source link

Add a lint for using @each with maps properly #33

Open nex3 opened 5 years ago

nex3 commented 5 years ago

A pattern I see occasionally is:

@each $key in map-keys($map) {
  $value: map-get($map, $key);
  // ...
}

This is an unnecessarily verbose way of writing:

@each $key, $value in $map {
  // ...
}

There are also some legitimate cases where only the key is used, so maybe it's a good idea to look for the pattern map-get($map, $key) in the loop body before raising the lint?