Sass

sass/no-global-builtins

Call Sass built-in functions through their module (map.get, math.div, string.index) after @use "sass:...", not as globals.

drobnastatycznefe-sass

Dlaczego

The global names of Sass's built-in functions (map-get, nth, unit, str-index, percentage...) were deprecated together with @import in Dart Sass 1.80.0 and go away in Dart Sass 3.0.0. Until then every call prints a deprecation warning, which buries the warnings that matter in the build log.

Poprawka

Load the module once at the top of the file and call the namespaced function: @use 'sass:map'; then map.get($theme, primary); sass:math for math.div, math.percentage, math.unit; sass:list, sass:string, sass:meta, sass:selector for the rest. sass-migrator module --built-in-only src/main.scss rewrites the calls without touching @import.

Przykłady

// bad
.alert { color: map-get($colors, danger); width: percentage(1 / 3); }
// good
@use 'sass:map';
@use 'sass:math';
.alert { color: map.get($colors, danger); width: math.percentage(math.div(1, 3)); }

Źródła

Fakty

Identyfikator
sass/no-global-builtins
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-global-builtins