Skip to main content

useSingleVarDeclarator

Disallow multiple variable declarations in the same variable statement

Examples

Invalid

let foo, bar;
warning[useSingleVarDeclarator]: Declare variables separately
   useSingleVarDeclarator.js:1:1
  
1  let foo, bar;
   -------------

Safe fix: Break out into multiple declarations
    | @@ -1 +1 @@
0   | - let foo, bar;
  0 | + let foo;let bar;

Valid

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