src/content/docs/linter/rules/no-duplicate-attributes.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="HTML" icon="seti:html"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.12` - Diagnostic Category: [`lint/nursery/noDuplicateAttributes`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`@html-eslint/no-duplicate-attrs`](https://html-eslint.org/docs/rules/no-duplicate-attrs) - Same as [`vue/no-duplicate-attributes`](https://eslint.vuejs.org/rules/no-duplicate-attributes){
"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>
<template>
<div foo :foo="bar" />
</template>
<div foo="a" bar="b"></div>