Skip to content
← Back to rules

eslint/no-nonoctal-decimal-escape Correctness

This rule is turned on by default.
💡 A suggestion is available for this rule.

作用

此规则不允许在字符串字面量中使用 \8 和 \9 转义序列。

为什么这不好?

ECMAScript 规范将字符串字面量中的 \8 和 \9 视为一种遗留特性

示例

此规则的错误代码示例:

javascript
let x = "\8";
let y = "\9";

此规则的正确代码示例:

javascript
let x = "8";
let y = "\\9";

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "no-nonoctal-decimal-escape": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "no-nonoctal-decimal-escape": "error",
  },
});
bash
oxlint --deny no-nonoctal-decimal-escape

版本

此规则已在 v0.2.10 中添加。

参考资料