Skip to content

noDuplicatedSpreadProps

¥Summary

¥How to configure

biome.json
{
"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