Repository navigation
feat(codemods): move mobile-to-root to @react-simplikit/codemods on jscodeshift - #617
Merged
Merged
Conversation
…scodeshift Follow the toss/suspensive codemods layout: a commander bin that prompts for missing arguments in a terminal and spawns jscodeshift, with one file per transform under src/transforms. - mobile-to-root keeps its offset-based edits, now on Babel through jscodeshift's parsers (Flow fallback for .js, sloppy-mode scripts) - jscodeshift runs from inside the target so ignore patterns never match a parent folder, and a missing path exits 1 - git-dirty check with --force, --jscodeshift passthrough, --fail-on-error - --help lists the transforms; a run that wrote files prints next steps - version fixed to react-simplikit, Node 20+
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #617 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 70 67 -3
Lines 2364 2171 -193
Branches 763 692 -71
==========================================
- Hits 2364 2171 -193 🚀 New features to boost your workflow:
|
Contributor
|
Size Change: -6.47 kB (-5.16%) ✅ Total Size: 119 kB 📦 View Changed
ℹ️ View Unchanged
|
Each fixture pair comes from a real-world case, with the old CLI's output as the expected file. Tests compare bytes without trimming, run the transform again on the output, and count the REP reports. Inputs that must not change and an input that cannot parse have their own fixtures. .gitattributes keeps the CRLF and BOM fixtures byte for byte.
🦋 Changeset detectedLatest commit: 2f7baaf The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…git errors - Report a mention of @react-simplikit/mobile left after the rewrite, not only when nothing in the file could be rewritten; package.json reports a mention outside the dependency fields - Leave an import on its own line when a line comment such as `// @ts-expect-error` sits right above it - Join merged bindings with the file's own line ending - Read a package.json that starts with a byte order mark - Find jest.setMock, createMockFromModule, genMockFromModule, deepUnmock and vi.doUnmock - Stop when git cannot read the status, instead of only skipping a folder outside a repository - Drop the change records only the old --json report read - Require Node 22, the oldest version CI runs; build in prepack Tests now read arrange, act, assert with one behaviour each and literal expectations. CLI behaviour that a pipe can drive moves from mocked unit tests to the e2e suite with real git and jscodeshift.
This was referenced Nov 23, 2026
tsdown runs publint on CI, publint packs the package, and packing ran prepack, which built again. The loop ran until the runner shut down. Release builds before publishing, so the package needs no lifecycle script.
mnxmnz
marked this pull request as ready for review
November 29, 2026 08:50
hyesungoh
approved these changes
Nov 30, 2026
hyesungoh
left a comment
Member
There was a problem hiding this comment.
great! LGTM 👍 👍
(just keep the first manual publish in mind 🙏 )
Merged
This was referenced Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
react-simplikit-codemodcarried its own file walker, report format and TypeScript-compiler parser for its one transform,mobile-to-root. A second transform would have had to plug into all three. This PR renames the package to@react-simplikit/codemodsand runs transforms through jscodeshift, so a transform is one file undersrc/transformsand the CLI only picks it and hands it to jscodeshift.[codemod] [path]. In a terminal it asks for a missing argument; anywhere else it exits1, because an unanswered prompt would otherwise end with0having changed nothing.--helplists the transforms.--forceskips the check, and a folder outside a git repository is not checked.buildordistfolder would otherwise have every file ignored.mobile-to-rootkeeps its rewrite and merge rules and still edits by offset, so formatting, comments, quote style and CRLF line endings survive. It now parses with Babel through jscodeshift, with a Flow fallback for.jsfiles.package.jsonhandling is unchanged, and a manifest with a byte order mark now parses.@react-simplikit/mobileleft after the rewrite, such as a subpath import, is now reported even when the file had other imports to rewrite. Before, only a file with nothing to rewrite was reported.// @ts-expect-errorright above it is left on its own line and reported, so the comment does not end up on another statement.react-simplikitthrough the changesetfixedgroup, and Node 22 or later is required, the oldest version CI runs.--dry-run--dry--jsonREPlines--ignore <glob>--jscodeshift="--ignore-pattern=<glob>"--no-package-json--debug.Tests
mobile-to-rootcases run on the new parser; only the cases that relied on the TypeScript parser accepting invalid code changed.declare module, Flow and sloppy-mode.js,.cjs/.mjs/.d.ts, andpackage.jsonwithworkspace:*, peer ranges andresolutions. The expected files are the old CLI's output, compared byte for byte without trimming. Each test also runs the transform again on the expected file and counts theREPreports. Inputs that must stay unchanged and an input that cannot parse have their own fixtures.buildfolder, a single file, a missing path, a run outside a terminal,--dry,--print,--jscodeshift, and the packed tarball. Only the interactive prompts keep mocked unit tests.readonly Array<…>that tsc rejects too.Limits:
.jsfile that uses Flow syntax and sloppy-mode syntax together still fails to parse.Checklist
yarn run fixto format and lint the code and docs? (yarn testpasses)yarn run test:coverageto make sure there is no uncovered line?