Closed DiogoDoreto closed 4 years ago
/cc @saschanaz please don't repeat issues, put examples here
@evilebottnawi For me #7101 wasn't exactly this issue though, because hyperHTML automatically trim out the newlines if single-rooted and thus won't make a breaking change.
Edit: But anyway it looks similar, and 100% sorry for #7100 which is exactly same as this one 😞
What should be done here? Any formatting outside a tag is potentially breaking. I think we should introduce one of these option to:
@saschanaz I'd vote to keep it simple: if the user tries to have it as one-liner and the line is not too long, avoid adding the line breaks. Otherwise leave the default formatting behavior.
This will create an incentive to the user to simplify their content, possibly extracting it into simple variables that would be easier to read.
It then will behave in a similar way as this example:
// the line below is left as-is
const obj = [{ test: true }];
// the code below will be reformatted with line breaks
// input:
const obj = [{
test: true }];
// output:
const obj = [
{
test: true
}
];
What do you think?
That doesn't even need an option then! Sounds good to me 👍
@evilebottnawi Do prettier maintainers think https://github.com/prettier/prettier/issues/7096#issuecomment-564444006 is good? Is it possible to implement that?
I would really like to see this as well.
@saschanaz it is out of scope this bug, we should not add extra space in this case, so PR welcome should be not hard
Fixed #7208
Prettier 1.19.1 Playground link
Input:
Output:
Expected behavior:
Adding whitespace inside the tagged template literal affects the output. To avoid the spaces around my components, the only way right now is to add ignore comments.