Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

eslint

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?

like image 404
arminfro Avatar asked Nov 17 '22 04:11

arminfro


1 Answers

Check out https://www.npmjs.com/package/eslint-plugin-align-assignments. It works well.

Unfortunately it seems to conflict with no-multi-spaces because of the spaces in front of the variable name.

let   a1 = 2;    // (no-multi-spaces) Multiple spaces found before 'a1'.
const a  = a1;
const b  = a;
like image 68
Niki Avatar answered Nov 20 '22 01:11

Niki