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

fix(eslint-plugin): [prefer-regexp-exec] respect flags when using RegExp #3855

Merged
merged 1 commit into from Sep 21, 2021

Conversation

rafaelss95
Copy link
Contributor

@rafaelss95 rafaelss95 commented Sep 8, 2021

Fixes #3477.

@typescript-eslint
Copy link
Contributor

@typescript-eslint typescript-eslint bot commented Sep 8, 2021

Thanks for the PR, @rafaelss95!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

@codecov codecov bot commented Sep 8, 2021

Codecov Report

Merging #3855 (1453074) into master (4195919) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Current head 1453074 differs from pull request most recent head 9fa7537. Consider uploading reports for the commit 9fa7537 to get more accurate results

@@           Coverage Diff           @@
##           master    #3855   +/-   ##
=======================================
  Coverage   93.50%   93.51%           
=======================================
  Files         151      151           
  Lines        8134     8140    +6     
  Branches     2580     2583    +3     
=======================================
+ Hits         7606     7612    +6     
  Misses        167      167           
  Partials      361      361           
Flag Coverage Δ
unittest 93.51% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ages/eslint-plugin/src/rules/prefer-regexp-exec.ts 100.00% <100.00%> (ø)

@bradzacher bradzacher added the bug label Sep 8, 2021
@rafaelss95 rafaelss95 changed the title fix(eslint-plugin): [prefer-regexp-exec]: respect flags when using RegExp fix(eslint-plugin): [prefer-regexp-exec] respect flags when using RegExp Sep 12, 2021
Copy link
Member

@bradzacher bradzacher left a comment

It looks like there currently aren't any existing tests for new RegExp - but I just checked and the rule currently supports its.
It just doesn't do the "global" check on them.

Your change causes the new RegExp constructor to be completely ignored - which is not correct.

Instead we should inspect the new constructor to extract the second argument to determine if it has a 'g' in the string

@bradzacher bradzacher added the awaiting response label Sep 20, 2021
@rafaelss95
Copy link
Contributor Author

@rafaelss95 rafaelss95 commented Sep 21, 2021

Your change causes the new RegExp constructor to be completely ignored - which is not correct.

@bradzacher Sorry, but I didn't understand what you mean, I've tested it locally and the reports went expected. Note that I had already added a test that covered new RegExp(...) for valid cases and I just added another one for invalid ones, just in case.

Oh, wait, I see... there's some inconsistent behavior. I'll look ASAP.

@rafaelss95 rafaelss95 force-pushed the fix/3477 branch 2 times, most recently from 85b7de5 to 1453074 Compare Sep 21, 2021
Copy link
Member

@bradzacher bradzacher left a comment

thanks for adding all of those tests!
LGTM!

@bradzacher bradzacher merged commit ffdb5ff into typescript-eslint:master Sep 21, 2021
9 checks passed
@bradzacher bradzacher removed the awaiting response label Sep 21, 2021
@rafaelss95 rafaelss95 deleted the fix/3477 branch Sep 21, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants