Skip to content

chore(jest-util): replace slash with inline implementation#15971

Open
roli-lpci wants to merge 5 commits intojestjs:mainfrom
roli-lpci:chore/remove-slash
Open

chore(jest-util): replace slash with inline implementation#15971
roli-lpci wants to merge 5 commits intojestjs:mainfrom
roli-lpci:chore/remove-slash

Conversation

@roli-lpci
Copy link

Summary

Replace the slash package with an inline implementation in jest-util. The entire slash package is path.replace(/\\/g, '/') — a one-liner that doesn't need an external dependency.

  • New slash function exported from jest-util (3 lines, uses String.prototype.replaceAll)
  • Updated imports across all 20 consumer files (15 .ts source files, 3 .js test files, 2 e2e test fixtures)
  • Removed slash from all 14 package.json dependency entries (13 packages + root)
  • Added jest-util dependency to babel-jest, jest-message-util, and @jest/test-sequencer (which didn't previously depend on it)

Note: this does not touch replacePathSepForGlob, which is a different function that only replaces path.sep (preserving glob escape chars).

Test plan

  • ESLint clean on all 20 modified source files
  • Prettier clean
  • yarn constraints passes
  • yarn dedupe --check passes
  • No remaining from 'slash' or require('slash') imports outside node_modules

Replace the `slash` package with a 3-line inline implementation in
`jest-util`. The `slash` package simply replaces backslashes with
forward slashes — a one-liner that doesn't need an external dependency.

- New `slash` function exported from `jest-util`
- Updated imports across all 20 consumer files
- Removed `slash` from all 14 package.json dependencies
- Added `jest-util` dependency to babel-jest, jest-message-util,
  and jest-test-sequencer (which didn't previously depend on it)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 27, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify
Copy link

netlify bot commented Feb 27, 2026

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 51cb3f0
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/69a0fa88172cd30008a30527
😎 Deploy Preview https://deploy-preview-15971--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Feb 27, 2026

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a45b213
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/69a15dba656a970008b44a04
😎 Deploy Preview https://deploy-preview-15971--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Add missing tsconfig.json project references for packages that gained
jest-util as a new dependency (babel-jest, jest-message-util,
jest-test-sequencer). The buildTs.mjs validation script asserts that
tsconfig references match workspace dependencies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 27, 2026

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15971

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15971

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15971

create-jest

npm i https://pkg.pr.new/create-jest@15971

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15971

expect

npm i https://pkg.pr.new/expect@15971

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15971

jest

npm i https://pkg.pr.new/jest@15971

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15971

jest-circus

npm i https://pkg.pr.new/jest-circus@15971

jest-cli

npm i https://pkg.pr.new/jest-cli@15971

jest-config

npm i https://pkg.pr.new/jest-config@15971

@jest/console

npm i https://pkg.pr.new/@jest/console@15971

@jest/core

npm i https://pkg.pr.new/@jest/core@15971

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15971

jest-diff

npm i https://pkg.pr.new/jest-diff@15971

jest-docblock

npm i https://pkg.pr.new/jest-docblock@15971

jest-each

npm i https://pkg.pr.new/jest-each@15971

@jest/environment

npm i https://pkg.pr.new/@jest/environment@15971

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15971

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15971

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15971

@jest/expect

npm i https://pkg.pr.new/@jest/expect@15971

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15971

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15971

@jest/globals

npm i https://pkg.pr.new/@jest/globals@15971

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15971

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15971

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15971

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15971

jest-message-util

npm i https://pkg.pr.new/jest-message-util@15971

jest-mock

npm i https://pkg.pr.new/jest-mock@15971

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15971

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15971

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15971

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15971

jest-resolve

npm i https://pkg.pr.new/jest-resolve@15971

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15971

jest-runner

npm i https://pkg.pr.new/jest-runner@15971

jest-runtime

npm i https://pkg.pr.new/jest-runtime@15971

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15971

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15971

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15971

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15971

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15971

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15971

@jest/transform

npm i https://pkg.pr.new/@jest/transform@15971

@jest/types

npm i https://pkg.pr.new/@jest/types@15971

jest-util

npm i https://pkg.pr.new/jest-util@15971

jest-validate

npm i https://pkg.pr.new/jest-validate@15971

jest-watcher

npm i https://pkg.pr.new/jest-watcher@15971

jest-worker

npm i https://pkg.pr.new/jest-worker@15971

pretty-format

npm i https://pkg.pr.new/pretty-format@15971

commit: 0d3f4f9

roli-lpci and others added 2 commits February 26, 2026 22:32
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removing the slash import from jest-resolve changed line numbers in the
built output, causing snapshot mismatches in moduleNameMapper,
requireMissingExt, and resolveNoFileExtensions tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant