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