Skip to content

Conversation

@michaelfaith
Copy link
Contributor

This change adds a new rule to require that any test cases that have names defined, have unique names within each valid and invalid group. This helps ensure that test logs are unambiguous.

Closes #554

This change adds a new rule to require that any test cases that have names defined, have unique names within each `valid` and `invalid` group.  This helps ensure that test logs are unambiguous.
@michaelfaith michaelfaith marked this pull request as ready for review October 25, 2025 01:56
Copy link

Copilot AI left a comment

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 unique-test-case-names that enforces unique test case names within valid and invalid test groups. This helps ensure test logs are unambiguous by preventing duplicate names that could make it difficult to identify failing tests.

Key Changes:

  • Implements the unique-test-case-names rule that validates test case name uniqueness within each test group
  • Adds comprehensive test coverage for the new rule, including edge cases like shorthand strings and unnamed test cases
  • Integrates the rule into the plugin's rule registry and documentation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/rules/unique-test-case-names.ts Implements the core rule logic that tracks seen names and reports duplicates
tests/lib/rules/unique-test-case-names.ts Provides test coverage for valid and invalid test case name scenarios
lib/index.ts Registers the new rule in the plugin's rule collection
docs/rules/unique-test-case-names.md Documents the rule's purpose, examples, and usage guidelines
README.md Adds the rule to the plugin's rule listing table

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

) {
const name = property.value.value;
if (namesSeen.has(name)) {
violatingNodes.push(property.value);
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

Only duplicate occurrences are tracked, but the first occurrence of a duplicate name is not reported. When a duplicate is found, both the original and duplicate nodes should be reported. Consider tracking nodes associated with each name to report all duplicates, including the first occurrence.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was intentional. I was treating the first occurrence as ok, but report every duplicate after. But maybe all should be reported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have a pattern for that kind of thing in other rules?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@aladdin-add aladdin-add merged commit 292a371 into eslint-community:main Oct 25, 2025
23 checks passed
@michaelfaith michaelfaith deleted the feat/unique-test-case-names branch October 25, 2025 18:50
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.

New Rule: unique-test-case-names

2 participants