eslint / eslint/css

New Rule: `no-duplicate-properties`

Open
#494 4 comments 0 reactions 1 assignee Claimed by @przemyslaw-zan View on GitHub
feature
Dominant language
JavaScript
Stars
308
Forks
44
Avg merge
2d 6h
Merged PRs (30d)
18

Description

### Rule details

Disallow duplicate properties within declaration blocks.

### What type of rule is this?

Warns about a potential problem

### Example code

```css
a {
/* Duplicate native property */
color: pink;
color: orange;

/* Duplicate custom property */
--custom-property: pink;
--custom-property: orange;

/* Not flagged with the option `allowFallbacks` */
height: 100vh;
height: 100dvh;
}
```

### Prior Art

- [declaration-block-no-duplicate-properties](https://stylelint.io/user-guide/rules/declaration-block-no-duplicate-properties/)
- [declaration-block-no-duplicate-custom-properties](https://stylelint.io/user-guide/rules/declaration-block-no-duplicate-custom-properties/)

### Participation

- [x] I am willing to submit a pull request to implement this rule.

### AI acknowledgment

- [x] I did not use AI to generate this issue report.
- [ ] (If the above is not checked) I have reviewed the AI-generated content before submitting.

### Additional comments

- This proposal would mean merging two original `stylelint` rules into one, as they are nearly identical.
- Property comparison is case-insensitive for native properties but case-sensitive for custom ones - matching CSS spec.
- Equivalent of `consecutive-duplicates-with-different-syntaxes` option from the [declaration-block-no-duplicate-properties](https://stylelint.io/user-guide/rules/declaration-block-no-duplicate-properties/) rule should also be included: `allowFallbacks`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.