Skip to content

noUselessEscapeInString (CSS)

biome.json
{
"linter": {
"rules": {
"suspicious": {
"noUselessEscapeInString": "error"
}
}
}
}

Disallow unnecessary escapes in string literals.

Escaping non-special characters in string literals doesn’t have any effect. Hence, they may confuse a reader.

a::after {
content: "\z"
}
code-block.css:2:14 lint/suspicious/noUselessEscapeInString  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ The character doesn't need to be escaped.

1 │ a::after {
> 2 │ content: "\z"
│ ^
3 │ }
4 │

ℹ Only quotes that enclose the string and special characters need to be escaped.

ℹ Safe fix: Unescape the character.

2 │ ··content:·"\z"
│ -
a::after {
content: "\'"
}
code-block.css:2:14 lint/suspicious/noUselessEscapeInString  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ The character doesn't need to be escaped.

1 │ a::after {
> 2 │ content: "\'"
│ ^
3 │ }
4 │

ℹ Only quotes that enclose the string and special characters need to be escaped.

ℹ Safe fix: Unescape the character.

2 │ ··content:·"\'"
│ -
a::after {
content: "\""
}
a::after {
content: "\n"
}
a::after {
content: "\e7bb"
}