New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[resolved] [HTML] allow corresponding option to jsxBracketSameLine #5377
Comments
I don't think this is the same as you are requesting. JSX and HTML are two different things. |
Perhaps we should name it to |
@michaeljota I agree they are different things, but in this regard they can be "collapsed" under the same option I think, as the behavior is largely the same. @j-f1's suggestion for the name (change?) emphasis it. |
I don't think I've ever seen any markup language with the closing brackets on a separate line. I'd like to see |
The reason I personally write the closing bracket on the next line is that it makes it much simpler to work out what's an attribute and what's content. <my-component
foo="bar"
moo="cow">
Now some text
It's really not clear where the text started
</my-component> compared to <my-component
foo="bar"
moo="cow"
>
Now some text
It's much clearer where the text started
</my-component> It also matches what people do in code and so we found it pretty simple to get our company to all adopt the coding style. |
@aboyton good point. But what about when you don't have content? <my-component
foo="bar"
moo="cow">
</my-component> Or is it still: <my-component
foo="bar"
moo="cow"
>
</my-component> Or something else entirely? |
<my-component
foo="bar"
moo="cow"
></my-component> Is what I do to reduce vertical space (or just put it all on one line). |
It also happens on Vue template. Closing bracket on the next line or same line is not important for this issue. Prettier provides this feature as an option for JSX but not for Angular or Vue. |
would be awesome to have that JSX option for any kind of html parser |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
my team is fine with
but hates
|
@stephen-dahl agree. The angle bracket hanging out there on its own line is never going to catch on. I've tried for the last month, but my mind still sees it as an error or a typo. IMO, js-beautify has solved the html formatting problem. Until prettier gets its stuff together, I'll be using that for my html. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Until it is fixed you can just disable prettier for
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'm not on the team, but it seems clear that they have agreed to support it, but that there has not yet been a corresponding pull request. Correct me if I'm wrong, but I think they would accept a good pull request that implements this. I spent some time on it myself, but ran into some roadblocks, then got distracted. It isn't a super-trivial feature to implement. |
This comment has been minimized.
This comment has been minimized.
@karptonite my fork achieves this with a few lines of code, however I didn't get around to fixing all the tons of unit tests that this breaks since its expecting the old formatting style. I took a stab at it recently again, but the html parser has been rewritten and would need to go down the rabbit hole again to figure out a new fix. I figure this is one of those changes that would take 10x less time for one of the regular maintainers to tackle than someone who's completely new to this codebase. Dear prettier team: can you plz take a look soon? I've been using my own fork for over 6 months now on all my projects and it works well.
Change here: adamJLev@a0cd45b |
Same, something like the following where a html tag has no attributes looks very strange to us: <p>
<strong
>some text some text some text some text some text
some text some text some text</strong
>
</p> |
@welljsjs the example you are showing is not really related to this issue. Rather, it is related to the |
Well, I've started a pull request with a first proof of concept fix for this in #9936. Anyone interested in offering feedback on this? |
I need this. I'm using wepy and the compiler will throw error if the closing tag is formatted like
|
sorry @lzl124631x prettier just doesn't care about what anyone else thinks, when you see "opinionated framework/library/formatter/whatever" what you should read is "everyone else is stupider than us, they don't deserve to have an opinion". Besides it has only been 4 years since this was opened I'm sure someones opinion will start mattering soon You also should ignore this message since I am part of the "stupider crowd" and anything I posted should just be ignored and considered as unworthy as my opinions |
As this issue seems to be requested by a lot of developers, it would be great if there could be any kind of initiative to address that. |
So ? |
What about it? I'm facing same issue in Vue. <a
href="https://marketplace.visualstudio.com/items?itemName=octref.vetur"
target="_blank"
>
Vetur
</a> Doesn't it look awful ? |
Yeah, a year went by and I'm still using my own prettier fork with the 2 line change, for all my Vue projects:
That command will install the fork as a drop in replacement under the same |
I recently became aware of this https://github.com/brodybits/prettierx Maybe you can get your change in there? |
OMG! Why maintainers don't want to implement this option? |
#5377 (comment) Feel free to send a PR |
Ok I will try to participate as well after 4 years of waiting. Please ? |
Prettier seems pretty ... dead :') |
I want to lock conversation, instead of being toxic, you can send a PR and help us, both PRs above are abandoned Resolver here: #5377 (comment), |
Note: Read this comment to make sure you’re up-to-speed on what this issue is and is not about: #5377 (comment)
For React/JSX - Prettier has an option to allow tags to close on the same line as the declaration, rather then on a new line:
jsxBracketSameLine: true
:jsxBracketSameLine: false
:With Prettier 1.15.1, at least for the Angular parser, there is no corresponding option, so all HTML is formatted like this:
Input:
Output:
Playground link
It would be nice to have a flag to set it such that the output of the above would be:
The text was updated successfully, but these errors were encountered: