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
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.
Btw, if this has to be applied to every Testing Library util, you could just select all CallExpression and check if they are related to Testing Library with isTestingLibraryUtil, and then, if so, check the args given. Just an idea!
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
Anything else?
No response
Do you want to submit a pull request to make the new rule?
Yes
The text was updated successfully, but these errors were encountered: