Skip to content

fix: no-conditional-in-test does not trigger for conditionals in test metadata (fixes #363) #372

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

Merged
merged 4 commits into from
Jul 10, 2025

Conversation

mskelton
Copy link
Member

@mskelton mskelton commented Jul 9, 2025

Fixes #363.

  • The no-conditional-in-test rule now only triggers for conditionals inside the test body, not in test metadata.
  • Added a test to ensure conditionals in test metadata are allowed.

@mskelton mskelton added the ai Generated with Cursor or Claude Code label Jul 9, 2025
@mskelton mskelton requested a review from Copilot July 10, 2025 01:47
Copy link
Contributor

@Copilot 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 updates the no-conditional-in-test ESLint rule so that it only flags conditionals inside the actual test function body (not in the metadata object) and adds a new test case to verify this behavior.

  • Restrict reporting to ternaries within the test callback function
  • Early-return when the last argument isn’t a function
  • Add a valid test confirming metadata conditionals are allowed

Reviewed Changes

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

File Description
src/rules/no-conditional-in-test.ts Wraps the existing report call in a check that the node is inside the test function body only
src/rules/no-conditional-in-test.test.ts Adds a valid test case ensuring conditionals in the metadata object do not trigger the rule
CLAUDE.md Introduces high-level project guidelines document
.cursor/rules/eslint-plugin-playwright.mdc Expands detailed internal ESLint-plugin development guidelines

@mskelton mskelton merged commit 12b0832 into main Jul 10, 2025
3 checks passed
@mskelton mskelton deleted the fix/no-conditional-in-test-metadata-363 branch July 10, 2025 04:20
Copy link

🎉 This PR is included in version 2.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai Generated with Cursor or Claude Code released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no-conditional-in-test rule triggers for test metadata conditionals (false-positive)
1 participant