Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

CONTRIBUTING.md

273 lines10.4 KB

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:
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[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](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.