Skip to content

Latest commit

 

History

History
105 lines (86 loc) · 1.75 KB

File metadata and controls

105 lines (86 loc) · 1.75 KB

at-each-key-value-single-line

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.
   **/
}

Options

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);
}
@use 'sass:map';

$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);
}
@use 'sass:map';

$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) {...}
@use 'sass:map';

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