Is there an ESLint rule to align `=` on assignments

Viewed 1117

I'm looking for a rule which aligns all = on assignments.

Something like this would be positive:

var foo       = 12;
var barfoo    = 21;
var barfoobar = 22;

Something like this would be negative:

var foo = 12;
var barfoobar = 21;

Rubocop has a rule called ForceEqualSignAlignment for exactly this. I wonder if there is something like that for ESLint?

2 Answers

Although there's no such rule in ESlint, there's a workaround to allow manual alignment in JS:

/*eslint no-multi-spaces: ["error", { exceptions: { "VariableDeclarator": true } }]*/

var someVar      = 'foo';
var someOtherVar = 'barBaz';
Related