|
| 1 | +--- |
| 2 | +name: deprecations |
| 3 | +description: 'Use when: deprecating Primer React components or hooks. Covers source annotations, docs metadata, changesets, docs page updates, and validation for deprecations.' |
| 4 | +--- |
| 5 | + |
| 6 | +# Deprecating components and hooks in Primer React |
| 7 | + |
| 8 | +Use this skill when a task involves marking a public Primer React API as deprecated. |
| 9 | + |
| 10 | +## What to update |
| 11 | + |
| 12 | +### Source code |
| 13 | + |
| 14 | +- Add a JSDoc `@deprecated` annotation to the exported component, hook, prop, or type following existing patterns nearby. |
| 15 | +- Keep runtime behavior unchanged unless the task explicitly requires more than deprecation signaling. |
| 16 | + |
| 17 | +### Docs metadata |
| 18 | + |
| 19 | +- For components, mark the relevant `*.docs.json` file with `"status": "deprecated"`. |
| 20 | +- For hooks, mark the relevant `*.hookDocs.json` file with `"status": "deprecated"`. |
| 21 | +- If schema or build tooling does not yet support the docs metadata you need, update the corresponding schema/build files in `packages/react/script/*-json/`. |
| 22 | + |
| 23 | +### Documentation content |
| 24 | + |
| 25 | +- If the deprecated component has a docs page or JSON-backed docs content that supports deprecation guidance, add or update the deprecation guidance and recommended alternative. |
| 26 | +- Follow `contributor-docs/deprecating-components.md`. |
| 27 | + |
| 28 | +### Versioning |
| 29 | + |
| 30 | +- Add a changeset for public API deprecations. |
| 31 | +- Use the versioning guidance in `contributor-docs/versioning.md` to choose the correct bump. |
| 32 | + |
| 33 | +## Validation |
| 34 | + |
| 35 | +Prefer targeted validation first, then broader validation if needed: |
| 36 | + |
| 37 | +- Format changed files with `npx prettier --write <paths>` |
| 38 | +- Lint changed TypeScript files with `npx eslint --fix <paths>` |
| 39 | +- Rebuild generated docs metadata when related schema or docs JSON changes: |
| 40 | + |
| 41 | +```bash |
| 42 | +npm run build:hooks.json -w @primer/react |
| 43 | +``` |
| 44 | + |
| 45 | +```bash |
| 46 | +npm run build:components.json -w @primer/react |
| 47 | +``` |
| 48 | + |
| 49 | +- Run targeted tests for the affected API when available |
| 50 | +- Run broader repository validation before finalizing if the change touches shared build tooling |
| 51 | + |
| 52 | +## Common files |
| 53 | + |
| 54 | +- `packages/react/src/**/*.docs.json` |
| 55 | +- `packages/react/src/**/*.hookDocs.json` |
| 56 | +- `packages/react/script/components-json/*` |
| 57 | +- `packages/react/script/hooks-json/*` |
| 58 | +- `contributor-docs/deprecating-components.md` |
| 59 | +- `.changeset/*.md` |
0 commit comments