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

feat(eslint-plugin): [prefer-regexp-exec] add autofix

Merged
merged 5 commits into from Apr 10, 2021

Conversation

phaux
Copy link
Contributor

@phaux phaux commented Mar 21, 2021

  • s.match(/regexpLiteral/) autofixes to /regexpLiteral/.exec(s)
  • s.match("regexpString") autofixes to /regexpString/.exec(s)
  • s.match(regexpVariable) autofixes to regexpVariable.exec(s)
  • s.match(stringVariable) autofixes to RegExp(stringVariable).exec(s)
  • Report location changed to just the method identifier ("match")
  • getWrappingFixer doesn't always add parens when not necessary

@typescript-eslint
Copy link
Contributor

typescript-eslint bot commented Mar 21, 2021

Thanks for the PR, @phaux!

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 bot commented Mar 21, 2021

Codecov Report

Merging #3207 (0d11e8d) into master (a5836be) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3207      +/-   ##
==========================================
+ Coverage   92.82%   92.86%   +0.04%     
==========================================
  Files         318      318              
  Lines       11003    11049      +46     
  Branches     3110     3129      +19     
==========================================
+ Hits        10213    10261      +48     
  Misses        350      350              
+ Partials      440      438       -2     
Flag Coverage Δ
unittest 92.86% <100.00%> (+0.04%) ⬆️

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%> (ø)
...ackages/eslint-plugin/src/util/getWrappingFixer.ts 100.00% <100.00%> (+6.06%) ⬆️

@bradzacher bradzacher added the enhancement label Mar 21, 2021
@phaux
Copy link
Contributor Author

phaux commented Mar 22, 2021

I added a test which creates a fake rule which uses getWrappingFixer and tests all code paths within it. That function is already too complicated for what it does but I hope at least it will be useful in other rules.

bradzacher
bradzacher previously approved these changes Apr 10, 2021
Copy link
Member

@bradzacher bradzacher left a comment

LGTM - thanks for adding this!

@bradzacher bradzacher merged commit e2cbeef into typescript-eslint:master Apr 10, 2021
10 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants