Skip to content

noUselessEscapeInString

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: "\a"
}
code-block.css:2:14 lint/nursery/noUselessEscapeInString  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The character doesn’t need to be escaped.

1 │ a::after {
> 2 │ content: “\a”
^
3 │ }
4 │

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

Safe fix: Unescape the character.

2 │ ··content:·\a”
-
a::after {
content: "\'"
}
code-block.css:2:14 lint/nursery/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"
}
biome.json
{
"linter": {
"rules": {
"nursery": {
"noUselessEscapeInString": "error"
}
}
}
}