noMultipleSpacesInRegularExpressionLiterals
诊断类别:lint/complexity/noMultipleSpacesInRegularExpressionLiterals
¥Diagnostic Category: lint/complexity/noMultipleSpacesInRegularExpressionLiterals
自从:v1.0.0
¥Since: v1.0.0
来源:
¥Sources:
-
与以下相同:
no-regex-spaces
¥Same as:
no-regex-spaces
禁止在正则表达式文字中不明确地使用连续空格字符
¥Disallow unclear usage of consecutive space characters in regular expression literals
¥Examples
¥Invalid
code-block.js:1:2 lint/complexity/noMultipleSpacesInRegularExpressionLiterals 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 │
code-block.js:1:5 lint/complexity/noMultipleSpacesInRegularExpressionLiterals 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 │
code-block.js:1:5 lint/complexity/noMultipleSpacesInRegularExpressionLiterals 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 │
code-block.js:1:11 lint/complexity/noMultipleSpacesInRegularExpressionLiterals 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
¥Related links