Skip to content

SCSS !default / !global inside strings are treated as declaration flags #19203

Description

@fallintoplace

Prettier 3.8.3

When !default or !global appears inside a string or function argument in SCSS, Prettier treats it as a Sass declaration flag instead of part of the value.

Input:

$a: "!default";
$b: unquote("!default");
$c: url("x!global");

Actual output:

$a: " !default";
$b: unquote(" !default");
$c: url("x !global");

Expected output:

$a: "!default";
$b: unquote("!default");
$c: url("x!global");

This looks like the SCSS directive detection is matching raw !default / !global text before the value is parsed, so values containing those strings get split as if they had trailing Sass flags.

I can send a fix with regression tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions