|
1 | 1 | # Contributing |
2 | 2 |
|
3 | | -Thank you for helping improve <ECOSYSTEM_NAME> codemods. This project provides automated migrations to help the community adopt new features and upgrade across breaking changes. |
| 3 | +Thanks for helping users adopt the latest features with your codemods! |
4 | 4 |
|
5 | | -## How we work |
| 5 | +### Before You Open a PR |
6 | 6 |
|
7 | | -- Propose: open an issue before large changes |
8 | | -- Safety: codemods must be safe, predictable, idempotent |
9 | | -- Tests: include multiple fixtures (positive/negative/idempotent) |
10 | | -- Documentation: update per-recipe README and root docs |
| 7 | +- **Issue**: Check for an existing issue, or open one first. |
| 8 | +- **Safety**: Codemods must be safe, predictable, and idempotent (running twice should not change code again). Avoid mixing patterns with different safety levels. |
| 9 | +- **Naming**: In `codemod.yaml`, the codemod name must start with `@<scope>`, where `<scope>` is this repo's GitHub org. |
| 10 | +- **Tests**: Add multiple fixtures (positive and negative). |
| 11 | +- **Docs**: Update the README for your codemod. |
11 | 12 |
|
12 | | -For workflow structure and orchestration details, see: https://docs.codemod.com/cli/workflows |
| 13 | +### Development |
13 | 14 |
|
14 | | -## Getting started |
| 15 | +- Scaffold a new codemod: |
| 16 | + ```bash |
| 17 | + npx codemod@latest init |
| 18 | + ``` |
| 19 | +- Test your codemod locally; |
| 20 | + ```bash |
| 21 | + cd /path/to/sample/project |
| 22 | + npx codemod workflow run -w /path/to/my-codemod/workflow.yaml |
| 23 | + ``` |
| 24 | +### Project Layout |
15 | 25 |
|
16 | | -```bash |
17 | | -npm install |
18 | | -npm run lint |
19 | | -npm run validate |
20 | | -npm run typecheck |
21 | | -npm run test |
22 | | -``` |
| 26 | +- Place all codemods in the `codemods/` directory. |
23 | 27 |
|
24 | | -## Scaffolding a new codemod |
| 28 | +### Checks |
25 | 29 |
|
26 | | -```bash |
27 | | -npx codemod@latest init codemods/my-codemod |
28 | | -``` |
| 30 | +- Lint/format: npm run check (Biome) |
| 31 | +- Types: npm run typecheck |
29 | 32 |
|
30 | | -During prompts, select appropriate options for your use case. Placeholders to adapt: |
31 | | -- Name: `@<NAMESPACE>/<MAJOR_VERSION>/<codemod-name>` |
| 33 | +### Pull Requests |
32 | 34 |
|
33 | | -## Commit messages |
| 35 | +- Describe the codemod and its migration use case. |
| 36 | +- Follow Conventional Commits: |
34 | 37 |
|
35 | | -Use Conventional Commits: |
36 | | -- `feat(scope):` add a new codemod or capability |
37 | | -- `fix(scope):` bugfixes in a transform or tests |
38 | | -- `docs(scope):` docs-only changes |
39 | | -- `refactor(scope):` code changes that neither fix a bug nor add a feature |
40 | | -- `test(scope):` add or adjust fixtures/tests |
41 | | -- `chore(scope):` tooling, CI, formatting, repo hygiene |
| 38 | +| Type | Usage | |
| 39 | +|----------|--------------------------------------| |
| 40 | +| feat | New codemod or capability | |
| 41 | +| fix | Bugfix in a transform or test | |
| 42 | +| docs | Documentation-only changes | |
| 43 | +| refactor | Non-feature, non-bugfix code changes | |
| 44 | +| test | Add or update fixtures/tests | |
| 45 | +| chore | Tooling, CI, formatting, repo hygiene| |
42 | 46 |
|
43 | | -## Security |
| 47 | +### License |
44 | 48 |
|
45 | | -See SECURITY.md and report privately. |
46 | | - |
47 | | -## License |
48 | | - |
49 | | -MIT |
| 49 | +By contributing, you agree that your work will be licensed under the MIT License. |
0 commit comments