Skip to content

Commit e34541f

Browse files
authored
docs(fmt): document clearing the cache (#635)
1 parent 1ff9ea0 commit e34541f

4 files changed

Lines changed: 50 additions & 6 deletions

File tree

‎website/docs/en/guide/cli/fmt.mdx‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,23 @@ rs fmt --cache-location .cache/rs-fmt
163163

164164
Relative paths are resolved from the current working directory, while absolute paths are used as-is. The directory is created as needed and excluded from file discovery. Unlike the default cache location, a custom directory does not receive an automatic `.gitignore`; exclude it from version control or manage it through your CI cache configuration.
165165

166-
When both options are provided, `--no-cache` takes precedence and the custom directory is not excluded from file discovery.
166+
If you also pass `--no-cache`, `--cache-location` is ignored and the directory follows the normal file discovery rules.
167+
168+
### `--clear-cache`
169+
170+
Clear the formatting cache and exit without formatting or checking files:
171+
172+
```bash
173+
rs fmt --clear-cache
174+
```
175+
176+
The command removes only the cache file, preserving the directory and other files. The default cache location is `.rstack/cache/fmt` under the Rstack configuration root. Use `--cache-location` to specify a custom cache directory:
177+
178+
```bash
179+
rs fmt --clear-cache --cache-location .cache/rs-fmt
180+
```
181+
182+
`--clear-cache` only clears the cache; it does not accept file arguments or other mode options.
167183

168184
### `--no-error-on-unmatched-pattern`
169185

‎website/docs/en/guide/formatting.mdx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,15 @@ If you enable these plugins only for specific files through `overrides`, only th
229229

230230
### Clearing the cache
231231

232-
To clear the formatting cache, delete `.rstack/cache/fmt` or the directory specified by `--cache-location`. `rs fmt` recreates the cache as needed.
232+
To clear the formatting cache, run:
233233

234-
Keep the rest of `.rstack`: it may contain Git hook scripts maintained by your project.
234+
```bash
235+
rs fmt --clear-cache
236+
```
237+
238+
If you use a custom cache directory, include `--cache-location <path>`.
239+
240+
The command deletes only the cache file, then exits without formatting files. See [`--clear-cache`](./cli/fmt#--clear-cache) for details.
235241

236242
## Prettier plugins
237243

‎website/docs/zh/guide/cli/fmt.mdx‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,23 @@ rs fmt --cache-location .cache/rs-fmt
163163

164164
相对路径基于当前工作目录解析,绝对路径则原样使用。目录会在需要时自动创建,并从文件发现中排除。与默认缓存位置不同,自定义目录不会自动生成 `.gitignore`;请将其排除在版本控制之外,或通过 CI 缓存配置进行管理。
165165

166-
同时使用两个选项时,优先使用 `--no-cache`,且不会从文件发现中排除自定义目录。
166+
如果同时传入 `--no-cache`,`--cache-location` 会被忽略,该目录将按正常的文件发现规则处理。
167+
168+
### `--clear-cache`
169+
170+
清理格式化缓存后退出,不执行格式化或格式检查:
171+
172+
```bash
173+
rs fmt --clear-cache
174+
```
175+
176+
命令只删除缓存文件,保留目录和其他文件。默认缓存位于 Rstack 配置根目录下的 `.rstack/cache/fmt`,也可以通过 `--cache-location` 指定自定义缓存目录:
177+
178+
```bash
179+
rs fmt --clear-cache --cache-location .cache/rs-fmt
180+
```
181+
182+
`--clear-cache` 仅用于清理缓存,不接受文件参数或其他运行模式选项。
167183

168184
### `--no-error-on-unmatched-pattern`
169185

‎website/docs/zh/guide/formatting.mdx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,15 @@ rs fmt --cache-location .cache/rs-fmt
229229

230230
### 清理缓存 \{#clearing-the-cache}
231231

232-
删除 `.rstack/cache/fmt` 或通过 `--cache-location` 指定的目录,即可清理格式化缓存。`rs fmt` 会在需要时重新生成缓存。
232+
运行以下命令可以清理格式化缓存:
233233

234-
请保留 `.rstack` 中的其他内容,其中可能包含项目维护的 Git hook 脚本。
234+
```bash
235+
rs fmt --clear-cache
236+
```
237+
238+
如果使用了自定义缓存目录,同时传入 `--cache-location <path>` 即可。
239+
240+
命令只删除缓存文件,随后退出,不执行格式化。更多用法见 [`--clear-cache`](./cli/fmt#--clear-cache)。
235241

236242
## Prettier 插件 \{#prettier-plugins}
237243

0 commit comments

Comments
 (0)