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.

This rule should always be enabled as these escape sequences are legacy features that should not be used in modern JavaScript code.

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