Skip to content

refactor: inline escape-string-regexp (single-regex utility) - #5883

Merged
mark-wiemer merged 3 commits into
mainfrom
voxpelli/inline-escape-string-regexp
Apr 15, 2026
Merged

mark-wiemer merged 3 commits into
mainfrom
voxpelli/inline-escape-string-regexp

Conversation

@voxpelli

Copy link
Copy Markdown
Contributor

The escape-string-regexp package is a single regex function. Inline it and remove the dependency.

Supersedes: #5772 #5773

PR Checklist

Overview

Contains an expiring todo comment that will be helpful when/if we add #5882

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)
@voxpelli
voxpelli requested review from a team and Copilot April 14, 2026 14:43
@voxpelli voxpelli self-assigned this Apr 14, 2026
@codecov

codecov Bot commented Apr 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.77%. Comparing base (7d9ade6) to head (1d953da).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/reporters/html.js 33.33% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.mjs providing an internal escapeRegExp() helper.
  • Update Mocha core, HTML reporter, and tests to use the in-repo escapeRegExp() instead of escape-string-regexp.
  • Remove escape-string-regexp from dependencies in package.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.

Comment thread lib/utils/regexp.mjs Resolved
Comment thread lib/utils/regexp.mjs Resolved
Comment thread lib/reporters/html.js Resolved
voxpelli and others added 2 commits April 14, 2026 18:13
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@voxpelli

Copy link
Copy Markdown
Contributor Author

Also, I failed to mention:

I added this new function to its own file in lib/utils/ as the current lib/utils.js is needlessly long and covering a bit too much.

Ideally I would want to eventually refactor it and split it apart.

@mark-wiemer mark-wiemer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yippee!

@mark-wiemer
mark-wiemer merged commit 25e6538 into main Apr 15, 2026
80 of 83 checks passed
@mark-wiemer
mark-wiemer deleted the voxpelli/inline-escape-string-regexp branch April 15, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants