Skip to content

feat: add vue/no-duplicate-class-names rule - #2934

Merged
FloEdelmann merged 26 commits into
vuejs:masterfrom
Yizack:master
Oct 17, 2025
Merged

FloEdelmann merged 26 commits into
vuejs:masterfrom
Yizack:master

Conversation

@Yizack

@Yizack Yizack commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

resolves #2932

@changeset-bot

changeset-bot Bot commented Sep 9, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d98ca00

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-vue Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Yizack

Yizack commented Sep 10, 2025

Copy link
Copy Markdown
Contributor Author

I believe this rule is now ready!

@FloEdelmann FloEdelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Sorry that reviewing took so long. I only have a few small suggestions/requests; in general the code looks really good! 🙂

Comment thread docs/rules/no-duplicate-class-names.md Resolved
Comment thread lib/rules/no-duplicate-class-names.js Resolved
@Yizack

Yizack commented Oct 15, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for your contribution! Sorry that reviewing took so long. I only have a few small suggestions/requests; in general the code looks really good! 🙂

Hi! No problem, thanks for the review 🙂, I just applied your suggestions and requests

@Yizack
Yizack requested a review from FloEdelmann October 15, 2025 15:06
Comment thread lib/rules/no-duplicate-class-names.js Resolved

@FloEdelmann FloEdelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 🙂
Thank you! 🥳

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new ESLint rule vue/no-duplicate-class-names that detects and automatically fixes duplicate class names in Vue template class attributes and directives.

Key changes:

  • Implements comprehensive duplicate class detection across static attributes, dynamic bindings, arrays, objects, conditionals, and binary expressions
  • Provides automatic fixing that preserves original spacing when removing duplicates
  • Detects duplicates both within single attributes and across static/dynamic class attributes

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/rules/no-duplicate-class-names.js Core rule implementation with duplicate detection logic and auto-fix functionality
tests/lib/rules/no-duplicate-class-names.js Comprehensive test suite covering valid/invalid cases and various class binding patterns
lib/index.js Registers the new rule in the plugin's rule index
docs/rules/no-duplicate-class-names.md User-facing documentation with examples and usage guidance
docs/rules/index.md Updates rule listing to include the new rule
.changeset/ten-lines-fail.md Changelog entry for the new feature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@waynzh waynzh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me, except there might be one case that needs additional handling.

Comment thread lib/rules/no-duplicate-class-names.js Resolved

@waynzh waynzh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@FloEdelmann FloEdelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again!

@FloEdelmann
FloEdelmann merged commit a353a33 into vuejs:master Oct 17, 2025
15 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rule proposal: vue/no-duplicate-class-names

4 participants