Skip to content

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.

const value = "\8";
const message = "w\8less";
const date = "December 1\9";
const text = "Don't use \8 and \9 escapes.";

This rule is not configurable.

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.

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