-
-
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
Feature request: Ability to disable XML/HTML/vue template formatting. #5661
Comments
Hi! Why don't you want to format the template parts of Vue? I assume that something didn't look good to you? Wouldn't you be more interested in fixing those bad cases instead? |
Hi! Yes, I hope we can fix/improve the "bad" cases, or cases our team feel most friction towards. (attributes) Then there are some cases that our team will accept and implement in due process. (indenting) And we have a need to keep up with fixes to the core (meaning js and less as per 1.14, prior to Vue formatting). (bug) We do need a way to be able to control changes within our product, it is not acceptable for us to flip back and forth and so would prefer to wait until things are stabilised (w.r.t. Vue formatting). I would have suggested more targeted end user options, but I know that being opinionated means that options are not highly desirable or accepted (from a Prettier perspective). This single option seemed as though it would be the most acceptable (prettier) and least disturbing (end usage). I'm open to other ideas as to how we can accomplish things. |
This is the reason I'm still using @vue/cli-service 3.3.1 |
I just made a demo plugin to make prettier only process the |
@meteorlxy You rule! 🚀🔥 |
Great effort there @meteorlxy but that's more change than is desired in our projects. If I understand the code correctly, what I am asking for is an option to do the equivalent of commenting out src/language-html/utils.js // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block
// custom blocks can be written in other languages so we should preserve them to not break the code
if (
options.parser === "vue" &&
node.type === "element" &&
node.parent.type === "root" &&
[
// "template",
"style",
"script",
// vue parser can be used for vue dom template as well, so we should still format top-level <html>
"html"
].indexOf(node.fullName) === -1
) {
return true;
} |
@lydell Here is a case that prettier shouldn't format the html part of Vue. The issue: new line can cause a different/broken style ! The css: white-space: pre-wrap; If I use prettier to change some old code, such bug happens. |
@towry I think you’re looking for the HTML Whitespace Sensitivity option. |
@lydell You are right! Thanks. |
I have been really stressing over prettier and vue. It has taken me hours and hours to try and fix this issue. It was not easy until I found Jon Gallant's method here |
Another vote to have the option for Prettier to ignore Vue |
We have been very happy with Prettier and have accepted the formatting of our Javascript and Less, with a little friction at first. We are using 1.14.3. As of 1.15 and the introduction of the Vue formatting, we have been unable to keep up with the current releases of Prettier due to white space changes and attribute formatting, to mention a couple. We would like to continue with Prettier, and keep up to date with the releases that bring fixes. So I would like to make a request to have an option to disable just the newest template formatting (we would prefer not to add ignore comments in hundreds of production files), so we could continue with the results we have achieved with 1.14. Hopefully we can accept some of the changes (indenting) and implement them, and for others I hope that a solution will become available to allow us to follow the recommendations of the Vue styling guide (e.g. component attributes). Thank you for your time and consideration.
The text was updated successfully, but these errors were encountered: