Skip to content

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.

const message = "Hello\07World";
const path = "C:\01\02\03";
const octal = "\377";

This rule is not configurable.

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.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.