noSuspiciousSemicolonInJsx
¥Summary
-
规则生效日期:
v1.6.0¥Rule available since:
v1.6.0 -
诊断类别:
lint/suspicious/noSuspiciousSemicolonInJsx¥Diagnostic Category:
lint/suspicious/noSuspiciousSemicolonInJsx -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 warning。
¥The default severity of this rule is warning.
¥How to configure
{ "linter": { "rules": { "suspicious": { "noSuspiciousSemicolonInJsx": "error" } } }}¥Description
它检测 JSX 元素内可能的 “wrong” 分号。
¥It detects possible “wrong” semicolons inside JSX elements.
在自闭合元素或闭合元素后出现的分号通常是由于重构出错而导致的拼写错误。
¥Semicolons that appear after a self-closing element or a closing element are usually the result of a typo of a refactor gone wrong.
¥Examples
¥Invalid
const Component = () => { return ( <div> <div />; </div> );}code-block.jsx:4:14 lint/suspicious/noSuspiciousSemicolonInJsx ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ There is a suspicious semicolon in the JSX element.
2 │ return (
3 │ <div>
> 4 │ <div />;
│ ^
> 5 │ </div>
│
6 │ );
7 │ }
ℹ This is usually the result of a typo or some refactor gone wrong.
ℹ Remove the semicolon, or move it inside a JSX element.
¥Valid
const Component = () => { return ( <div> <div /> ; </div> );}const Component2 = () => { return ( <div> <span>;</span> </div> );}¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号