jsx-void-dom-elements-no-children
NOTE: this rule is included the following rule sets:
recommended
react
jsx
fresh
Enable full set in
deno.json
:{ "lint": { "rules": { "tags": ["recommended"] // ...or "react", "jsx", "fresh" } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended # or ... deno lint --rules-tags=react # or ... deno lint --rules-tags=jsx # or ... deno lint --rules-tags=fresh
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include
or exclude
array in deno.json
:{ "lint": { "rules": { "include": ["jsx-void-dom-elements-no-children"], "exclude": ["jsx-void-dom-elements-no-children"] } } }
确保 HTML 中的空元素没有任何子元素,因为这不是有效的 HTML。有关更多信息,请参阅
空元素
文章在 MDN。
无效:
<br>foo</br>
<img src="a.jpg">foo</img>
有效:
<br />
<img src="a.jpg" />