Skip to content
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

prettier can format vue, but I can not use it for Vue templates #1076

Closed
3 tasks done
qiulang opened this issue Feb 1, 2019 · 2 comments
Closed
3 tasks done

prettier can format vue, but I can not use it for Vue templates #1076

qiulang opened this issue Feb 1, 2019 · 2 comments

Comments

@qiulang
Copy link

qiulang commented Feb 1, 2019

Problem

We just want to use prettier to format our vue codes because we use prettier extensively for all our codes and we don't want to introduce another format tool.

But vetur uses prettyHtml for Vue templates and I can't change it to vue, .i.e I can not set "vetur.format.defaultFormatter.html": "prettier",

So now when I save vue codes, vscode will format my code using prettyHtml, then our lint process will use prettier to format codes again. The result is quite different.

@qiulang
Copy link
Author

qiulang commented Feb 1, 2019

I tried prettier, prettyhtml and vscode save on format and got 3 different results!
For example, I run prettyhtml src/App.vue, even though prettyhtml uses my prettier setting, it indent all 3 sections <style> <template> <script>, while prettier just indent <template> section.

vetur format <template> section using prettyhtml (e.g. tabWidth 2 by default), format <style> and <script> sections using prettier. So it is different than the other two.

This just makes my format impossible.

Currently I come up with a temporary solution that run prettier --write "src/**/*.{js,vue}" first to format all my files. Then set "vetur.format.defaultFormatter.html": "none" to prevent vscode from formatting my vue codes (template section) again and in the future.

@octref
Copy link
Member

octref commented Feb 6, 2019

You can follow #950 for using prettier in template.

@octref octref closed this as completed Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants