nonOctalDecimalEscapes
Reports non-octal decimal escape sequences (\8 and \9) in string literals.
✅ This rule is included in the ts logical
preset.
The escape sequences \8
and \9
in string literals are legacy features that behave as identity escapes, meaning they simply represent the literal digits “8” and “9”.
While these were allowed in most JavaScript engines before ECMAScript 2021, they are now specified as non-octal decimal escape sequences and are considered optional in the specification.
These escape sequences are not supported in strict mode in all environments and should be avoided when writing new code.
Examples
Section titled “Examples”const value = "\8";
const message = "w\8less";
const date = "December 1\9";
const text = "Don't use \8 and \9 escapes.";
const value = "8";
const message = "w8less";
const date = "December 19";
const text = "Don't use \\8 and \\9 escapes.";
Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”This rule should always be enabled as these escape sequences are legacy features that should not be used in modern JavaScript code.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noNonoctalDecimalEscape
- ESLint:
no-nonoctal-decimal-escape
- Oxlint:
eslint/no-nonoctal-decimal-escape
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.