Closed millermedeiros closed 8 years ago
Hi @millermedeiros,
you're right, will see if it is possible to remove the stringBefore/stringAfter
hack.
regards
Hi @millermedeiros,
I removed the replacement of jsxElements
on stringBefore
. But this plugin added an option to not recursively format the jsxExpressions
so in order to honor that option I have instead now to replace the jsxExpressions
during stringBefore
. if the option formatJSXExpressions
is set to true (which is the default value) then you will have the desired results.
Hope this is good enough. In my tests this worked fine. It format this:
function render(count) {
return <input type='text'
onChange={ this.change('some nice') }
value={ word } />;
}
into this
function render(count) {
return <input type='text'
onChange={ this.change('some nice') }
value={ word } />;
}
using these settings
{
"jsx": {
"formatJSX": true,
"attrsOnSameLineAsTag": false,
"maxAttrsOnTag": 1,
"firstAttributeOnSameLine": true,
"spaceInJSXExpressionContainers": " ",
"alignWithFirstAttribute": true,
"formatJSXExpressions": true,
"htmlOptions": {
"brace_style": "collapse",
"indent_char": " ",
"indent_size": 2,
"max_preserve_newlines": 2,
"preserve_newlines": true
}
},
"quotes": {
"type": "single",
"avoidEscape": true
}
}
since this plugin removes the
JSXElement
from the tree (replaces it with a comment), other plugins aren't able to make changes to the JSX unless they also usestringAfter
esformatter@0.9
uses Babylon and is able to parse JSX, so maybe you don't need thestringBefore/stringAfter
hack anymore.see: https://github.com/millermedeiros/esformatter-quotes/issues/15