Skip to content

Conversation

@michaelfaith
Copy link
Contributor

This change adds a new rule to require name be present in test cases under certain conditions. This rule aims to ensure test suites are producing logs in a form that make it easy to identify failing test, when they happen. For thoroughly tested rules, it's not uncommon to have the same code across multiple test cases, with only options or settings differing between them. Requiring these test cases to have a name helps ensure the test output is meaningful and distinct.

Closes #544

This change adds a new rule to require `name` be present in test cases under certain conditions.  This rule aims to ensure test suites are producing logs in a form that make it easy to identify failing test, when they happen.
For thoroughly tested rules, it's not uncommon to have the same `code` across multiple test cases, with only `options` or `settings` differing between them.
Requiring these test cases to have a `name` helps ensure the test output is meaningful and distinct.
@michaelfaith
Copy link
Contributor Author

michaelfaith commented Oct 21, 2025

Rule's already working. 😆
image

Would you rather i address these in the same change, or as a separate change?

@michaelfaith michaelfaith marked this pull request as ready for review October 21, 2025 23:05
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 introduces a new ESLint rule test-case-name-property that requires test cases to include a name property under configurable conditions. The rule helps ensure test output is meaningful and distinct, particularly when multiple test cases share the same code but differ in options or settings.

Key changes:

  • Adds rule implementation with three configuration modes: always, objects, and objects-with-config (default)
  • Includes comprehensive test coverage for all configuration modes
  • Updates plugin exports and documentation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/rules/test-case-name-property.ts Implements the core rule logic with three violation filters and message types
tests/lib/rules/test-case-name-property.ts Provides extensive test coverage for all rule configuration modes
lib/index.ts Registers the new rule in the plugin's rule collection
docs/rules/test-case-name-property.md Documents rule purpose, options, and usage examples
README.md Adds rule to the plugin's rule listing table

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

@aladdin-add
Copy link
Contributor

Would you rather i address these in the same change, or as a separate change?

I prefer in this PR, but both are fine for me.

@michaelfaith
Copy link
Contributor Author

I'm having second thoughts about the rule name. What do you think about require-test-case-name instead of test-case-name-property? That seems more precise to me.

@aladdin-add
Copy link
Contributor

I'm having second thoughts about the rule name. What do you think about require-test-case-name instead of test-case-name-property? That seems more precise to me.

👍 It better illustrates the functionality of this rule.

@michaelfaith michaelfaith changed the title feat(test-case-name-property): add rule to require name for test cases feat(require-test-case-name): add rule to require name for test cases Oct 22, 2025
@michaelfaith
Copy link
Contributor Author

michaelfaith commented Oct 22, 2025

@aladdin-add That should be all of the new violations addressed.

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.

👍 Looks great! just a few questions/minor suggestions.

Leaving it open 2~3 days for others to review.

@aladdin-add aladdin-add requested a review from bmish October 23, 2025 02:37
@bmish bmish changed the title feat(require-test-case-name): add rule to require name for test cases feat: add new rule require-test-case-name Oct 23, 2025
@aladdin-add aladdin-add merged commit ceb07dc into eslint-community:main Oct 23, 2025
23 checks passed
@michaelfaith michaelfaith deleted the feat/test-case-property-name branch October 23, 2025 16:56
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: test-case-name-property

3 participants