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”If your project has portions that perform raw string manipulations and rely on legacy octal escape sequences, it might be difficult to refactor towards code that passes this rule. You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.
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