> For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt.

# check

`rs check` 命令可统一运行当前项目的 lint、格式和可选的 TypeScript 类型检查。默认情况下，它会先运行 [`rs lint`](/zh/guide/cli/lint.md)，再运行 [`rs fmt --check`](/zh/guide/cli/fmt.md#--check)。

## 用法 \{#usage}

```bash
rs check [options] [files...]
```

传入文件或目录，可以将 lint 和格式检查都限制在这些路径中：

```bash
rs check src/index.ts packages/utils
```

相同的文件参数会同时传给两个命令，因此上述示例等同于：

```bash
rs lint src/index.ts packages/utils && rs fmt --check src/index.ts packages/utils
```

## 检查内容 \{#checks}

运行 `rs check` 等同于：

```bash
rs lint && rs fmt --check
```

各项检查会按顺序运行。如果 lint 失败，`rs check` 会停止运行，不再检查格式。只有所有已启用的检查均通过时，该命令才会成功退出。

## 选项 \{#options}

### `--fix`

自动修复 lint 和格式问题：

```bash
rs check --fix
```

该命令等同于：

```bash
rs lint --fix && rs fmt --write
```

如果应用可用的修复后 lint 仍然失败，`rs check` 会停止运行，不再执行格式化。

### `--type-check`

在 lint 过程中启用 TypeScript 类型检查：

```bash
rs check --type-check
```

该命令等同于：

```bash
rs lint --type-check && rs fmt --check
```

省略此选项时，不会运行类型检查。

### `-h, --help`

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

```bash
rs check --help
```

## 配置 \{#configuration}

`rs check` 没有独立的 `define.check()` 配置。它会使用 [`define.lint()`](/zh/guide/configuration.md#define-lint) 中的 lint 配置，以及 [`define.fmt()`](/zh/guide/configuration.md#define-fmt) 中的格式化配置。
