A powerful tool for running and testing JavaScript/TypeScript codemods, inspired by ast-grep.
jssg is a JavaScript/TypeScript toolkit that simplifies writing and testing ast-grep codemods. It’s built into the Codemod CLI, making it easy to run codemods from the command line and publish them to the registry. If you’ve used tools like jscodeshift, jssg will feel familiar—but with key advantages. Unlike jscodeshift, jssg is built on the robust and high-performance ast-grep engine, written in Rust and optimized for fast, large-scale code transformations. Most importantly, thanks to ast-grep’s tree-sitter foundation, jssg supports a wide range of languages—including custom ones.
To run a jssg codemod on a target directory for a specific language like Java, use the following command:
Note: Although your jssg codemods are written in JS/TS, the target language can be something else.
Target language (e.g., javascript
, typescript
, python
, java
, cpp
, php
, kotlin
, etc.).
Comma-separated list of file extensions to process.
Do not respect .gitignore
files.
Include hidden files and directories in the scan.
Maximum number of concurrent threads to use.
Perform a dry-run to see the changes without applying them.
The jssg testing framework provides testing capabilities for jssg codemods using before/after fixture files.
Create your test directory. A common structure includes input
and expected
files for each test case.
Run the tests using the npx codemod@latest jssg test
command.
These options are required for running tests with jssg.
Path to the jssg codemod file, which is a JS/TS file.
Target language (e.g., javascript
, typescript
, python
, java
, cpp
, php
, kotlin
, etc.).
Control which tests are discovered and run.
The directory containing your tests (default: "tests"
).
A pattern to run only tests whose names match the filter.
Options for controlling test output and reporting.
The output format for test results. Can be console
, json
, or terse
.
Show detailed output, including diffs for failed tests.
The number of context lines to show in diffs (default: 3).
Ignore whitespace differences when comparing test outputs.
Options for controlling how tests are executed.
Test timeout in seconds (default: 30).
Maximum number of concurrent threads to use for running tests.
Run tests sequentially instead of in parallel.
Stop the test run on the first failure.
Options for managing test snapshots and expected errors.
Create or update the expected
files with the output of the codemod.
A comma-separated list of test patterns that are expected to fail.
Development-focused options for rapid iteration.
Enable watch mode to automatically re-run tests when files change.