Skip to content

Latest commit

 

History

History
75 lines (58 loc) · 1.35 KB

at-each-key-value-single-line.md

File metadata and controls

75 lines (58 loc) · 1.35 KB

Pattern: Missing use of @each $key, $value

Issue: -

Description

This is a rule that checks for situations where users have:

  • Done a loop using map-keys
  • Grabbed the value for that key inside of the loop.
$font-weights: (
  "regular": 400,
  "medium": 500,
  "bold": 700
);
@each $key in map-keys($font-weights) {
  $value: map-get($font-weights, $key);
  /**        ↑
   * This call should be consolidated into the @each call.
   **/
}

Examples

true

The following patterns are considered violations:

$font-weights: (
  "regular": 400,
  "medium": 500,
  "bold": 700
);
@each $key in map-keys($font-weights) {
  $value: map-get($font-weights, $key);
}

The following patterns are not considered violations:

$font-weights: ("regular": 400, "medium": 500, "bold": 700);
@each $key, $value in $font-weights {...}
$font-weights: (
  "regular": 400,
  "medium": 500,
  "bold": 700
);
$other-weights: (
  "regular": 400,
  "medium": 500,
  "bold": 700
);

@each $key, $value in map-keys($font-weights) {
  $value: map-get($other-weights, $key);
}
$font-weights: ("regular": 400, "medium": 500, "bold": 700);

@each $key, $value in map-keys($font-weights) {...}

Further Reading