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
feat: add new option html-top-level-indent
#6077
Conversation
I like it! 👍 Considering the last couple of comments in #3888 I'm also open to only doing |
@lydell Should I update the website code as well? (Not sure how to do it and may need some help.) Actually, one of my concern is whether we should apply this to all embedded language block inside HTML, or just to the top-level. The current implementation will possibly produce the following markup (with <script>
let foo
</script>
<body>
<script>
let bar
</script>
</body> |
I'd say we should apply it to all levels: <script>
let foo
</script>
<body>
<script>
let bar
</script>
</body> But this feels like another argument to making the option specific to Vue SFCs.
Do you mean the playground? I haven't touch it since the React rewrite, so I'm a bit unsure myself. |
To me indenting template but not script and style (in vue) by default seems like an inconsistency, should at least not be the default |
@ForsakenHarmony Changing the default behavior will be a breaking change. |
I know, but maybe it should be |
f7cf274
to
c282dc7
Compare
I'm not sure I like the name for |
|
Is there any word on when this will go in? |
The code of this PR looks really good! I tried it out locally and realized something. The reason I thought #5574 (review) sounded like a good idea was because it sounded like there would be nothing Vue-specific about the option. But there is.
Notice the indentation of Now I'm a little confused. What is it that users want really? It makes sense from a logical point of view not to indent So maybe a Sorry for all the back and forth! I really wanted to press the "Approve" button on this PR this morning, but now I'm not sure. Prettier's goal is a low amount of options. When we add a new one we must make sure that it is really making people happier. And I'm not sure that |
My understanding is the auto value will keep the indentation as it currently is with the HTML and vue formatters (the indenting |
No worries. What I had in my mind when making this PR is:
But as you say, there's not yet huge demand for
I see #5377 has a lot of upvotes, and I think it doesn't make much sense that we only allow it in JSX but not HTML (I'd say people waiting for that feature can't be very happy about it). So in this case I agree with your earliest opinion (#3888 (comment)) to make it work beyond Vue templates.
If you are dropping the current behavior, I'd say it will be very likely that some users will get unhappy, whether you have |
If not making this very specific thing which most people don't like according to the polls a breaking change is important, the default value should have some kind of special name |
@ForsakenHarmony |
🤔 |
@Justineo thing is it currently is Vue specific? |
@ForsakenHarmony Yes. |
Any plans to merge these changes in next version? |
I think the conclusion from what we’ve learned from this PR is that the |
I vote |
As mentiond earlier, this PR aims to:
Unfortunately, it's not ideal in the end. Let's wait for a |
@Justineo Thank you for your hard work on this PR! I’m really sorry it did not end up merged, but sometimes a PR of exploration is what it takes to find the best solution to a problem. 🙇♂️ |
To be clear, I don't think But I respect your choice. |
I like this, but I just don't like |
* feat: implement --vue-indent-script-and-style mentioned at pr-#6077 * docs: --vue-indent-script-and-style * update new test case * feat: playground for --vue-indent-script-and-style * chores: Revert package.json version * Remove noisy snapshots
…ttier#6157) * feat: implement --vue-indent-script-and-style mentioned at pr-prettier#6077 * docs: --vue-indent-script-and-style * update new test case * feat: playground for --vue-indent-script-and-style * chores: Revert package.json version * Remove noisy snapshots
Added a new option:
html-top-level-indent
, which is described in #3888 (comment).The new option has the following possible values:
"always"
- Always apply top-level indent for templates, scripts and styles."never"
- Avoid top-level indent for templates, scripts and styles."auto"
- Avoid top-level indent for scripts and styles inside Vue files.docs/
directory)CHANGELOG.unreleased.md
file following the template.✨Try the playground for this PR✨