Example of unstable JSX + parentheses
See original GitHub issuefunction MyCompoent() {
return (
<div>
(<FormattedMessage
id="some-id"
defaultMessage="some looooooooog default"
/>)
</div>
);
}
turns into:
function MyCompoent() {
return (
<div>
(
<FormattedMessage
id="some-id"
defaultMessage="some looooooooog default"
/>
)
</div>
);
}
https://jlongster.github.io/prettier/#{"content"%3A"function MyCompoent() {\n return (\n <div>\n (<FormattedMessage\n id%3D\"some-id\"\n defaultMessage%3D\"some looooooooog default\"\n %2F>)\n <%2Fdiv>\n )%3B%5Cn%7D%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22jsxBracketSameLine%22%3Afalse%2C%22doc%22%3Afalse%7D%7D
which turns into:
function MyCompoent() {
return (
<div>
(
<FormattedMessage
id="some-id"
defaultMessage="some looooooooog default"
/>
)
</div>
);
}
https://jlongster.github.io/prettier/#{"content"%3A"function MyCompoent() {\n return (\n <div>\n (\n <FormattedMessage\n id%3D\"some-id\"\n defaultMessage%3D\"some looooooooog default\"\n %2F>\n )\n <%2Fdiv>\n )%3B%5Cn%7D%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22jsxBracketSameLine%22%3Afalse%2C%22doc%22%3Afalse%7D%7D
It becomes stable after adding two newlines:
function MyCompoent() {
return (
<div>
(
<FormattedMessage
id="some-id"
defaultMessage="some looooooooog default"
/>
)
</div>
);
}
https://jlongster.github.io/prettier/#{"content"%3A"function MyCompoent() {\n return (\n <div>\n (\n\n\n <FormattedMessage\n id%3D\"some-id\"\n defaultMessage%3D\"some looooooooog default\"\n %2F>\n )\n <%2Fdiv>\n )%3B%5Cn%7D%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22jsxBracketSameLine%22%3Afalse%2C%22doc%22%3Afalse%7D%7D
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
The fact that it breaks is expected and I don’t think that we should put a hack for it. However the new line is not.
Ah, no, that was silly of me. Of course it will break there. A bit unfortunate but very unlikely to be fixable without an ugly hack.
The insertion of an extra newline is a problem, I have some ideas about what might be causing that.