# attr-value-no-duplication

> Prevents duplicate values within the same attribute to ensure clean and efficient markup.

Class attributes should not contain duplicate values. Other attributes can be checked via configuration.

Level: Error

## Config value

[Section titled “Config value”](#config-value)

* `true`: enable rule with default attributes (only class)
* `['attr1', 'attr2', ...]`: specify custom list of attributes to check
* `false`: disable rule

## Default attributes checked

[Section titled “Default attributes checked”](#default-attributes-checked)

By default, this rule only checks the `class` attribute for duplicate values:

* `class` - CSS class names should not be repeated

Other attributes can be checked by providing a custom configuration.

### The following patterns are **not** considered rule violations

[Section titled “The following patterns are not considered rule violations”](#the-following-patterns-are-not-considered-rule-violations)

```html
<div class="container fluid small">Content</div>
```

```html
<!-- data-attributes not checked by default -->
<input data-attribute="apple banana apple">
```

### The following patterns are considered rule violations:

[Section titled “The following patterns are considered rule violations:”](#the-following-patterns-are-considered-rule-violations)

```html
<div class="d-none small d-none">Content</div>
```

## Why does this rule exist?

[Section titled “Why does this rule exist?”](#why-does-this-rule-exist)

Having duplicate values in class attributes can:

* Make the markup unnecessarily verbose
* Cause confusion during development
* Lead to inefficient CSS specificity calculations
* Indicate potential copy-paste errors or oversight

This rule helps maintain clean, efficient markup by catching these duplicates early.

## Custom configuration

[Section titled “Custom configuration”](#custom-configuration)

You can customize which attributes to check by providing an array:

```json
{
  "attr-value-no-duplication": ["class", "id", "name", "role"]
}
```

```json
{
  "attr-value-no-duplication": ["data-test", "aria-label", "custom-attr"]
}
```

This allows you to focus on attributes specific to your project needs.