Skip to content

noDuplicateAttributes

biome.json
{
"linter": {
"rules": {
"correctness": {
"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/correctness/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.

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