Repository navigation
refactor: inline escape-string-regexp (single-regex utility) - #5883
Conversation
The escape-string-regexp package is a single regex function. Inline it at all 4 call sites and remove the dependency. Ref: #5357 (v12 Release Plan)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5883 +/- ##
==========================================
- Coverage 89.87% 89.77% -0.11%
==========================================
Files 64 65 +1
Lines 4723 4725 +2
Branches 994 994
==========================================
- Hits 4245 4242 -3
- Misses 478 483 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR inlines the functionality of the escape-string-regexp package into Mocha and removes the direct production dependency, updating internal call sites to use the new shared utility.
Changes:
- Add
lib/utils/regexp.mjsproviding an internalescapeRegExp()helper. - Update Mocha core, HTML reporter, and tests to use the in-repo
escapeRegExp()instead ofescape-string-regexp. - Remove
escape-string-regexpfromdependenciesinpackage.json(lockfile updates reflect it remaining as a transitive dev dependency via tooling).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/utils/regexp.mjs |
Introduces the inlined regexp-escaping utility. |
lib/mocha.js |
Switches fgrep() to use the new internal escapeRegExp(). |
lib/reporters/html.js |
Switches suite/test URL generation to use the new internal escapeRegExp(). |
test/integration/helpers.js |
Updates integration helper to source escapeRegExp() from the new internal module. |
test/assertions.js |
Updates custom unexpected assertions to use the internal escapeRegExp(). |
package.json |
Removes the direct dependency on escape-string-regexp. |
package-lock.json |
Updates lockfile to reflect dependency removal and remaining transitive usage. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Also, I failed to mention: I added this new function to its own file in Ideally I would want to eventually refactor it and split it apart. |
The escape-string-regexp package is a single regex function. Inline it and remove the dependency.
Supersedes: #5772 #5773
PR Checklist
status: accepting prsOverview
Contains an expiring todo comment that will be helpful when/if we add #5882