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

# lint

`rs lint` 命令使用 [Rslint](https://rslint.rs/guide/) 检查源代码。

## 用法 \{#usage}

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

该命令会加载通过 [`define.lint()`](/zh/guide/configuration.md#define-lint) 注册的代码检查配置。

## 选项 \{#options}

`rs lint` 支持与 Rslint 相同的命令行选项，具体说明请参见 [Rslint CLI 文档](https://rslint.rs/guide/cli)。

示例：

```bash
# 检查指定目录
rs lint src

# 自动修复问题
rs lint --fix

# 检查代码并运行 TypeScript 类型检查
rs lint --type-check
```

## 配置 \{#configuration}

在 [Rstack 配置文件](/zh/guide/configuration.md#configuration-file)中通过 [`define.lint()`](/zh/guide/configuration.md#define-lint) 配置代码检查。该 API 支持标准的 [Rslint 配置](https://rslint.rs/config/)。配置函数会接收 `rstack/lint` 的全部导出，因此无需手动导入预设和插件：

```ts title="rstack.config.ts"
import { define } from 'rstack';

define.lint(({ js, ts }) => [
  js.configs.recommended,
  ts.configs.recommendedTypeChecked,
]);
```

## 类型感知检查 \{#typed-linting}

`ts.configs.recommendedTypeChecked` 等类型感知预设只对 `tsconfig.json` 包含的文件生效。在 Monorepo 中，可以通过 Rslint 的 [`parserOptions.project`](https://rslint.rs/config/language-options#languageoptionsparseroptionsproject) 列出各个子项目的 `tsconfig.json`。示例请参考[根配置](/zh/guide/monorepo.md#root-configuration)。
