Skip to content
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

Should unnecessary_raw_strings be enforced in RegExps? #3385

Open
jamesderlin opened this issue May 8, 2022 · 0 comments
Open

Should unnecessary_raw_strings be enforced in RegExps? #3385

jamesderlin opened this issue May 8, 2022 · 0 comments
Labels
P3 A lower priority bug or feature request type-question A question about expected behavior or functionality

Comments

@jamesderlin
Copy link

Describe the issue
I typically am in the habit of using raw strings with RegExps. IMO this is a good habit to have, even if using raw strings for a particular pattern isn't strictly necessary. Using a raw string allows me to not have to think. Should using raw strings unnecessarily when constructing a RegExp really be discouraged?

In the meantime, I'll probably just be disabling unnecessary_raw_strings entirely.

To Reproduce

var decimalRegExp = RegExp(r'\d+');
var hexRegExp = RegExp(r'(0x)?[0-9a-fA-F]+'); // unnecessary_raw_strings

Expected behavior
Perhaps relax the unnecessary_raw_strings lint if the string is used for a RegExp?

Bonus points if it also could recognize and ignore cases like:

const hexPattern = r'(0x)?[0-9a-fA-F]+';
var hexRegExp = RegExp(hexPattern);

although I'm far less concerned about that case.

@srawlins srawlins added the type-question A question about expected behavior or functionality label Jun 29, 2022
@srawlins srawlins added the P3 A lower priority bug or feature request label Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 A lower priority bug or feature request type-question A question about expected behavior or functionality
Projects
None yet
Development

No branches or pull requests

2 participants