Skip to content

noOctalEscape

Disallow octal escape sequences in string literals

As of the ECMAScript 5 specification, octal escape sequences in string literals are deprecated and should not be used. Unicode escape sequences should be used instead.

const foo = "Copyright \251";
code-block.js:1:24 lint/nursery/noOctalEscape  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Don’t use deprecated octal escape sequences.

> 1 │ const foo = “Copyright \251”;
^^^^
2 │

Safe fix: Use hexadecimal escape sequences instead.

1 - const·foo·=·Copyright·\251;
1+ const·foo·=·Copyright·\xa9;
2 2

const foo = "Copyright \u00A9"; // unicode escape
const bar = "Copyright \xA9"; // hexadecimal escape
biome.json
{
"linter": {
"rules": {
"nursery": {
"noOctalEscape": "error"
}
}
}
}