-
Notifications
You must be signed in to change notification settings - Fork 152
Closed
Labels
Description
Name for new rule
no-global-regex-flag-to-query
Description of the new rule
The rule would warn when a user uses the global regex flag to search for text/name.
A regex that uses the global flag holds the lastIndex
state when it found a match, due to this it could be that a new match can't be found.
See testing-library/dom-testing-library#1116 for the fix within DTL, where we added a log when we detect this.
Testing Library feature
Queries that use a regex
Testing Library framework(s)
All
What category of rule is this?
Suggests an alternate way of doing something
Optional: other category of rule
No response
Code examples
screen.getAllByText(/hello world/g)
screen.findByRole('button', {name: /log in/ig})
Anything else?
No response
Do you want to submit a pull request to make the new rule?
Yes
Belco90