4

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

Spent quite some time looking for a answer to this and found this thread Is there a JSX formatter for sublime text?. But it seems to never come to a solution. Babel and ESlint does everything for me except formatting the code.

Community
  • 1
  • 1
Mathias Asberg
  • 3,562
  • 6
  • 30
  • 46
  • What do you mean by formatting ? (syntax-highlighting/autocomplete/beautify ?) – Sachin Nov 06 '16 at 08:25
  • Possible duplicate of [Is there a JSX formatter for sublime text?](http://stackoverflow.com/questions/27558699/is-there-a-jsx-formatter-for-sublime-text) – Eugene Kulabuhov Feb 10 '17 at 22:33

3 Answers3

0

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

One of the things that I was thinking it is to write the formatting code from scratch, using babylon to parse the code. Currently it uses js-beautify.

Here is an online demo in case you want to try it

roy riojas
  • 2,406
  • 1
  • 28
  • 30
0

you can try to install babel theme for sublime text, it support all es6 and jsx. you can find it here: https://github.com/babel/babel-sublime

chenkehxx
  • 1,589
  • 12
  • 15
0

You can install the babel syntax by following the below 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
Venkatesh Somu
  • 4,710
  • 4
  • 23
  • 22