https://github.com/lingui/codemods
Collection of codemods for LinguiJS
https://github.com/lingui/codemods
codemods jscodeshift lingui
Last synced: about 2 months ago
JSON representation
Collection of codemods for LinguiJS
- Host: GitHub
- URL: https://github.com/lingui/codemods
- Owner: lingui
- License: mit
- Created: 2018-09-03T15:01:46.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-11-19T15:57:24.000Z (7 months ago)
- Last Synced: 2025-03-12T04:01:45.581Z (3 months ago)
- Topics: codemods, jscodeshift, lingui
- Language: TypeScript
- Homepage:
- Size: 585 KB
- Stars: 2
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Linguijs Codemods
![]()
![]()
![]()
This repository contains a collection of codemod scripts for use with [JSCodeshift](https://github.com/facebook/jscodeshift) that help update Lingui APIs.
### Usage
`npx @lingui/codemods [...options]`
- `transform` - name of transform, see available transforms below.
- `path` - files or directory to transform
- use the `--dry` option for a dry-run
- use `--print` to print the output for comparison
- use `--remove-unused-imports` to remove unused imports once finished the codemodThis will start an interactive wizard, and then run the specified transform.
### Included Transforms
#### `v2-to-v3`
Converts some outdated standards from `lingui` version 2.x.x to new features and best practices introduced in `lingui` version 3.x.x
```sh
npx @lingui/codemods v2-to-v3
```#### `split-macro-imports`
Converts `@lingui/macro` imports to `@lingui/core/macro` and `@lingui/react/macro`.
```sh
npx @lingui/codemods split-macro-imports
```Visit the [Migration guide from 4.x to 5.x](https://lingui.dev/introduction) for more information.
### jscodeshift options
To pass more options directly to jscodeshift, use `--jscodeshift="..."`. For example:
```sh
npx @lingui/codemods --jscodeshift="--run-in-band --verbose=2"
```See all available options [here](https://github.com/facebook/jscodeshift#usage-cli).
### Recast Options
Options to [recast](https://github.com/benjamn/recast)'s printer can be provided
through jscodeshift's `printOptions` command line argument```sh
npx @lingui/codemods --jscodeshift="--printOptions='{\"quote\":\"double\"}'"
```### Usage without params
A CLI is built-in to help you migrate your codebase, will ask you some questions:
```sh
➜ project git:(master) npx @lingui/codemods
? On which files or directory should the codemods be applied? for ex: ./src
? Which dialect of JavaScript do you use? for ex: JavaScript | Typescript | JavaScript with Flow
? Which transform would you like to apply? for ex: `v2-to-v3`
```### License
@lingui/codemods is [MIT licensed](./LICENSE).