src/content/docs/linter/rules/no-nonoctal-decimal-escape.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/correctness/noNonoctalDecimalEscape`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has a [**safe**](/linter/#safe-fixes) fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-nonoctal-decimal-escape`](https://eslint.org/docs/latest/rules/no-nonoctal-decimal-escape){
"linter": {
"rules": {
"correctness": {
"noNonoctalDecimalEscape": "error"
}
}
}
}
Disallow \8 and \9 escape sequences in string literals.
Since ECMAScript 2021, the escape sequences \8 and \9 have been defined as non-octal decimal escape sequences. However, most JavaScript engines consider them to be "useless" escapes. For example:
"\8" === "8"; // true
"\9" === "9"; // true
Although this syntax is deprecated, it is still supported for compatibility reasons. If the ECMAScript host is not a web browser, this syntax is optional. However, web browsers are still required to support it, but only in non-strict mode. Regardless of your targeted environment, it is recommended to avoid using these escape sequences in new code.
const x = "\8";
const x = "Don't use \8 escape.";
const x = "Don't use \9 escape.";
const x = "8";
const x = "Don't use \\8 and \\9 escapes.";