mihai-vlc / sublime-jsfmt

jsfmt plugin for Sublime Text
MIT License
477 stars 21 forks source link

How to configure the jsfmt to the line break I want? #35

Closed iplus26 closed 8 years ago

iplus26 commented 8 years ago

I'm working with React Native these days, so instead of

var {Text, ListView, View, Image, StyleSheet, TouchableHighlight, } = React;

I want

var {Text, 
    ListView,
    View,
    //...
    TouchableHighlight } = React;

I've walked through the esformatter preset files but I can't understand it well... So any help will be appreciated.

mihai-vlc commented 8 years ago

Something like this should do the trick for your particular line of code.

{
    "options":
    {
        "lineBreak" : {
            "after": {
                "ObjectPatternComma": 1
            }
        }
}

You can read more about your configuration here: https://github.com/millermedeiros/esformatter/blob/master/doc/config.md

The ast parser is very helpful in situations like this.

iplus26 commented 8 years ago

Yes, it works! Thank you!

I also installed esformatter-var-each to make the new configuration work.