octalEscapes
Reports using octal escape sequences in string literals.
✅ This rule is included in the ts logical
preset.
Octal escape sequences (e.g., \01
, \02
, \377
) are a deprecated feature in JavaScript that can lead to confusion and portability issues.
They are forbidden in strict mode code, template literals, and are less readable than their modern alternatives.
The null character escape sequence \0
(when not followed by an octal digit) is still allowed as it is commonly used and well-understood.
Examples
Section titled “Examples”const message = "Hello\07World";const path = "C:\01\02\03";const octal = "\377";
const message = "Hello\x07World";const path = "C:\x01\x02\x03";const octal = "\xFF";
// The null character escape is allowedconst nullChar = "\0";
Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you need to maintain compatibility with very old JavaScript engines that don’t support hexadecimal or Unicode escape sequences, you might choose to disable this rule. However, this is extremely rare in modern development.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noOctalEscape
- ESLint:
no-octal-escape
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.