noDuplicatedSpreadProps
¥Summary
-
规则生效日期:
v2.3.8¥Rule available since:
v2.3.8 -
诊断类别:
lint/nursery/noDuplicatedSpreadProps¥Diagnostic Category:
lint/nursery/noDuplicatedSpreadProps -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
此规则属于以下域:
¥This rule belongs to the following domains:
-
来源:
¥Sources:
¥How to configure
{ "linter": { "rules": { "nursery": { "noDuplicatedSpreadProps": "error" } } }}¥Description
禁止 JSX prop 多次展开相同的标识符。
¥Disallow JSX prop spreading the same identifier multiple times.
强制任何唯一表达式只能展开一次。通常,将同一个表达式展开两次表明存在错误,因为展开之间的任何属性都可能被覆盖,而这并非本意。即使情况并非如此,这也会导致执行不必要的计算。
¥Enforces that any unique expression is only spread once. Generally spreading the same expression twice is an indicator of a mistake since any attribute between the spreads may be overridden when the intent was not to. Even when that is not the case this will lead to unnecessary computations being performed.
¥Examples
¥Invalid
<div {...props} something="else" {...props} />code-block.jsx:1:1 lint/nursery/noDuplicatedSpreadProps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ The expression props has spread more than once.
> 1 │ <div {…props} something=“else” {…props} />
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Spreading an expression more than once will lead to unnecessary computations being performed. Reduce spreads of this expression down to 1.
¥Valid
<div something="else" {...props} />¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号