2

I get this error when I run prettier.

..\index.component.html
[error] ..\index.component.html: SyntaxError: Only void and foreign elements can be self closed "home-hero" (3:5)
[error]   1 |
[error]   2 |   <layout>
[error] > 3 |     <home-hero slot="hero" />
[error]     |     ^
[error]   4 |
[error]   5 |     <h3 slot="callout" />
[error]   6 |

But I want to use self close tag. How set prettier to ignore this error?

In prettier schema I don't see any reference of "self" or something like this.

Shlomi Levi
  • 2,050
  • 15
  • 25

1 Answers1

0

This is actually a feature with HTML standard as mentioned in the below thread -

Are (non-void) self-closing tags valid in HTML5?

All the modern libraries like angular use the HTML5 standard for template in which case the user defined templates will be treated as non-void and hence you have to close the tag with proper ending tag.

Here is the complete list of HTML tag description related to void and non-void

https://developer.mozilla.org/en-US/docs/Web/HTML/Element

You can also check the spec related to tech home-hero is written whether they allow the self closing tags!

MBB
  • 1,168
  • 2
  • 6
  • 17