biome correctness/noNonoctalDecimalEscape
labelled safe
Analysis Nemotron 3 Super
The rule flags octal-like escape sequences '\8' and '\9' inside string literals.
Fix: Replace each occurrence of the escape sequence '\8' with the literal character '8' and '\9' with '9' within string literals.
8 hazards
- In template literals, replacing '\8' with '8' could alter interpolation if the original escape was part of a larger expression like `${x}\8${y}` where the literal now incorrectly merges with adjacent expressions.
- If the string literal is used in a context where the escape sequence was intended to represent two separate characters (backslash and digit) due to prior escaping (e.g., from code generation), the fix incorrectly collapses them into a single digit.
- In non-strict mode, while '\8' and '\9' are currently treated as '8' and '9', future ECMAScript revisions might repurpose these sequences, making the fix potentially non-forward-compatible if relied upon for specific behavior.
- If the string contains a comment-like sequence (e.g., in a multi-line string or template literal) that accidentally resembles '\8' or '\9', the fix might modify unintended parts of the string, altering embedded metadata or formatting.
- When the string literal is part of a larger expression involving concatenation (e.g., `'\8' + variable`), the fix changes the evaluation by replacing the escape with a literal, which may affect performance or side effects if the variable access has observable consequences.
- In tagged template literals, the raw string passed to the tag function differs between the original (containing the escape) and the fixed version, potentially changing the tag's behavior if it inspects the raw escapes.
- If the escape sequence appears inside a regular expression literal (which is not a string literal), the rule does not apply, but if mistakenly processed due to tooling error, the fix would corrupt the regex pattern.
- If the string literal is used to generate code dynamically (e.g., via `new Function()`), replacing '\8' with '8' alters the generated source, possibly changing the behavior of the resulting function.
Programs
| id | result | title | hazard |
|---|