Lint Rules

useSingleVarDeclarator (since v0.7.0)

This rule is recommended by Rome.

Disallow multiple variable declarations in the same variable statement

Examples

Invalid

let foo, bar;
style/useSingleVarDeclarator.js:1:1 lint/style/useSingleVarDeclarator  FIXABLE  ━━━━━━━━━━━━━━━━━━━━

   Declare variables separately
  
  > 1 │ let foo, bar;
   ^^^^^^^^^^^^^
    2 │ 
  
   Suggested fix: Break out into multiple declarations
  
    1  - let·foo,·bar;
      1+ let·foo;
      2+ let·bar;
    2 3  
  

Valid

for (let i = 0, x = 1; i < arr.length; i++) {}