You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3512b5d
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: website/docs/en/guide/formatting.mdx
+31-5Lines changed: 31 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,19 +193,45 @@ define.fmt({
193
193
194
194
## Cache
195
195
196
-
`rs fmt`uses a persistent cache by default for file-based `--write`, `--check`, and `--list-different` runs. Formatting results use file content and final formatting options, so changing either causes the file to be formatted again. Unsupported parser lookups normally use the file path and final options. For filenames without an extension, they also use file content because Prettier may infer a parser from the shebang. Installed Prettier plugins are identified by their package name, version, and entry point; local, linked, or unversioned plugins bypass the cache.
196
+
`rs fmt`caches results by default to speed up repeated runs on unchanged files. The cache is shared by `--write`, `--check`, and `--list-different`.
197
197
198
-
The default cache directory is `.rstack/cache/fmt` under the Rstack configuration root. When a command runs from a subdirectory, it continues to use the cache next to the resolved `rstack.config.*` file. Stdin formatting does not use this cache.
198
+
### Cache behavior
199
199
200
-
Use [`--cache-location <path>`](./cli/fmt#--cache-location-path) to store the cache in a different directory. Relative paths are resolved from the current working directory. Custom directories are excluded from file discovery but are not automatically ignored by Git.
200
+
Cached results are reused when the file content and formatting options are unchanged. The cache also accounts for Rstack and Prettier versions, as well as the package name, version, and entry point of installed Prettier plugins. Changes to any of these cause the file to be processed again.
201
201
202
-
Use [`--no-cache`](./cli/fmt#--no-cache) to run without reading, creating, or updating the cache:
202
+
The cache is stored in `.rstack/cache/fmt` under the Rstack configuration root. Running from a subdirectory uses the same cache as long as the command resolves to the same `rstack.config.*` file.
203
+
204
+
### CLI options
205
+
206
+
Use [`--no-cache`](./cli/fmt#--no-cache) to disable the cache for the current run. Existing cache files are left unchanged:
203
207
204
208
```bash
205
209
rs fmt --no-cache
206
210
```
207
211
208
-
You can safely delete `.rstack/cache` to clear cached results. Do not treat the entire `.rstack` directory as disposable because it may also contain user-maintained Git hook scripts.
212
+
Use [`--cache-location <path>`](./cli/fmt#--cache-location-path) to choose a different cache directory. Relative paths are resolved from the current working directory:
213
+
214
+
```bash
215
+
rs fmt --cache-location .cache/rs-fmt
216
+
```
217
+
218
+
The custom directory is excluded from formatting. Add it to `.gitignore` if you do not want to commit it.
219
+
220
+
### Cache exceptions
221
+
222
+
`rs fmt` bypasses the persistent cache in the following cases:
223
+
224
+
- Input comes from stdin or an editor buffer through `--lsp`.
225
+
- A file uses a local or linked Prettier plugin, or a plugin without package version information.
226
+
- A file uses `prettier-plugin-tailwindcss`. Its class sorting can depend on external stylesheets and configuration files that the cache does not track.
227
+
228
+
If you enable these plugins only for specific files through `overrides`, only those files bypass the cache. Other files can still use it.
229
+
230
+
### Clearing the cache
231
+
232
+
To clear the formatting cache, delete `.rstack/cache/fmt` or the directory specified by `--cache-location`. `rs fmt` recreates the cache as needed.
233
+
234
+
Keep the rest of `.rstack`: it may contain Git hook scripts maintained by your project.
0 commit comments