useSelfClosingElements
诊断类别:lint/style/useSelfClosingElements
¥Diagnostic Category: lint/style/useSelfClosingElements
自从:v1.0.0
¥Since: v1.0.0
来源:
¥Sources:
-
与以下相同:
@stylistic/jsx-self-closing-comp
¥Same as:
@stylistic/jsx-self-closing-comp
防止没有子组件的组件有额外的结束标签
¥Prevent extra closing tags for components without children
¥Examples
¥Invalid
code-block.jsx:1:1 lint/style/useSelfClosingElements FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
> 1 │ <div></div>
│ ^^^^^^^^^^^
2 │
ℹ Unsafe fix: Use a SelfClosingElement instead
1 │ - <div></div>
1 │ + <div·/>
2 2 │
code-block.jsx:1:1 lint/style/useSelfClosingElements FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
> 1 │ <Component></Component>
│ ^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Unsafe fix: Use a SelfClosingElement instead
1 │ - <Component></Component>
1 │ + <Component·/>
2 2 │
code-block.jsx:1:1 lint/style/useSelfClosingElements FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
> 1 │ <Foo.bar></Foo.bar>
│ ^^^^^^^^^^^^^^^^^^^
2 │
ℹ Unsafe fix: Use a SelfClosingElement instead
1 │ - <Foo.bar></Foo.bar>
1 │ + <Foo.bar·/>
2 2 │
¥Valid
¥Related links