-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Make "jsx-bracket-same-line" More Generalised? #5593
Comments
Hi @marbuser If we were to respect the option, you might expect to print that as: <a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">
awesome-vue
</a> Unfortunately, unlike JSX, that line break between So we print it like this to preserve |
Hey duailibe, Thanks for the quick reply. Is it possible to perhaps disable this bracket functionality in Prettier then and combine this with another option then like eslint to solve this? If not, then is the option really to just stick with it? Because from what I tested in the playground going through all the options, there doesn't really seem to be a way to disable it. On all html options it will put the brackets on new line. :/ Thanks! :) |
The ignore will just make it possible to insert a new line before/after tags: Prettier 1.15.3 --html-whitespace-sensitivity ignore
--parser html Input: <a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a> Output: <a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">
awesome-vue
</a> But it won't change cases where we have to break "inside" the tag. For example, we will print: <a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
target="_blank"
rel="noopener"
> instead of: <a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
target="_blank"
rel="noopener"> Is that what you want? There's no way do that currently |
Hey duailibe, Yeah this is the sort of output I was hoping for;
No matter though. If it can't be done, it can't be done I guess. Are there any current plans/discussions about perhaps figuring out a way to implement something this way? Thanks |
I don't think this was requested before (but I could be wrong), so there's currently no discussion for this feature. cc @ikatyang |
This looks like a duplicate of #5377, let's track the issue there. Note that it's only possible to put |
Tried to report the issue using the playground but GitHub wasn't having it so going to write this manually. Apologies if the format isn't correct. I will try to make it as neat as possible.
Currently the option 'jsx-bracket-same-line' is obviously only working with JSX. With the recent implementation of HTML, Vue, and Angular support, I think this rule should be reworked (or a variant/option added to it) that generalises it's use-case.
For example, I'm a VueJS user and when using Prettier to format my HTML, I don't get an option to decide whether I want the
<
>
brackets on the same line or not. I get that the whole point of Prettier is to be 'opinionated', but if people who use JSX (AKA React) already have this option, then I think adding some option/rule to accomodate the new formatting support for HTML, Vue, and Angular won't make Prettier any more/less 'opinionated' than it currently is.Example:
Default VueJS CLI HelloWorld Component:
Output with Prettier:
What I'm referring to:
Hopefully this can be addressed. No clue if this is a bug or if this was intended when the support for Vue and others was added, but some discussion would be appreciated. :)
The text was updated successfully, but these errors were encountered: