useFragmentSyntax
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/style/useFragmentSyntax¥Diagnostic Category:
lint/style/useFragmentSyntax -
此规则包含 unsafe 修复程序。
¥This rule has an unsafe fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
来源:
¥Sources:
-
与
react/jsx-fragments相同¥Same as
react/jsx-fragments
-
¥How to configure
{ "linter": { "rules": { "style": { "useFragmentSyntax": "error" } } }}¥Description
此规则强制使用 <>...</> 而不是 <Fragment>...</Fragment>。
¥This rule enforces the use of <>...</> over <Fragment>...</Fragment>.
简写片段语法可节省按键次数,并且仅在需要按键时不适用。
¥The shorthand fragment syntax saves keystrokes and is only inapplicable when keys are required.
¥Examples
¥Invalid
<Fragment>child</Fragment>code-block.jsx:1:1 lint/style/useFragmentSyntax FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Use shorthand syntax for Fragment elements instead of standard syntax.
> 1 │ <Fragment>child</Fragment>
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Shorthand fragment syntax saves keystrokes and is only inapplicable when keys are required.
ℹ Unsafe fix: Replace <Fragment> with the fragment syntax
1 │ <Fragment>child</Fragment>
│ -------- --------
<React.Fragment>child</React.Fragment>code-block.jsx:1:1 lint/style/useFragmentSyntax FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Use shorthand syntax for Fragment elements instead of standard syntax.
> 1 │ <React.Fragment>child</React.Fragment>
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Shorthand fragment syntax saves keystrokes and is only inapplicable when keys are required.
ℹ Unsafe fix: Replace <Fragment> with the fragment syntax
1 │ <React.Fragment>child</React.Fragment>
│ -------------- --------------
¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号