Skip to content

noMultipleSpacesInRegularExpressionLiterals (since v1.0.0)

Diagnostic Category: lint/complexity/noMultipleSpacesInRegularExpressionLiterals

Sources:

Disallow unclear usage of consecutive space characters in regular expression literals

/ /
complexity/noMultipleSpacesInRegularExpressionLiterals.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  
  
/foo */
complexity/noMultipleSpacesInRegularExpressionLiterals.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  
  
/foo {2,}bar {3,5}baz/
complexity/noMultipleSpacesInRegularExpressionLiterals.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  
  
/foo [ba]r b(a|z)/
complexity/noMultipleSpacesInRegularExpressionLiterals.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  
  
/foo {2}bar/
/ foo bar baz /
/foo bar baz/