Sass

sass/no-legacy-color-functions

Adjust colours with color.scale or color.adjust (and read channels with color.channel), not darken, lighten, fade-out and the like.

drobnastatycznefe-sass

Dlaczego

darken, lighten, saturate, desaturate, adjust-hue, opacify, fade-in, transparentize, fade-out and the single-channel getters (red(), hue(), lightness()...) assume one sRGB colour space. They were deprecated in Dart Sass 1.79.0 and are removed in Dart Sass 2.0.0. darken($c, 20%) subtracts a fixed amount, so a dark colour turns black while a light one barely changes.

Poprawka

@use 'sass:color'; then color.scale($brand, $lightness: -20%) for a relative change (or color.adjust for an absolute one), with $space: oklch for perceptually even steps, and color.channel($c, 'lightness', $space: hsl) to read a channel. For colours that change at run time (themes, dark mode), use CSS color-mix(in oklch, var(--brand) 80%, black) instead.

Przykłady

// bad
.btn:hover { background: darken($brand, 10%); border-color: fade-out($brand, 0.5); }
// good
@use 'sass:color';
.btn:hover { background: color.scale($brand, $lightness: -10%, $space: oklch); border-color: color.change($brand, $alpha: 0.5); }

Źródła

Fakty

Identyfikator
sass/no-legacy-color-functions
Waga
drobna
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
scss vue svelte astro
Tylko w projektach z
sass
Uczy jej skill
fe-sass Sass (SCSS)
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain sass/no-legacy-color-functions