ES6 ES2015 (Babel) Format / Beautfier for Sublime for .jsx.js

I want to be able to format my code in Sublime when running Reactjs using ES2015.

It took quite a while to find the answer to this question and found this thread. Is there a JSX formatter for sublime text? . But it seems he never comes to a decision. Babel and ESlint do everything for me except code formatting.

+4
source share
3 answers

Have you tried sublime-jsfmt ? adding the esformatter-jsx plugin can help format the code. (disclaimer: I did this), he has some errors for some corner cases that need to be fixed, but for the most common cases you can get good results.

One of the things that I was thinking about is to write formatting code from scratch, using babylon to parse the code. He is currently using js-beautify.

Here is an online demo if you want to try it.

0
source
0

You can set babel syntax by following these steps.

    1.go to this url  https://packagecontrol.io/installation copy the code of sublime text 3 or sublime text 2 from the url

    2.open sublime text editor and go to menu options of View and select the "show console" 

    3.then paste the code from the above url and press enter.It will install the package manager.

    4.press ctrl+shift+p and type install in the input box. A list of options will come,then select the Install package option.It will install.

    5.After installing the above press again ctrl+shift+p and type the "babel" and select babel in the list.It will install the babel syntax

    6.to change the syntax of the page select the view menu and choose syntax/babel
0
source

All Articles