You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ESLint: `data-testid` "some_snake_case_value" should match '^([a-z][a-z0-9]*)(-[a-z0-9]+)*$'' (testing-library/consistent-data-testid)
How will the new rule affect the code?
Example ESLint config:
'testing-library/consistent-data-testid': ['error',{'testIdPattern': '^([a-z][a-z0-9]*)(-[a-z0-9]+)*$',// kebab-case'testIdAttribute': ['data-testid'],'customMessage': 'Please use kebab-case values for data-testids.'}]
Example code:
<divdata-testid="some_snake_case_value" />
Example error:
ESLint: `data-testid` Please use kebab-case values for data-testids. (testing-library/consistent-data-testid)
Anything else?
First things first, I hope I've used the right issue template. Also, I am more than happy to have a go at this issue and open a PR, in case you all agree to proceed with this change.
In my opinion adding this change would support devs in providing more meaningful (error) messages. In my example, the developer does not need to think about what the regex means, but is just shown a straight-forward message.
Any feedback is welcome :)
Do you want to submit a pull request to change the rule?
Yes
The text was updated successfully, but these errors were encountered:
)
Closes#718
* feat(consistent-data-testid): add support for custom message in the rule configuration
* feat(consistent-data-testid): update docs
* feat(consistent-data-testid): use undefined as default value for customMessage
* feat(consistent-data-testid): add comment to test case
Co-authored-by: Patrick Ahmetovic <[email protected]>
What rule do you want to change?
consistent-data-testid
Does this change cause the rule to produce more or fewer warnings?
More warnings
How will the change be implemented?
The changes will be implemented by extending the possible rule configuration values by a new field (e.g.
customMessage
), and consuming it, if present.Example code
Example ESLint config:
How does the current rule affect the code?
Example ESLint config:
Example code:
Example error:
How will the new rule affect the code?
Example ESLint config:
Example code:
Example error:
Anything else?
First things first, I hope I've used the right issue template. Also, I am more than happy to have a go at this issue and open a PR, in case you all agree to proceed with this change.
In my opinion adding this change would support devs in providing more meaningful (error) messages. In my example, the developer does not need to think about what the regex means, but is just shown a straight-forward message.
Any feedback is welcome :)
Do you want to submit a pull request to change the rule?
Yes
The text was updated successfully, but these errors were encountered: