-
Notifications
You must be signed in to change notification settings - Fork 137
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
Rule to enforce consistent data-testid format #55
Comments
Hey Thomas! Thanks for your message! This rule seems quite interesting and it would be awesome if you could create a PR to include it in the plugin (I want to use it now at my code base actually). I don't fully get how few things work for this rule (like what's the exact behavior of that Let me know if you need help with anything related to the PR. Thanks for you contribution! |
Sounds good! I'll get a PR together. I think this can be general rule. It's tricky to determine the actual component name via AST, so I use the file name as a stand-in (unless it's index, then I use the parent directory). Always open to feedback / improvements so happy to collaborate on it! |
🎉 This issue has been resolved in version 1.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Question: looking at the code and the tests...is it true that this only works for JSX? |
@wingy3181 that is correct - see here for detail on the rule. I'm sure contributions would be welcome to make it work for angular/html as well, I sadly don't have the time at the moment to make those additions. |
@tknickman thanks for the quickly reply...yep that's the same line i saw...if i have some time i will see if i can make those additions..... |
Hey @wingy3181, thanks for bringing this up! I didn't realize this was an exclusive React rule, to be honest, we should have made that clear in the rule description at least. Would you mind reporting this in a new issue so we can track and handle it properly? Thanks! |
Hey, great plugin!
I recently wrote a custom rule that we are using internally at my company to enforce consistent values for
data-testid
. (I found this plugin because I wanted to use the same name 😂). We have a giant monorepo and teams were using everything from camelCase to PascalCase to kebab-case to snake_case to who-knows-what-case when writing test Id's.This rule allows specifying a regex (that can include an inferred component name) that is used to validate all
data-testid
values. It has proved to be useful in larger codebases because itHere is what the rule config looks like
If you think this is generally useful I would be happy to submit a PR to add this rule.
Thanks!
The text was updated successfully, but these errors were encountered: