-
-
Notifications
You must be signed in to change notification settings - Fork 31
feat: add new rule require-test-case-name
#553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add new rule require-test-case-name
#553
Conversation
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.
There was a problem hiding this 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, andobjects-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.
I prefer in this PR, but both are fine for me. |
|
I'm having second thoughts about the rule name. What do you think about |
👍 It better illustrates the functionality of this rule. |
name for test casesname for test cases
|
@aladdin-add That should be all of the new violations addressed. |
There was a problem hiding this 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.
name for test casesrequire-test-case-name

This change adds a new rule to require
namebe 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 samecodeacross multiple test cases, with onlyoptionsorsettingsdiffering between them. Requiring these test cases to have anamehelps ensure the test output is meaningful and distinct.Closes #544