noNonoctalDecimalEscape
Summary
Section titled “Summary”- Rule available since: v1.0.0
- Diagnostic Category: lint/correctness/noNonoctalDecimalEscape
- This rule is recommended, which means is enabled by default.
- This rule has a safe fix.
- The default severity of this rule is error.
- Sources:
- Same as no-nonoctal-decimal-escape
 
- Same as 
How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "correctness": {        "noNonoctalDecimalEscape": "error"      }    }  }}Description
Section titled “Description”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"; // trueAlthough 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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”const x = "\8";code-block.js:1:12 lint/correctness/noNonoctalDecimalEscape  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Don’t use \8 and \9 escape sequences in string literals.
  
  > 1 │ const x = “\8”;
      │            ^^
    2 │ 
  
  ℹ The nonoctal decimal escape is a deprecated syntax that is left for compatibility and should not be used.
  
  ℹ Safe fix: Replace \8 with 8. This maintains the current functionality.
  
    1 │ const·x·=·“\8”;
      │            -   
const x = "Don't use \8 escape.";code-block.js:1:22 lint/correctness/noNonoctalDecimalEscape  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Don’t use \8 and \9 escape sequences in string literals.
  
  > 1 │ const x = “Don’t use \8 escape.”;
      │                      ^^
    2 │ 
  
  ℹ The nonoctal decimal escape is a deprecated syntax that is left for compatibility and should not be used.
  
  ℹ Safe fix: Replace \8 with 8. This maintains the current functionality.
  
    1 │ const·x·=·“Don’t·use·\8·escape.”;
      │                      -           
const x = "Don't use \9 escape.";code-block.js:1:22 lint/correctness/noNonoctalDecimalEscape  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Don’t use \8 and \9 escape sequences in string literals.
  
  > 1 │ const x = “Don’t use \9 escape.”;
      │                      ^^
    2 │ 
  
  ℹ The nonoctal decimal escape is a deprecated syntax that is left for compatibility and should not be used.
  
  ℹ Safe fix: Replace \9 with 9. This maintains the current functionality.
  
    1 │ const·x·=·“Don’t·use·\9·escape.”;
      │                      -           
const x = "8";const x = "Don't use \\8 and \\9 escapes.";Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.