Skip to content

singleVariableDeclarations

Enforces one variable per declaration statement.

✅ This rule is included in the ts logical presets.

Declaring multiple variables in a single statement can reduce readability. Each variable declaration should be on its own line to make the code easier to read and maintain.

let first, second, third;
const width = 100,
height = 200;
for (let index = 0, length = 10; index < length; index++) {
console.log(index);
}

This rule is not configurable.

If you prefer to declare multiple variables in a single statement for brevity, you might choose to disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.