跳转到内容

noDuplicateAttributes

此内容尚不支持你的语言。

biome.json
{
"linter": {
"rules": {
"nursery": {
"noDuplicateAttributes": "error"
}
}
}
}

Disallow duplication of attributes.

According to the HTML specification, each attribute name must be unique within a single element. Duplicate attributes are invalid and can lead to unexpected behavior in browsers.

For Vue templates (.vue files), this rule also considers the following directives as aliases of their arguments:

  • v-bind:foo and :foo are handled as the attribute foo.

Vue class/style bindings are ignored. For example, class and :class may co-exist.

Event handlers are ignored. For example, @click and v-on:click are not considered attributes by this rule.

Dynamic arguments such as :[foo] or v-bind:[foo] are ignored.

<div foo="a" foo="b"></div>
code-block.html:1:14 lint/nursery/noDuplicateAttributes ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Duplicate attribute ‘foo’.

> 1 │ <div foo=“a” foo=“b”></div>
^^^^^^^
2 │

This is the first occurrence of the attribute.

> 1 │ <div foo=“a” foo=“b”></div>
^^^
2 │

Each attribute name must be unique within a single element. Duplicate attributes are invalid and can lead to unexpected browser behavior.

Consider removing or renaming the duplicate ‘foo’ attribute.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<template>
<div foo :foo="bar" />
</template>
<div foo="a" bar="b"></div>