noOctalEscape
¥Summary
-
规则生效日期:
v1.9.3¥Rule available since:
v1.9.3 -
诊断类别:
lint/suspicious/noOctalEscape¥Diagnostic Category:
lint/suspicious/noOctalEscape -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则包含 safe 修复程序。
¥This rule has a safe fix.
-
此规则的默认严重级别为 warning。
¥The default severity of this rule is warning.
-
来源:
¥Sources:
-
与
no-octal-escape相同¥Same as
no-octal-escape
-
¥How to configure
{ "linter": { "rules": { "suspicious": { "noOctalEscape": "error" } } }}¥Description
禁止在字符串字面量中使用八进制转义序列
¥Disallow octal escape sequences in string literals
根据 ECMAScript 5 规范,字符串字面量中的八进制转义序列已被弃用,不应再使用。应改用 Unicode 转义序列。
¥As of the ECMAScript 5 specification, octal escape sequences in string literals are deprecated and should not be used. Unicode escape sequences should be used instead.
¥Examples
¥Invalid
const foo = "Copyright \251";code-block.js:1:24 lint/suspicious/noOctalEscape FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Don’t use deprecated octal escape sequences.
> 1 │ const foo = “Copyright \251”;
│ ^^^^
2 │
ℹ Safe fix: Use hexadecimal escape sequences instead.
1 │ - const·foo·=·“Copyright·\251”;
1 │ + const·foo·=·“Copyright·\xa9”;
2 2 │
¥Valid
const foo = "Copyright \u00A9"; // unicode escapeconst bar = "Copyright \xA9"; // hexadecimal escape¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号