Here is the tool and approaches that can help:
ESLint + plugin or manual rules While ESLint is mainly for linting, some plugins can help with alignment, like:
eslint-plugin-align-assignments This plugin aligns = and : in variable declarations and object literals.
Install:
npm install --save-dev eslint eslint-plugin-align-assignments
Add to your .eslintrc.js:
module.exports = {
plugins: ['align-assignments'],
rules: {
'align-assignments/align-assignments': ['error', { requiresOnly: false }],
},
};
Then run:
npx eslint --fix yourfile.js