Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions website/docs/en/guide/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'Public Rstack APIs, including configuration helpers, tool API re-e

# API reference

Rstack CLI provides a unified configuration API and re-exports the public APIs of Rsbuild, Rslib, Rstest, and Rslint through dedicated subpaths. Prefer these subpaths to direct imports from each tool's core package so that dependency entry points stay unified and APIs match the tool versions integrated by Rstack CLI.
Rstack CLI provides a unified configuration API and re-exports the public APIs of Rsbuild, Rslib, Rstest, and Rslint through the subpaths below. Import from these entry points to use APIs that match the tool versions in Rstack CLI.

## Import paths

Expand Down Expand Up @@ -58,8 +58,6 @@ export const teamConfig: RstackConfig = {

## Re-exports

The tool-specific subpaths below re-export the public APIs from their corresponding core packages. Using these entry points keeps imports unified and APIs aligned with the tool versions integrated by Rstack CLI.

### `rstack/app`

`rstack/app` re-exports all public APIs from `@rsbuild/core`, including APIs for creating and controlling Rsbuild instances.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/guide/cli/check.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rs check --type-check

### `-h, --help`

Display usage and option information without running checks:
Display usage and options:

```bash
rs check --help
Expand Down
12 changes: 7 additions & 5 deletions website/docs/en/guide/cli/fmt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The command uses the following exit codes:

### `-h, --help`

Display usage and option information without formatting files:
Display usage and options:

```bash
rs fmt --help
Expand All @@ -79,7 +79,7 @@ If `config/format.ignore` contains this rule:
generated/**
```

Here, `config/format.ignore` is located relative to the project root. The `generated/**` rule is relative to `config/`. It therefore ignores `config/generated/**` instead of `generated/**` in the project root.
The `generated/**` rule is relative to `config/`, where the ignore file is located. It excludes `config/generated/**`, not `generated/**` in the project root.

Loaded rules apply to scanned paths, explicitly passed files, `--stdin-filepath`, and documents formatted through `--lsp`.

Expand Down Expand Up @@ -133,9 +133,11 @@ Run a language server that formats editor buffers over the [Language Server Prot
rs fmt --lsp
```

The server only advertises document formatting and formats the buffer held by the editor, not the file on disk. Formatting options sent by the editor, such as tab size, are ignored: the Rstack config is the single source of truth. Ignored, unsupported, and unparsable documents produce no edits rather than an error.
The server supports document formatting only and works on the editor's buffer. Formatting rules come from the Rstack config; editor options such as tab size are ignored. Ignored, unsupported, and unparsable documents produce no formatting edits.

The server loads a single config for the workspace root reported by the editor and does not discover nested configs per file; launch one server per config root when a project contains several. The config is loaded on the first formatting request and reused for the lifetime of the server; restart the server after changing it. Besides the global [`--config`](../configuration#configuration-file) option, only [`--ignore-path`](#--ignore-path-path) affects the server. Relative values for both are resolved from the directory the server was launched in.
The server uses the config at the workspace root reported by the editor and does not discover nested configs for individual files. If a project has multiple configs, launch a server for each config root. The server reuses the loaded config, so restart it after changing the config.

Besides the global [`--config`](../configuration#configuration-file) option, only [`--ignore-path`](#--ignore-path-path) affects the server's formatting behavior. Relative paths for both are resolved from the directory where the server was launched.

Register `rs fmt --lsp` as a custom language server in any editor with LSP support to format on demand or on save.

Expand All @@ -161,7 +163,7 @@ Store the persistent cache in a custom directory:
rs fmt --cache-location .cache/rs-fmt
```

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.
Relative paths are resolved from the current working directory. The custom cache directory is excluded from formatting and does not receive an automatic `.gitignore`. Add the directory to `.gitignore` if you do not want to commit the cache to Git.

If you also pass `--no-cache`, `--cache-location` is ignored and the directory follows the normal file discovery rules.

Expand Down
6 changes: 3 additions & 3 deletions website/docs/en/guide/cli/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ When using a custom directory, add the full command to the `prepare` script of t
}
```

> The path must not contain `..`. This prevents hook files from being created or overwritten outside the repository through a parent directory path.
> The path must not contain `..` to prevent creating or overwriting hook files outside the repository.

### `--help`

Expand Down Expand Up @@ -136,7 +136,7 @@ The default directory structure is:
└── ...
```

Files alongside `_` are repository hook scripts. The `_` directory contains generated files and is ignored by Git. `rs hooks` points `core.hooksPath` to `.rstack/hooks/_`.
`rs hooks` points `core.hooksPath` to `.rstack/hooks/_`.

## Supported hooks

Expand Down Expand Up @@ -189,7 +189,7 @@ Use it to initialize a Node.js version manager, update `PATH`, or set `RSTACK_HO

## Ownership safety

Each generated hooks directory records its owning project. Only that project should include `rs hooks` in its `prepare` script. Rstack skips installation from any other project, even with `--force`, and refuses to remove hooks owned by another project.
Each hooks directory is managed by one project. Include `rs hooks` only in that project's `prepare` script. Installation from other projects is skipped, even with `--force`; uninstallation from other projects is rejected.

To transfer ownership:

Expand Down
8 changes: 2 additions & 6 deletions website/docs/en/guide/cli/staged.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ description: 'Run lint-staged tasks against Git-staged files with the rs staged

# staged

The `rs staged` command uses [lint-staged](https://github.com/lint-staged/lint-staged) to run tasks against files staged in Git.

`rs staged` can run linters, formatters, or other checks on staged files before committing code.
`rs staged` uses [lint-staged](https://github.com/lint-staged/lint-staged) to run linters, formatters, or other checks on files staged in Git.

A common pattern is to pair `rs staged` with [`rs hooks`](./hooks) and run staged-file tasks from a `pre-commit` hook.

Expand All @@ -30,9 +28,7 @@ rs staged --allow-empty

### `--concurrent`

`--concurrent` controls how many tasks may run at the same time. It accepts `true`, `false`, or a positive integer.

When the option is omitted, it defaults to `true`, so `rs staged` runs tasks concurrently without a fixed limit. Set it to `false` to run one task at a time, or use a positive integer to limit the number of concurrent tasks.
`--concurrent` controls how many tasks run at once: `true` (the default) allows unlimited concurrency, `false` runs one task at a time, and a positive integer sets the maximum.

```bash
# Use the default: run tasks concurrently without a fixed limit
Expand Down
4 changes: 2 additions & 2 deletions website/docs/en/guide/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ define.fmt({
});
```

The configuration file does not require a default export. Each `define.*()` API can be called at most once; defining the same configuration type more than once throws an error.
The configuration file does not require a default export. Call each `define.*()` API at most once; repeated calls throw an error.

By default, Rstack CLI looks for a file with one of the following names:

Expand All @@ -50,7 +50,7 @@ rs build --config ./configs/rstack.config.ts

## Importing dependencies \{#loading-dependencies-on-demand}

Rstack keeps a project's build, test, lint, formatting, and other settings in one `rstack.config.*` file. When a command loads the config file, it also loads every top-level import, even if it does not use the related configuration. Importing every tool and plugin at the top level can therefore add startup overhead to commands such as `rs lint` and `rs fmt`.
Tools and plugins imported at the top level of `rstack.config.*` are loaded with the config, even if the current command does not use them. This can add startup overhead to commands such as `rs lint` and `rs fmt`.

Choose the import style based on the config contents:

Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/guide/formatting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ The command deletes only the cache file, then exits without formatting files. Se

To add formatting capabilities that are not built into Rstack CLI, install the corresponding [Prettier plugin](https://prettier.io/docs/plugins) and add it to `plugins`. Plugins can be referenced by package name, file path, or URL. Package names and relative paths are resolved from the directory containing the Rstack configuration file.

Because `rs fmt` loads plugins in workers, plugin objects cannot be passed directly. Reference each plugin by package name, path, or URL instead.
Because `rs fmt` loads plugins in workers, plugin objects cannot be passed directly.

For example, install and enable [`prettier-plugin-tailwindcss`](https://github.com/tailwindlabs/prettier-plugin-tailwindcss):

Expand Down
6 changes: 2 additions & 4 deletions website/docs/en/guide/git-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ git config --get core.hooksPath

## Pre-commit checks

A `pre-commit` hook can lint and format the files staged for the current commit.

### Configure tasks

Add staged-file tasks to the Rstack config file. Adjust the glob patterns for the languages used by your project:
Expand All @@ -76,6 +74,6 @@ rs staged

When you run `git commit`, Git invokes the hook installed by `rs hooks`. The hook executes `.rstack/hooks/pre-commit`, and `rs staged` then runs the configured tasks on the staged files.

`rs staged` passes matching staged files to each command. Commands in an array run in order: [`rs lint --fix`](./cli/lint) first applies available fixes, then [`rs fmt`](./cli/fmt) formats the result. Remove `--fix` if lint errors should block the commit without changing files.
`rs staged` passes matching staged files to each command. Commands in an array run in order: [`rs lint --fix`](./cli/lint) first applies available lint fixes, then [`rs fmt`](./cli/fmt) formats the files. Remove `--fix` if you do not want lint issues fixed automatically.

After every task passes, the commit continues and includes the fixed and formatted results. If any task fails, the commit stops; fix the issue and then try again.
If all tasks pass, the commit includes the fixed and formatted results. If any task fails, the commit stops.
2 changes: 0 additions & 2 deletions website/docs/en/guide/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ Once you have reviewed and validated the changes, move on to Rstest:
Use the migrate-to-rstack-cli Skill to migrate Rstest to Rstack CLI, leaving all other tools unchanged.
```

Repeat this process for each remaining tool.

## Supported tools

The Skill can directly migrate the following standalone tools:
Expand Down
4 changes: 1 addition & 3 deletions website/docs/en/guide/monorepo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ description: 'Use Rstack CLI to configure shared checks, formatting, staged task

This guide explains how to use Rstack CLI in a monorepo, including how it works with task orchestrators such as [Turborepo](https://turborepo.com/docs) and [Nx](https://nx.dev/docs/getting-started/intro).

It covers managing the Rstack CLI dependency, configuring lint, formatting, and staged-file tasks at the root, and defining separate configurations for web applications and libraries.

## Project structure

The recommended setup has two levels:
Expand All @@ -29,7 +27,7 @@ The recommended setup has two levels:
└── rstack.config.ts
```

This structure keeps the Rstack CLI version in one place while keeping build and test configuration close to the project that uses it.
This structure centralizes tool versions and check rules while letting each project maintain its own build and test configuration.

## Rstack CLI dependency management \{#rstack-dependency-management}

Expand Down
4 changes: 1 addition & 3 deletions website/docs/en/guide/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: 'Create a Rstack project or add Rstack CLI to an existing project a

import { PackageManagerTabs } from '@rspress/core/theme';

Rstack CLI brings the Rstack toolchain together with one CLI and one configuration file. This guide shows how to create a new Rstack project or add Rstack CLI to an existing project, and introduces the available workflows.
Rstack CLI brings the Rstack toolchain together with one CLI and one configuration file, for both new and existing projects.

## Environment preparation

Expand Down Expand Up @@ -38,8 +38,6 @@ Rstack CLI requires Node.js 20.19.0+ or 22.12.0+.
}}
/>

Follow the prompts to complete the setup.

After creating the project, do the following:

- Run `pnpm install` (or your package manager's install command) to install dependencies.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/guide/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ When both configurations are registered, Rstack CLI gives `define.app()` precede

### Disable automatic inheritance

To keep the test configuration independent, set `extends` explicitly. An empty object disables automatic inheritance without extending another configuration:
Set `extends` to an empty object to prevent tests from inheriting the application or library configuration:

```ts title="rstack.config.ts"
import { define } from 'rstack';
Expand Down
4 changes: 1 addition & 3 deletions website/docs/zh/guide/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: 'Rstack 公共 API,包括配置辅助方法、各工具重新导

# API 参考 \{#api-reference}

Rstack CLI 提供统一的配置 API,并通过专用子路径重导出 Rsbuild、Rslib、Rstest 和 Rslint 的公开 API。建议优先从这些子路径导入,而不是直接从各工具的 core 包导入,以统一依赖入口,并确保 API 与 Rstack CLI 集成的工具版本匹配。
Rstack CLI 提供统一的配置 API,并通过以下子路径重导出 Rsbuild、Rslib、Rstest 和 Rslint 的公开 API。建议从这些入口导入,确保 API 与 Rstack CLI 使用的工具版本一致。

## 导入路径 \{#import-paths}

Expand Down Expand Up @@ -58,8 +58,6 @@ export const teamConfig: RstackConfig = {

## 重导出 \{#re-exports}

以下工具子路径均会重导出对应 core 包的公开 API。通过这些入口导入,可以统一依赖入口,并确保 API 与 Rstack CLI 集成的工具版本匹配。

### `rstack/app`

`rstack/app` 重导出 `@rsbuild/core` 的全部公开 API,包括用于创建和控制 Rsbuild 实例的 API。
Expand Down
2 changes: 1 addition & 1 deletion website/docs/zh/guide/cli/check.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rs check --type-check

### `-h, --help`

显示命令用法和选项信息,但不运行检查:
显示命令用法和选项:

```bash
rs check --help
Expand Down
12 changes: 7 additions & 5 deletions website/docs/zh/guide/cli/fmt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rs fmt --check

### `-h, --help`

显示命令用法和选项信息,但不格式化文件:
显示命令用法和选项:

```bash
rs fmt --help
Expand All @@ -79,7 +79,7 @@ rs fmt --ignore-path config/format.ignore
generated/**
```

这里,`config/format.ignore` 相对项目根目录定位。文件中的 `generated/**` 规则则相对 `config/` 目录解析。因此,它会忽略 `config/generated/**`,而不是项目根目录下的 `generated/**`。
这里的 `generated/**` 相对于 ignore 文件所在的 `config/` 目录,会忽略 `config/generated/**`,而不是项目根目录下的 `generated/**`。

加载的规则会作用于扫描得到的路径、显式传入的文件、`--stdin-filepath`,以及通过 `--lsp` 格式化的文档。

Expand Down Expand Up @@ -133,9 +133,11 @@ rs fmt -l
rs fmt --lsp
```

该 server 只声明 document formatting 一项能力,格式化的是编辑器内存中的 buffer,而不是磁盘上的文件。编辑器传入的格式化选项(如缩进宽度)会被忽略,Rstack 配置是唯一的配置来源。被忽略、无法推断 parser 或解析失败的文件不会返回任何编辑操作,而不是返回错误。
该服务仅支持文档格式化,处理编辑器中的缓冲区内容。格式化规则由 Rstack 配置决定,编辑器传入的缩进宽度等选项不会生效。对于被忽略、不支持或无法解析的文档,服务不返回格式化修改。

server 只为编辑器上报的 workspace root 加载一份配置,不会按文件发现嵌套配置;如果项目包含多份配置,请为每个配置根目录各启动一个 server。配置会在第一次格式化请求时加载,并在 server 的整个生命周期内复用;修改配置后需要重启 server。除全局的 [`--config`](../configuration#configuration-file) 选项外,只有 [`--ignore-path`](#--ignore-path-path) 会影响该 server。两者的相对路径都相对于 server 的启动目录解析。
服务使用编辑器上报的工作区根目录中的配置,不会为每个文件查找嵌套配置。项目包含多份配置时,请为每个配置根目录分别启动服务。服务会复用已加载的配置,因此修改配置后需要重启服务。

除全局的 [`--config`](../configuration#configuration-file) 选项外,只有 [`--ignore-path`](#--ignore-path-path) 会影响服务的格式化行为。两者的相对路径都基于服务启动时的目录解析。

在任何支持 LSP 的编辑器中将 `rs fmt --lsp` 注册为自定义 language server,即可手动或在保存时格式化。

Expand All @@ -161,7 +163,7 @@ rs fmt --no-cache
rs fmt --cache-location .cache/rs-fmt
```

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

如果同时传入 `--no-cache`,`--cache-location` 会被忽略,该目录将按正常的文件发现规则处理。

Expand Down
6 changes: 3 additions & 3 deletions website/docs/zh/guide/cli/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ rs hooks --hooks-dir "config/git hooks"
}
```

> 路径中不能包含 `..`,以免通过父目录路径在仓库之外创建或覆盖 hook 文件。
> 路径中不能包含 `..`,以防在仓库外创建或覆盖 hook 文件。

### `--help`

Expand Down Expand Up @@ -136,7 +136,7 @@ Rstack 会自动定位当前生效的 hooks,并移除 `core.hooksPath` 配置
└── ...
```

与 `_` 同级的文件是仓库 hook 脚本。`_` 目录包含生成文件,并由 Git 忽略。`rs hooks` 会将 `core.hooksPath` 指向 `.rstack/hooks/_`。
`rs hooks` 会将 `core.hooksPath` 指向 `.rstack/hooks/_`。

## 支持的 hooks \{#supported-hooks}

Expand Down Expand Up @@ -189,7 +189,7 @@ ${XDG_CONFIG_HOME:-$HOME/.config}/rstack/hooks-init.sh

## 所有权保护 \{#ownership-safety}

每个生成的 hooks 目录都会记录所属项目。只有该项目应在 `prepare` 脚本中调用 `rs hooks`。其他项目即使使用 `--force` 调用安装命令,也会被跳过;卸载命令同样会拒绝删除其他项目的 hooks。
每个 hooks 目录由一个项目管理,请仅在该项目的 `prepare` 脚本中调用 `rs hooks`。其他项目运行安装命令时会跳过安装,即使传入 `--force` 也不例外;运行卸载命令时则会拒绝删除这组 hooks。

如需转移所有权:

Expand Down
Loading
Loading