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
16 changes: 12 additions & 4 deletions website/docs/en/guide/monorepo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

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 Rstack dependencies, configuring lint and staged-file tasks at the root, and defining separate configurations for web applications and libraries.
It covers managing Rstack dependencies, 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:

- The root manages the shared Rstack version, lint rules, and staged-file tasks.
- The root manages the shared Rstack version, lint and formatting rules, and staged-file tasks.
- Each application or library has its own [Rstack configuration](./configuration) for build, test, or documentation configuration.

```text
Expand Down Expand Up @@ -37,7 +37,7 @@ Project-specific dependencies, such as Rsbuild plugins and testing libraries, sh

## Root configuration

Use [`define.lint()`](./configuration#define-lint) and [`define.staged()`](./configuration#define-staged) in the root `rstack.config.ts` for checks that apply to the entire repository:
Use [`define.lint()`](./configuration#define-lint), [`define.fmt()`](./configuration#define-fmt), and [`define.staged()`](./configuration#define-staged) in the root `rstack.config.ts` for checks and formatting that apply to the entire repository:

```ts title="rstack.config.ts"
import { define } from 'rstack';
Expand All @@ -48,8 +48,14 @@ define.lint(async () => {
return [js.configs.recommended, ts.configs.recommended];
});

define.fmt({
singleQuote: true,
ignorePatterns: ['**/dist/**'],
});

define.staged({
'*.{js,jsx,ts,tsx,mjs,cjs}': 'rs lint',
'*.{js,jsx,ts,tsx,mjs,cjs}': ['rs lint', 'rs fmt'],
'*.{json,md,mdx,css,html,yml,yaml}': 'rs fmt',
});
```

Expand All @@ -60,6 +66,8 @@ Expose these tasks through scripts in the root `package.json`:
"private": true,
"scripts": {
"lint": "rs lint",
"format": "rs fmt",
"check:format": "rs fmt --check",
"staged": "rs staged"
}
}
Expand Down
16 changes: 12 additions & 4 deletions website/docs/zh/guide/monorepo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

本指南介绍如何在 Monorepo 中使用 Rstack CLI,以及如何让它与 [Turborepo](https://turborepo.com/docs)、[Nx](https://nx.dev/docs/getting-started/intro) 等任务编排工具协同工作。

主要内容包括管理 Rstack 依赖、在根目录统一配置代码检查和暂存文件任务,以及为 Web 应用和库项目定义独立配置。
主要内容包括管理 Rstack 依赖、在根目录统一配置代码检查、格式化和暂存文件任务,以及为 Web 应用和库项目定义独立配置。

## 目录结构 \{#project-structure}

推荐使用两层配置:

- 根目录统一管理 Rstack 版本、lint 规则和暂存文件任务
- 根目录统一管理 Rstack 版本、lint 和格式化规则,以及暂存文件任务
- 每个应用或库使用自己的 [Rstack 配置](./configuration),定义构建、测试或文档配置。

```text
Expand Down Expand Up @@ -37,7 +37,7 @@ Rsbuild 插件、测试库等项目专属依赖,建议定义在实际使用它

## 根配置 \{#root-configuration}

在根目录的 `rstack.config.ts` 中使用 [`define.lint()`](./configuration#define-lint) 和 [`define.staged()`](./configuration#define-staged) 配置适用于整个仓库的检查
在根目录的 `rstack.config.ts` 中使用 [`define.lint()`](./configuration#define-lint)、[`define.fmt()`](./configuration#define-fmt) 和 [`define.staged()`](./configuration#define-staged),配置适用于整个仓库的检查和格式化

```ts title="rstack.config.ts"
import { define } from 'rstack';
Expand All @@ -48,8 +48,14 @@ define.lint(async () => {
return [js.configs.recommended, ts.configs.recommended];
});

define.fmt({
singleQuote: true,
ignorePatterns: ['**/dist/**'],
});

define.staged({
'*.{js,jsx,ts,tsx,mjs,cjs}': 'rs lint',
'*.{js,jsx,ts,tsx,mjs,cjs}': ['rs lint', 'rs fmt'],
'*.{json,md,mdx,css,html,yml,yaml}': 'rs fmt',
});
```

Expand All @@ -60,6 +66,8 @@ define.staged({
"private": true,
"scripts": {
"lint": "rs lint",
"format": "rs fmt",
"check:format": "rs fmt --check",
"staged": "rs staged"
}
}
Expand Down