noAdjacentSpacesInRegex
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/complexity/noAdjacentSpacesInRegex¥Diagnostic Category:
lint/complexity/noAdjacentSpacesInRegex -
此规则为推荐规则,默认启用。
¥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-regex-spaces相同¥Same as
no-regex-spaces
-
¥How to configure
{ "linter": { "rules": { "complexity": { "noAdjacentSpacesInRegex": "error" } } }}¥Description
禁止在正则表达式文字中不明确地使用连续空格字符
¥Disallow unclear usage of consecutive space characters in regular expression literals
¥Examples
¥Invalid
/ /code-block.js:1:2 lint/complexity/noAdjacentSpacesInRegex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This regular expression contains unclear uses of consecutive spaces.
> 1 │ / /
│ ^^^
2 │
ℹ It’s hard to visually count the amount of spaces.
ℹ Safe fix: Use a quantifier instead.
1 │ - /···/
1 │ + /·{3}/
2 2 │
/foo */code-block.js:1:5 lint/complexity/noAdjacentSpacesInRegex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This regular expression contains unclear uses of consecutive spaces.
> 1 │ /foo */
│ ^^
2 │
ℹ It’s hard to visually count the amount of spaces.
ℹ Safe fix: Use a quantifier instead.
1 │ - /foo··*/
1 │ + /foo·+/
2 2 │
/foo {2,}bar {3,5}baz/code-block.js:1:5 lint/complexity/noAdjacentSpacesInRegex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This regular expression contains unclear uses of consecutive spaces.
> 1 │ /foo {2,}bar {3,5}baz/
│ ^^^^^^^^^^^^
2 │
ℹ It’s hard to visually count the amount of spaces.
ℹ Safe fix: Use a quantifier instead.
1 │ - /foo··{2,}bar···{3,5}baz/
1 │ + /foo·{3,}bar·{5,7}baz/
2 2 │
/foo [ba]r b(a|z)/code-block.js:1:11 lint/complexity/noAdjacentSpacesInRegex FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This regular expression contains unclear uses of consecutive spaces.
> 1 │ /foo [ba]r b(a|z)/
│ ^^
2 │
ℹ It’s hard to visually count the amount of spaces.
ℹ Safe fix: Use a quantifier instead.
1 │ - /foo·[ba]r··b(a|z)/
1 │ + /foo·[ba]r·{2}b(a|z)/
2 2 │
¥Valid
/foo {2}bar// foo bar baz //foo bar baz/¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号