13

I searched for a package to auto-indent and beautify my React/babel code. I just tried atom-beautify which seems to have good feeback on Atom.

But the result on an usual babel file is not good enough: "HTML tag" doesn't indent as wanted. Has anyone tried to use atom-beautify with babel?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Damien Leroux
  • 11,177
  • 7
  • 43
  • 57

5 Answers5

12

I currently use the plugins language-babel, react, and autoclose-html to handle this for me with no issues.

https://atom.io/packages/autoclose-html

https://atom.io/packages/language-babel

https://atom.io/packages/react

Hope this helps!

David Meents
  • 621
  • 4
  • 12
  • 1
    I tried language-babel but, correct me if I'm wrong, it auto-indents only jsx not local javascript in function & co. – Damien Leroux May 15 '16 at 19:11
  • I'm afraid I can't be certain on that. I just went in and played around with settings and it seems to have the options that you're looking for, and I've had no issues, all my javascript and react code is properly indented automatically. Sorry if this wasn't more help. – David Meents May 15 '16 at 19:22
  • 4
    `react` and `language-babel` seem to be colliding with each other - I get a warning message about this. – Karolis.sh Nov 25 '16 at 07:49
  • I had this collision problem too. I'm using only `react` for now and it seems to help a lot – tkcast May 03 '17 at 22:41
  • Same problem here, react and language-babel doesn´t work together. I used language-babel so far. – NEOline May 24 '17 at 12:23
5

Atom beautify did not support jsx at that time. it does now :)

Damien Leroux
  • 11,177
  • 7
  • 43
  • 57
4

I already faced the same problem and ended using prettier-atom . It works really nice with HTML tags.

Jalal
  • 3,308
  • 4
  • 35
  • 43
3

I use Prettier (https://prettier.io/) to re-write my code into best practices, so all the team can write code as if only one person has written it all. Supports JSX, and recently, even TypeScript, CSS, SCSS, ..

elQueFaltaba
  • 618
  • 1
  • 9
  • 17
1

I use miniprettier, it's listed on Prettier official site as a recommended package.

It's like prettier-atom but without all the dependencies. I love it! It works very well on JSX. I use atom-beautify for other filetypes (e.g. JSON, pure HTML, JS).

hoohoo-b
  • 1,141
  • 11
  • 12