Skip to content
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

Add rule to suggest using built-in locators (prefer-native-locators) #308

Merged

Conversation

camchenry
Copy link
Contributor

This PR adds a rule for suggesting usage of built-in locators when there is an equivalent to a custom locator that is being used. Rather than trying to rewrite all possible custom locators, I've focused on a cases that are auto-fixable and should have a low false positive rate. So, more complex locators (including text queries) were not included in this initial PR. We should expand this rule to accommodate for other cases in the future.

src/rules/prefer-native-locators.ts Outdated Show resolved Hide resolved
src/rules/prefer-native-locators.ts Outdated Show resolved Hide resolved
src/rules/prefer-native-locators.ts Show resolved Hide resolved
src/rules/prefer-native-locators.ts Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/rules/prefer-native-locators.ts Outdated Show resolved Hide resolved
src/rules/prefer-native-locators.ts Show resolved Hide resolved
src/rules/prefer-native-locators.ts Outdated Show resolved Hide resolved
@camchenry
Copy link
Contributor Author

@mskelton I added some additional test cases based on real-world usage that I was able to find. I am feeling pretty confident in it overall. Feel free to merge if you'd like.

@camchenry
Copy link
Contributor Author

And thank you for reviewing all of the feedback!

@mskelton mskelton merged commit e6f92b0 into playwright-community:main Sep 6, 2024
3 checks passed
Copy link

🎉 This PR is included in version 1.7.0 🎉

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prefer using native getBy* selectors
2 participants