royriojas / esformatter-jsx

esformatter plugin: format jsx files (or js files with Facebook React JSX Syntax)
MIT License
142 stars 25 forks source link

Should not insert new lines #85

Closed hiaw closed 2 years ago

hiaw commented 8 years ago

esformatter keep inserting new lines before curly bracket for JSX like this

 <Text style={ styles.index }>
        { this.props.num + 1 }.
        { item.name } -
        { item.quantity } Available 
 </Text>

when I wanted to keep it this way

     <Text style={ styles.index }>
        { this.props.num + 1 }. { item.name } - { item.quantity } Available 
     </Text>

This is my config

{
"plugins": [
  "esformatter-jsx"
],
"jsx": {
  "formatJSX": true,
  "attrsOnSameLineAsTag": false,
  "maxAttrsOnTag": 1,
  "firstAttributeOnSameLine": true,
  "formatJSXExpressions": true,
  "JSXExpressionsSingleLine": true,
  "alignWithFirstAttribute": true,
  "Spaceinjsxexpressioncontainers": "",
  "removeSpaceBeforeClosingJSX": false,
  "htmlOptions": {
    "brace_style": "collapse",
    "indent_char": " ",
    "indent_size": 2,
    "max_preserve_newlines": 2,
    "preserve_newlines": false
  }
}
}

Did I messed up my config? Help?

royriojas commented 8 years ago

hi @hiaw

No you didn't, it is somehow expected behavior. I will see if I can make that behavior optional, but lately I haven't had much time to spend on the issues.

In any case a workaround for this issue will be to use string interpolation

<Text style={ styles.index }>
   { `${ this.props.num + 1 }. ${ item.name } - ${ item.quantity } Available` }
</Text>

I will mark this as an enhacement