digitalbazaar / eslint-config-digitalbazaar

BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Define one-var rule. #51

Closed mattcollier closed 3 years ago

mattcollier commented 3 years ago

Enforces one of the basic rules here: https://github.com/digitalbazaar/bedrock/blob/master/CONTRIBUTING.md#javascript

Prefer one variable declaration per line, no elaborate indentation, and declare nearest to where variables are used. You may declare simple iterator vars for loops multiple times in the same function, functional-scope notwithstanding.

With this rule:

let foo, bar;

produces error: Split 'let' declarations into multiple statements.

https://eslint.org/docs/rules/one-var

mattcollier commented 3 years ago

I support this as long as it doesn't break destructuring like this:

const {var1, var2} = foo;
let {var3, var4} = bar;

I've confirmed that it does not impact destructured assignment..