Ilja
Ilja

Reputation: 46509

Beautify js code in atom editor on save according to eslint configuration

I am using Atom as my code editor of choice and am finding it hard to implement functionality to beautify code. I am relying quite heavily on eslint package and just got beautify to clean up my code on save. issue is that once code is beautified it results in some minor eslint errors and I am looking for a way to either set up beautify plugin in a way that respects eslint rules or use something else that does the job.

Upvotes: 14

Views: 4390

Answers (2)

Nitin Jadhav
Nitin Jadhav

Reputation: 7316

You may want to use an Atom plugin called Prettier Eslint that formats code according to eslint config file (.eslintrc). It uses eslint's --fix flag to fix issues.

Edit: Looks like its Prettier-atom now. Thanks, @dube.

Upvotes: 7

Brett DeWoody
Brett DeWoody

Reputation: 62851

It sounds like your beautify settings aren't matched up with your eslint rules. For example, the eslint indent rule might be set to 4 while beautify indent is set to 2.

The beautify plugin has some settings to customize how it beautifies your code. You can read about those settings in the docs. Unfortunately there's only 17 settings so it might not be possible to sync the 2 packages.

If you find you need more control over the auto-formatting in Atom you might want to check out the ESFormatter package. It has more than 250 options, which might suit your needs better if you have some non-standard ESLint rules.

Upvotes: 5

Related Questions