-
Notifications
You must be signed in to change notification settings - Fork 153
Closed
Labels
Description
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 it
- Avoids the dreaded naming problem
- Allows automation and developers to move faster by inferring test Id's without having to look them up every time.
Here is what the rule config looks like
'@custom/my-secret-plugin-name/data-testid': [
2,
{
testIdPattern: '^{componentName}(__([A-Z]+[a-z]*?)+)*$',
excludePaths: ['__tests__']
}
],
If you think this is generally useful I would be happy to submit a PR to add this rule.
Thanks!
Belco90, gaving and OddKMS