# thx/gogocode

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/thx-gogocode).**

6,075 stars · 465 forks · JavaScript · mit

## Links

- GitHub: https://github.com/thx/gogocode
- awesome-repositories: https://awesome-repositories.com/repository/thx-gogocode.md

## Topics

`ast` `babel` `jscodeshift` `recast` `vue`

## Description

GoGoCode is an AST-based code transformation toolkit that enables developers to query, match, and rewrite JavaScript source code using jQuery-style selectors and wildcard patterns. At its core, it provides a programmatic code refactoring library that manipulates parsed AST nodes, allowing precise structural modifications without worrying about formatting differences. The toolkit also functions as a JavaScript AST query engine, finding code patterns through snippet-based matching with wildcards that capture unknown or variable-length fragments.

What distinguishes GoGoCode is its callback-driven dynamic replacement system, where transformation callbacks receive matched wildcard values and return context-aware replacement code. The jQuery-style selector syntax makes AST traversal intuitive without manual tree walking, while the wildcard-based pattern matching handles both fixed and variable-length code fragments during queries. The toolkit includes a multi-framework migration engine that automates upgrading Vue 2 components to Vue 3 syntax, converting Element UI imports to Element Plus equivalents, and migrating iView to iView 4, with full Vue template-aware parsing for single-file component transformations.

The code transformation capabilities cover AST node insertion, deletion, and replacement, along with positional code insertion methods like append, prepend, before, and after. For querying, it supports code existence checks, matched node iteration, and AST-to-code generation for output or inspection. The framework migration tools specifically handle Vue template transformations alongside JavaScript, enabling full-stack code modifications in a single pass.

## Tags

### Software Engineering & Architecture

- [AST-Based Refactorers](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-tools/internal-tree-representations/ast-based-refactorers.md) — Provides AST-based refactoring by matching and replacing code patterns using queries and wildcards.
- [Template-Aware Transformations](https://awesome-repositories.com/f/software-engineering-architecture/code-transformation-engines/template-aware-transformations.md) — Parses and transforms Vue template syntax alongside JavaScript for full-stack code modifications.
- [Pattern-Based Code Manipulation](https://awesome-repositories.com/f/software-engineering-architecture/coding-patterns/pattern-based-code-manipulation.md) — Finds code snippets by pattern with wildcards and performs insert, remove, or replace operations.
- [Framework Migrations](https://awesome-repositories.com/f/software-engineering-architecture/legacy-migration-strategies/framework-migrations.md) — Automates framework version upgrades by rewriting imports, APIs, and component syntax using AST-based pattern matching.
- [Callback-Driven Replacements](https://awesome-repositories.com/f/software-engineering-architecture/code-transformation-tools/callback-driven-replacements.md) — Accepts callback functions that receive matched wildcard values and return context-aware replacement code. ([source](https://github.com/thx/gogocode/blob/main/docs/specification/basic.en.md))
- [Wildcard Callback Replacements](https://awesome-repositories.com/f/software-engineering-architecture/event-driven-callbacks/wildcard-callback-replacements.md) — Ships callback-driven dynamic replacement where callbacks receive wildcard matches and return replacement code.

### Development Tools & Productivity

- [Source Code Rewriting](https://awesome-repositories.com/f/development-tools-productivity/ast-transformation-tools/ast-to-source-conversion/source-code-rewriting.md) — Provides AST-based source code rewriting for precise structural modifications without formatting concerns.
- [JavaScript AST Transformations](https://awesome-repositories.com/f/development-tools-productivity/ast-transformation-tools/standardized-ast-transformation/javascript-ast-transformations.md) — Provides an AST manipulation library for querying, replacing, and generating JavaScript code.
- [Code Refactoring Tools](https://awesome-repositories.com/f/development-tools-productivity/code-refactoring-tools.md) — Provides a programmatic code rewriting system that inserts, removes, and replaces AST nodes.
- [UI Library Migration Tools](https://awesome-repositories.com/f/development-tools-productivity/ui-library-migration-tools.md) — Rewrites iView component imports and API calls to match iView 4's updated interface. ([source](https://github.com/thx/gogocode/tree/main/docs/vue))

### Programming Languages & Runtimes

- [Pattern Wildcards](https://awesome-repositories.com/f/programming-languages-runtimes/pattern-wildcards.md) — Matches code patterns with wildcards that capture unknown or variable-length fragments during AST queries.
- [Code Fragment Wildcards](https://awesome-repositories.com/f/programming-languages-runtimes/pattern-wildcards/code-fragment-wildcards.md) — Ships wildcard-based pattern matching for capturing unknown code fragments in AST queries. ([source](https://github.com/thx/gogocode/blob/main/docs/specification/basic.en.md))
- [Code Fragment Wildcards](https://awesome-repositories.com/f/programming-languages-runtimes/pattern-wildcards/metric-query-wildcards/code-fragment-wildcards.md) — Uses wildcards in code selectors to match unknown or variable-length code fragments during AST queries.

### User Interface & Experience

- [AST Node Querying](https://awesome-repositories.com/f/user-interface-experience/component-querying/ast-node-querying.md) — Provides jQuery-style AST node selection for pattern-based code queries without manual traversal. ([source](https://cdn.jsdelivr.net/gh/thx/gogocode@main/README.md))
- [jQuery-Style Selectors](https://awesome-repositories.com/f/user-interface-experience/component-querying/ast-node-querying/jquery-style-selectors.md) — Selects AST nodes using a jQuery-like syntax for intuitive code traversal without manual tree walking. ([source](https://github.com/thx/gogocode/tree/main/docs/))
- [Migration Upgrades](https://awesome-repositories.com/f/user-interface-experience/element-plus-ui-components/migration-upgrades.md) — Automates converting Element UI imports and usage patterns to Element Plus equivalents. ([source](https://github.com/thx/gogocode/tree/main/docs/vue))
- [Migration Automation](https://awesome-repositories.com/f/user-interface-experience/ui-component-libraries/migration-automation.md) — Converts component imports and usage patterns between UI libraries like Element UI to Element Plus.

### Web Development

- [Migration Automation](https://awesome-repositories.com/f/web-development/vue-component-wrappers/vue-component-libraries/migration-automation.md) — Automates upgrading Vue 2 components to Vue 3 syntax and migrating Element UI to Element Plus.
- [Version Migration Tools](https://awesome-repositories.com/f/web-development/vue-development/version-migration-tools.md) — Automates rewriting Vue 2 component syntax and lifecycle hooks to Vue 3 equivalents. ([source](https://github.com/thx/gogocode/tree/main/docs/vue))
- [Template Syntax Transformers](https://awesome-repositories.com/f/web-development/vue-starter-templates/template-syntax-transformers.md) — Parses and transforms Vue template syntax alongside JavaScript for full-stack code modifications. ([source](https://github.com/thx/gogocode/tree/main/docs/))

### Data & Databases

- [Vue Template Parsers](https://awesome-repositories.com/f/data-databases/sql-statement-parsing/template-aware-parsing/vue-template-parsers.md) — Parses and transforms Vue template syntax alongside JavaScript for single-file component transformations.

### Scientific & Mathematical Computing

- [CSS-Like Selectors](https://awesome-repositories.com/f/scientific-mathematical-computing/recursive-tree-traversal-algorithms/ast-traversers/css-like-selectors.md) — Implements jQuery-style selector syntax for intuitive AST node selection without manual tree walking.
