noUselessEscapeInRegex
¥Summary
-
规则生效日期:
v1.9.0¥Rule available since:
v1.9.0 -
诊断类别:
lint/complexity/noUselessEscapeInRegex¥Diagnostic Category:
lint/complexity/noUselessEscapeInRegex -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则包含 safe 修复程序。
¥This rule has a safe fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
来源:
¥Sources:
-
与
no-useless-escape相同¥Same as
no-useless-escape
-
¥How to configure
{ "linter": { "rules": { "complexity": { "noUselessEscapeInRegex": "error" } } }}¥Description
禁止在正则表达式文字中使用不必要的转义序列。
¥Disallow unnecessary escape sequence in regular expression literals.
在正则表达式文字中转义非特殊字符没有任何效果。因此,它们可能会让读者感到困惑。
¥Escaping non-special characters in regular expression literals doesn’t have any effect. Hence, they may confuse a reader.
¥Examples
¥Invalid
/\a/;code-block.js:1:2 lint/complexity/noUselessEscapeInRegex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ The character doesn’t need to be escaped.
> 1 │ /\a/;
│ ^^
2 │
ℹ Safe fix: Unescape the character.
1 │ /\a/;
│ -
/[\-]/;code-block.js:1:3 lint/complexity/noUselessEscapeInRegex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ The character doesn’t need to be escaped.
> 1 │ /[\-]/;
│ ^^
2 │
ℹ The character should only be escaped if it appears in the middle of the character class or under the `v` flag.
ℹ Safe fix: Unescape the character.
1 │ /[\-]/;
│ -
/[\&]/v;code-block.js:1:3 lint/complexity/noUselessEscapeInRegex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ The character doesn’t need to be escaped.
> 1 │ /[\&]/v;
│ ^^
2 │
ℹ Safe fix: Unescape the character.
1 │ /[\&]/v;
│ -
¥Valid
/\^\d\b//[\b]/¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号