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: support HTML/Vue/Angular #5259
Conversation
- merge logic from language-vue
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks @ikatyang! |
Thanks, @ikatyang. I am glad to be using Vue with the awesome people behind the team. |
Was waiting so long for that, thanks @ikatyang ! 💪🏻 🎉 |
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@ikatyang Sorry for bother you, but I would like to confirm this behavior before I open an issue for this. I'm formatting my teams project, and came with some awkward behavior. With With Notice that when is set to |
@michaeljota that looks like a bug to me, could you open an issue for it? |
Opened #5396 to address the sensitivity issue between interpolation and text. |
Thanks @ikatyang! |
This is awesome work! One issue I am having is when I use arrow functions for handling events in Vue.
Prettier adds a semi colon after the curly brace which throws an unexpected token error when building. |
@erisman20 Can you provide a link to Prettier playground reproducing the issue? |
@erisman20 can't you use For more complicated/longer functions, write down the method inside of the |
@kissu I don't much know about vue, but I'll guess this is about the this context. Although seems an unusual behavior, Prettier should not break the code. And I can't reproduce the issue, Prettier indeed adds a semi colon, but after the function, so it shouldn't break anything. |
@kissu That was just a basic example to showcase what was happening. Here is a Playground. I have never used that before, but the "second format" is how prettier formats my code. @michaeljota In terms of Vue, you cant have a trailing semi colon like that. It will throw an error. You can even try it in the provided playground and you can see the error |
@erisman20 I opened an issue for you: #5406 |
Why add a semicolon in the first place? That adds an extra character for no reason o.o |
@alfaproject That's configurable, the default behavior however is to add a semicolon at the end of a line. |
Can I find out why html wrap attributes are now enforced? I am using prettier for my html files inside Angular project. This happened after I updated prettier |
@gogakoreli Please open an issue filling the template |
Fixes #1882
Fixes #2097
Fixes #3767
Fixes #4095
Fixes #5098
Fixes #5263
Try out this PR:
or preview playground (hard reload to ensure it's the latest one).
Please note that syntax errors produced by child language in the playground is a known issue, it won't happen if you use it locally (i.e.,
prettier something.html
).Already supported on master:
<!-- display: block -->
)--html-whitespace-sensitivity <css|strict|ignore>
css
: respect default css style (safe in the most cases)strict
: every element is considered whitespace sensitive (the safest)ignore
: every element is considered whitespace insensitive (dangerous)<!--[if IE]><![endif]-->
)Added in this PR:
<!-- @prettier -->
)html`<div>Hello ${name}!</div>`
)<![CDATA[ content ]]>
){{jsExpression}}
):class
,v-if
,v-bind:id
,@click
)*ngIf
,[target]
,(target)
,[(target)]
)@Component({ template: `<div>Hello World</div>` })
)TODOs:
<script type="module">
(Support for script tags in .html files #3767)<script type="text/markdown">
(Markdown formatting inside html files #4095)style
content (feat: support HTML/Vue/Angular #5259 (comment))--parser <vue|angular>
*.vue
defaults tovue
parser*.component.html
defaults toangular
parser*.html
defaults tohtml
parserv-for
(feat: support HTML/Vue/Angular #5259 (comment))v-on:click
,@click
(feat: support HTML/Vue/Angular #5259 (comment))slot-scope
(feat: support HTML/Vue/Angular #5259 (comment))(target)="input"
[target]="input"
{{input}}
*directive="input"
docs/
directory)