Open History to see the last commit
1# Contributing
2β
3## Questions
4β
5If you have questions about implementation details, help or support, then please use our dedicated community forum at [GitHub Discussions](https://github.com/TanStack/query/discussions) **PLEASE NOTE:** If you choose to instead open an issue for your question, your issue will be immediately closed and redirected to the forum.
6β
7## Reporting Issues
8β
9If you have found what you think is a bug, please [file an issue](https://github.com/TanStack/query/issues/new/choose). **PLEASE NOTE:** Issues that are identified as implementation questions or non-issues will be immediately closed and redirected to [GitHub Discussions](https://github.com/TanStack/query/discussions)
10β
11## Suggesting new features
12β
13If you are here to suggest a feature, first create an issue if it does not already exist. From there, we will discuss use-cases for the feature and then finally discuss how it could be implemented.
14β
15## Development
16β
17_TanStack/query uses **symlink-based** configuration files. For smooth development in a local environment, we recommend developing in an environment that supports symlinks(ex: Linux, macOS, Windows Subsystem for Linux / WSL)._
18β
19If you have been assigned to fix an issue or develop a new feature, please follow these steps to get started:
20β
21- Fork this repository.
22- Install dependencies
23β
24 ```bash
25 pnpm install
26 ```
27β
28 - We use [pnpm](https://pnpm.io/) v10 for package management (run in case of pnpm-related issues).
29β
30 ```bash
31 corepack enable && corepack prepare
32 ```
33β
34 - We use [nvm](https://github.com/nvm-sh/nvm) to manage node versions - please make sure to use the version mentioned in `.nvmrc`
35β
36 ```bash
37 nvm use
38 ```
39β
40- Build all packages.
41β
42 ```bash
43 pnpm build:all
44 ```
45β
46- Run development server.
47β
48 ```bash
49 pnpm run watch
50 ```
51β
52- Implement your changes and tests to files in the `src/` directory and corresponding test files.
53- Document your changes in the appropriate doc page.
54- Git stage your required changes and commit (see below commit guidelines).
55- Submit PR for review.
56β
57### Editing the docs locally and previewing the changes
58β
59The documentations for all the TanStack projects are hosted on [tanstack.com](https://tanstack.com), which is a TanStack Start application (https://github.com/TanStack/tanstack.com). You need to run this app locally to preview your changes in the `TanStack/query` docs.
60β
61> [!NOTE]
62> The website fetches the doc pages from GitHub in production, and searches for them at `../query/docs` in development. Your local clone of `TanStack/query` needs to be in the same directory as the local clone of `TanStack/tanstack.com`.
63β
64You can follow these steps to set up the docs for local development:
65β
661. Make a new directory called `tanstack`.
67β
68```sh
69mkdir tanstack
70```
71β
722. Enter that directory and clone the [`TanStack/query`](https://github.com/TanStack/query) and [`TanStack/tanstack.com`](https://github.com/TanStack/tanstack.com) repos.
73β
74```sh
75cd tanstack
76git clone git@github.com:TanStack/query.git
77# We probably don't need all the branches and commit history
78# from the `tanstack.com` repo, so let's just create a shallow
79# clone of the latest version of the `main` branch.
80# Read more about shallow clones here:
81# https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/#user-content-shallow-clones
82git clone git@github.com:TanStack/tanstack.com.git --depth=1 --single-branch --branch=main
83```
84β
85> [!NOTE]
86> Your `tanstack` directory should look like this:
87>
88> ```
89> tanstack/
90> |
91> +-- query/ (<-- this directory cannot be called anything else!)
92> |
93> +-- tanstack.com/
94> ```
95β
963. Enter the `tanstack/tanstack.com` directory, install the dependencies and run the app in dev mode:
97β
98```sh
99cd tanstack.com
100pnpm i
101# The app will run on https://localhost:3000 by default
102pnpm dev
103```
104β
1054. Now you can visit http://localhost:3000/query/latest/docs/framework/react/overview in the browser and see the changes you make in `tanstack/query/docs` there.
106β
107> [!WARNING]
108> You will need to update the `docs/config.json` file (in `TanStack/query`) if you add a new documentation page!
109β
110You can see the whole process in the screen capture below:
111β
112https://github.com/fulopkovacs/form/assets/43729152/9d35a3c3-8153-4e74-9cb2-af275f7a269b
113β
114### Running examples
115β
116- Make sure you've installed the dependencies in the repo's root directory.
117β
118 ```bash
119 pnpm install
120 ```
121β
122- If you want to run the example against your local changes, run below in the repo's root directory. Otherwise, it will be run against the latest TanStack Query release.
123β
124 ```bash
125 pnpm run watch
126 ```
127β
128- Run below in the selected examples' directory.
129β
130 ```bash
131 pnpm run dev
132 ```
133β
134#### Note on standalone execution
135β
136If you want to run an example without installing dependencies for the whole repo, just follow instructions from the example's README.md file. It will be then run against the latest TanStack Query release.
137β
138## Online one-click setup
139β
140You can use Gitpod (An Online Open Source VS Code like IDE which is free for Open Source) for developing online. With a single click it will start a workspace and automatically:
141β
142- clone the `TanStack/query` repo.
143- install all the dependencies in `/` and `/docs`.
144- run below in the root(`/`) to Auto-build files.
145β
146 ```bash
147 npm start
148 ```
149β
150- run below in `/docs`.
151β
152 ```bash
153 npm run dev
154 ```
155β
156[](https://gitpod.io/#https://github.com/TanStack/query)
157β
158## Commit message conventions
159β
160`TanStack/query` is using [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines).
161β
162We have very precise rules over how our git commit messages can be formatted. This leads to **more readable messages** that are easy to follow when looking through the **project history**.
163β
164### Commit Message Format
165β
166Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
167format that includes a **type**, a **scope** and a **subject**:
168β
169```text
170<type>(<scope>): <subject>
171<BLANK LINE>
172<body>
173<BLANK LINE>
174<footer>
175```
176β
177The **header** is mandatory and the **scope** of the header is optional.
178β
179Any line of the commit message cannot be longer than 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools.
180β
181### Type
182β
183Must be one of the following:
184β
185- **feat**: A new feature
186- **fix**: A bug fix
187- **docs**: Documentation only changes
188- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
189- **refactor**: A code change that neither fixes a bug nor adds a feature
190- **perf**: A code change that improves performance
191- **test**: Adding missing or correcting existing tests
192- **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation
193β
194### Scope
195β
196The scope could be anything specifying place of the commit change. For example `query-core`, `react-query` etc...
197β
198You can use `*` when the change affects more than a single scope.
199β
200### Subject
201β
202The subject contains succinct description of the change:
203β
204- use the imperative, present tense: "change" not "changed" nor "changes"
205- don't capitalize first letter
206- no dot (.) at the end
207β
208### Body
209β
210Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.
211β
212### Footer
213β
214The footer should contain any information about **Breaking Changes** and is also the place to [reference GitHub issues that this commit closes](https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue).
215β
216**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
217β
218### Example
219β
220Here is an example of the release type that will be done based on a commit messages:
221β
222| Commit message | Release type |
223| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
224| fix(pencil): stop graphite breaking when too much pressure applied | Patch Release |
225| feat(pencil): add `graphiteWidth` option | ~~Minor~~ Feature Release |
226| perf(pencil): remove `graphiteWidth` option<br/><br/>BREAKING CHANGE: The `graphiteWidth` option has been removed.<br/>The default graphite width of 10mm is always used for performance reasons. | ~~Major~~ Breaking Release |
227β
228### Revert
229β
230If the commit reverts a previous commit, it should begin with `revert:`, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
231β
232## Pull requests
233β
234Maintainers merge pull requests by squashing all commits and editing the commit message if necessary using the GitHub user interface.
235β
236Use an appropriate commit type. Be especially careful with breaking changes.
237β
238## Releases
239β
240For each new commit added to `main` with `git push` or by merging a pull request or merging from another branch, a GitHub action is triggered and runs the `semantic-release` command to make a release if there are codebase changes since the last release that affect the package functionalities.
241β
242## π§ͺ Test
243β
244TanStack Query uses [Nx](https://nx.dev/) as its monorepo tool.
245To run tests in a local environment, you should use `nx` commands from the root directory.
246β
247### β
Run all tests
248β
249To run tests for **all packages**, run:
250β
251```bash
252npm run test
253```
254β
255### β
Run tests for a specific package
256β
257To run tests for a specific package, use the following command:
258β
259```bash
260npx nx run @tanstack/{package-name}:test:lib
261```
262β
263For example:
264β
265```bash
266npx nx run @tanstack/react-query:test:lib
267```
268β
269### β οΈ Caution
270β
271Do not run `pnpm run test:lib` inside individual package folders.
272This can cause test failures due to dependencies between packages.
273Always run tests from the **root folder** using `nx` commands.