A toolkit for running codemods over multiple JavaScript or TypeScript files using AST transformations.
jscodeshift is a toolkit for running codemods (code modification scripts) across multiple JavaScript or TypeScript files. It provides a CLI runner and a JavaScript API to apply transformations, making large-scale codebase refactoring and upgrades efficient and consistent.
JavaScript and TypeScript developers, library maintainers, and teams needing to perform automated, consistent code transformations across entire projects or codebases.
Developers choose jscodeshift for its jQuery-like API for AST manipulation, which simplifies writing complex codemods, and its ability to preserve original code formatting while supporting multiple parsers like Babel, Flow, and TypeScript.
A JavaScript codemod toolkit.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Offers a jQuery-like interface for navigating and modifying ASTs, making complex transformations more readable and maintainable, as shown in the example using .findVariableDeclarators().
Uses recast under the hood to retain original formatting and comments during transformations, reducing noise in diffs and maintaining code consistency.
Supports Babel, Flow, TypeScript, and custom parsers, allowing it to handle diverse codebases and modern JavaScript features seamlessly.
Includes helpers like defineTest and defineInlineTest for unit testing transforms with Jest and snapshot testing, streamlining the development of reliable codemods.
Requires deep understanding of ASTs and the jscodeshift API, which can be a barrier for developers unfamiliar with abstract syntax trees or complex code manipulation.
Only works with JavaScript and TypeScript files, making it unsuitable for projects with mixed or non-JS codebases without additional tooling.
Debugging transforms can be challenging, especially with asynchronous issues or intricate AST changes, though the README provides VSCode setup guidance.