noVoidElementsWithChildren
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/correctness/noVoidElementsWithChildren¥Diagnostic Category:
lint/correctness/noVoidElementsWithChildren -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则包含 unsafe 修复程序。
¥This rule has an unsafe fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
来源:
¥Sources:
¥How to configure
{ "linter": { "rules": { "correctness": { "noVoidElementsWithChildren": "error" } } }}¥Description
此规则防止空元素(又称自关闭元素)有子元素。
¥This rules prevents void elements (AKA self-closing elements) from having children.
¥Examples
¥Invalid
<br>invalid child</br>code-block.jsx:1:1 lint/correctness/noVoidElementsWithChildren FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ br is a void element tag and must not have children.
> 1 │ <br>invalid child</br>
│ ^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Unsafe fix: Remove the children.
1 │ <br>invalid·child</br>
│ --------------- --
<img alt="some text" children={"some child"} />code-block.jsx:1:1 lint/correctness/noVoidElementsWithChildren FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ img is a void element tag and must not have children.
> 1 │ <img alt=“some text” children={“some child”} />
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Unsafe fix: Remove the children.
1 │ <img·alt=“some·text”·children={“some·child”}·/>
│ ------------------------
React.createElement('img', {}, 'child')code-block.js:1:1 lint/correctness/noVoidElementsWithChildren FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ img is a void element tag and must not have children.
> 1 │ React.createElement(‘img’, {}, ‘child’)
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Unsafe fix: Remove the children.
1 │ React.createElement(‘img’,·{},·‘child’)
│ -------
¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号