Skip to content

Commit c197edd

Browse files
authored
docs: document check command (#308)
1 parent 45aaafd commit c197edd

9 files changed

Lines changed: 139 additions & 18 deletions

File tree

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ Rstack CLI brings the Rstack toolchain together for JavaScript development, with
1212

1313
It also covers local development needs outside Rstack's scope, with Prettier formatting and lint-staged commands.
1414

15-
| Command | Description | Powered by |
16-
| ------------ | -------------------------------- | ------------------------------------------------------------------------------------------------- |
17-
| `rs dev` | Run the app dev server | [Rsbuild](https://github.com/web-infra-dev/rsbuild) |
18-
| `rs build` | Build the app for production | [Rsbuild](https://github.com/web-infra-dev/rsbuild) |
19-
| `rs preview` | Preview the app production build | [Rsbuild](https://github.com/web-infra-dev/rsbuild) |
20-
| `rs test` | Run tests | [Rstest](https://github.com/web-infra-dev/rstest) |
21-
| `rs lint` | Lint code | [Rslint](https://github.com/web-infra-dev/rslint) |
22-
| `rs lib` | Build library | [Rslib](https://github.com/web-infra-dev/rslib) |
23-
| `rs doc` | Serve or build docs | [Rspress](https://github.com/web-infra-dev/rspress) |
24-
| `rs fmt` | Format code | [Prettier](https://github.com/prettier/prettier) + [Yuku](https://github.com/yuku-toolchain/yuku) |
25-
| `rs setup` | Install Git hooks | - |
26-
| `rs staged` | Run tasks on staged Git files | [lint-staged](https://github.com/lint-staged/lint-staged) |
15+
| Command | Description |
16+
| --------------------------------------------------- | -------------------------------- |
17+
| [`rs dev`](https://rstack.rs/guide/cli/dev) | Run the app dev server |
18+
| [`rs build`](https://rstack.rs/guide/cli/build) | Build the app for production |
19+
| [`rs preview`](https://rstack.rs/guide/cli/preview) | Preview the app production build |
20+
| [`rs test`](https://rstack.rs/guide/cli/test) | Run tests |
21+
| [`rs lint`](https://rstack.rs/guide/cli/lint) | Lint code |
22+
| [`rs fmt`](https://rstack.rs/guide/cli/fmt) | Format code |
23+
| [`rs check`](https://rstack.rs/guide/cli/check) | Run static checks |
24+
| [`rs lib`](https://rstack.rs/guide/cli/lib) | Build library |
25+
| [`rs doc`](https://rstack.rs/guide/cli/doc) | Serve or build docs |
26+
| [`rs setup`](https://rstack.rs/guide/cli/setup) | Install Git hooks |
27+
| [`rs staged`](https://rstack.rs/guide/cli/staged) | Run tasks on staged Git files |
2728

2829
Rstack CLI fits into your existing project workflow. It does not replace your runtime, package manager, or task runner, such as [pnpm](https://github.com/pnpm/pnpm), [Bun](https://github.com/oven-sh/bun), [Turborepo](https://github.com/vercel/turborepo), [Nx](https://github.com/nrwl/nx), and [Nub](https://github.com/nubjs/nub).
2930

@@ -57,6 +58,7 @@ bun add -d rstack
5758
"build": "rs build",
5859
"preview": "rs preview",
5960
"test": "rs test",
61+
"check": "rs check --type-check",
6062
"lint": "rs lint",
6163
"lib": "rs lib",
6264
"doc": "rs doc",
@@ -73,6 +75,7 @@ pnpm dev
7375
pnpm build
7476
pnpm preview
7577
pnpm test
78+
pnpm check
7679
pnpm lint
7780
pnpm lib
7881
pnpm doc
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["dev", "build", "preview", "lib", "doc", "test", "lint", "fmt", "setup", "staged"]
1+
["dev", "build", "preview", "lib", "doc", "test", "check", "lint", "fmt", "setup", "staged"]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
description: 'Run linting and formatting checks together, with optional TypeScript type checking.'
3+
---
4+
5+
# check
6+
7+
The `rs check` command combines linting, formatting, and optional TypeScript type checking for the current project. By default, it runs [`rs lint`](./lint) followed by [`rs fmt --check`](./fmt#--check).
8+
9+
## Usage
10+
11+
```bash
12+
rs check [options]
13+
```
14+
15+
## Checks
16+
17+
Running `rs check` is equivalent to:
18+
19+
```bash
20+
rs lint && rs fmt --check
21+
```
22+
23+
Checks run sequentially. If linting fails, `rs check` stops without running the formatting check. The command exits successfully only when every enabled check passes.
24+
25+
## Options
26+
27+
### `--type-check`
28+
29+
Enable TypeScript type checking as part of linting:
30+
31+
```bash
32+
rs check --type-check
33+
```
34+
35+
This is equivalent to:
36+
37+
```bash
38+
rs lint --type-check && rs fmt --check
39+
```
40+
41+
Type checking is disabled when this option is omitted.
42+
43+
### `-h, --help`
44+
45+
Display usage and option information without running checks:
46+
47+
```bash
48+
rs check --help
49+
```
50+
51+
## Configuration
52+
53+
`rs check` has no separate `define.check()` configuration. It uses the linting configuration from [`define.lint()`](../configuration#define-lint) and the formatting configuration from [`define.fmt()`](../configuration#define-fmt).

website/docs/en/guide/monorepo.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
description: 'Configure shared Rstack checks, formatting, staged tasks, and project workflows in a monorepo.'
3+
---
4+
15
# Monorepo
26

37
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).
@@ -65,9 +69,9 @@ Expose these tasks through scripts in the root `package.json`:
6569
{
6670
"private": true,
6771
"scripts": {
68-
"lint": "rs lint",
72+
"check": "rs check --type-check",
6973
"format": "rs fmt",
70-
"check:format": "rs fmt --check",
74+
"lint": "rs lint",
7175
"staged": "rs staged"
7276
}
7377
}

website/docs/en/guide/quick-start.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Add the commands your project needs to the `scripts` field in `package.json`. Fo
128128
"build": "rs build",
129129
"preview": "rs preview",
130130
"test": "rs test",
131+
"check": "rs check",
131132
"lint": "rs lint",
132133
"format": "rs fmt"
133134
}
@@ -144,6 +145,7 @@ The following commands are available:
144145
- [`rs lib`](./cli/lib): Build a library with Rslib.
145146
- [`rs doc`](./cli/doc): Develop, build, or preview a documentation site with Rspress.
146147
- [`rs test`](./cli/test): Run tests with Rstest.
148+
- [`rs check`](./cli/check): Run linting and formatting checks, with optional TypeScript type checking.
147149
- [`rs lint`](./cli/lint): Lint source code with Rslint.
148150
- [`rs fmt`](./cli/fmt): Format code.
149151
- [`rs setup`](./cli/setup): Install repository-level Git hooks.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["dev", "build", "preview", "lib", "doc", "test", "lint", "fmt", "setup", "staged"]
1+
["dev", "build", "preview", "lib", "doc", "test", "check", "lint", "fmt", "setup", "staged"]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
description: '同时运行 lint 和格式检查,并可选启用 TypeScript 类型检查。'
3+
---
4+
5+
# check
6+
7+
`rs check` 命令可统一运行当前项目的 lint、格式和可选的 TypeScript 类型检查。默认情况下,它会先运行 [`rs lint`](./lint),再运行 [`rs fmt --check`](./fmt#--check)
8+
9+
## 用法 \{#usage}
10+
11+
```bash
12+
rs check [options]
13+
```
14+
15+
## 检查内容 \{#checks}
16+
17+
运行 `rs check` 等同于:
18+
19+
```bash
20+
rs lint && rs fmt --check
21+
```
22+
23+
各项检查会按顺序运行。如果 lint 失败,`rs check` 会停止运行,不再检查格式。只有所有已启用的检查均通过时,该命令才会成功退出。
24+
25+
## 选项 \{#options}
26+
27+
### `--type-check`
28+
29+
在 lint 过程中启用 TypeScript 类型检查:
30+
31+
```bash
32+
rs check --type-check
33+
```
34+
35+
该命令等同于:
36+
37+
```bash
38+
rs lint --type-check && rs fmt --check
39+
```
40+
41+
省略此选项时,不会运行类型检查。
42+
43+
### `-h, --help`
44+
45+
显示命令用法和选项信息,但不运行检查:
46+
47+
```bash
48+
rs check --help
49+
```
50+
51+
## 配置 \{#configuration}
52+
53+
`rs check` 没有独立的 `define.check()` 配置。它会使用 [`define.lint()`](../configuration#define-lint) 中的 lint 配置,以及 [`define.fmt()`](../configuration#define-fmt) 中的格式化配置。

website/docs/zh/guide/monorepo.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
description: '在 Monorepo 中配置共享的 Rstack 检查、格式化、暂存文件任务和项目工作流。'
3+
---
4+
15
# Monorepo
26

37
本指南介绍如何在 Monorepo 中使用 Rstack CLI,以及如何让它与 [Turborepo](https://turborepo.com/docs)[Nx](https://nx.dev/docs/getting-started/intro) 等任务编排工具协同工作。
@@ -65,9 +69,9 @@ define.staged({
6569
{
6670
"private": true,
6771
"scripts": {
68-
"lint": "rs lint",
72+
"check": "rs check --type-check",
6973
"format": "rs fmt",
70-
"check:format": "rs fmt --check",
74+
"lint": "rs lint",
7175
"staged": "rs staged"
7276
}
7377
}

website/docs/zh/guide/quick-start.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Available templates: app-vanilla, app-vanilla-ts, app-react, app-react-ts, app-p
128128
"build": "rs build",
129129
"preview": "rs preview",
130130
"test": "rs test",
131+
"check": "rs check",
131132
"lint": "rs lint",
132133
"format": "rs fmt"
133134
}
@@ -144,6 +145,7 @@ Rstack 提供以下命令:
144145
- [`rs lib`](./cli/lib):使用 Rslib 构建库。
145146
- [`rs doc`](./cli/doc):使用 Rspress 开发、构建或预览文档站点。
146147
- [`rs test`](./cli/test):使用 Rstest 运行测试。
148+
- [`rs check`](./cli/check):运行 lint 和格式检查,并可选启用 TypeScript 类型检查。
147149
- [`rs lint`](./cli/lint):使用 Rslint 检查源代码。
148150
- [`rs fmt`](./cli/fmt):格式化代码。
149151
- [`rs setup`](./cli/setup):安装仓库级 Git hooks。

0 commit comments

Comments
 (0)