Skip to content

Commit e2f136a

Browse files
committed
docs: add typed linting guidance for monorepos
1 parent 8fc3677 commit e2f136a

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

website/docs/en/guide/cli/lint.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ define.lint(({ js, ts }) => [
3939
ts.configs.recommendedTypeChecked,
4040
]);
4141
```
42+
43+
## Typed linting
44+
45+
Type-aware presets such as `ts.configs.recommendedTypeChecked` apply only to files included by a `tsconfig.json`. In a monorepo, list the project `tsconfig.json` files through Rslint's [`parserOptions.project`](https://rslint.rs/config/language-options#languageoptionsparseroptionsproject). See [Root configuration](../monorepo#root-configuration) for an example.

website/docs/en/guide/monorepo.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ import { define } from 'rstack';
4949
define.lint(({ js, ts }) => [
5050
js.configs.recommended,
5151
ts.configs.recommendedTypeChecked,
52+
{
53+
languageOptions: {
54+
parserOptions: {
55+
project: ['./apps/*/tsconfig.json', './packages/*/tsconfig.json'],
56+
},
57+
},
58+
},
5259
]);
5360

5461
define.fmt({
@@ -62,6 +69,8 @@ define.staged({
6269
});
6370
```
6471

72+
`parserOptions.project` lists the `tsconfig.json` of each project for type-aware presets and `rs check --type-check`. See [Typed linting](./cli/lint#typed-linting).
73+
6574
Expose these tasks through scripts in the root `package.json`:
6675

6776
```json title="package.json"

website/docs/zh/guide/cli/lint.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ define.lint(({ js, ts }) => [
3939
ts.configs.recommendedTypeChecked,
4040
]);
4141
```
42+
43+
## 类型感知检查 \{#typed-linting}
44+
45+
`ts.configs.recommendedTypeChecked` 等类型感知预设只对 `tsconfig.json` 包含的文件生效。在 Monorepo 中,可以通过 Rslint 的 [`parserOptions.project`](https://rslint.rs/config/language-options#languageoptionsparseroptionsproject) 列出各个子项目的 `tsconfig.json`。示例请参考[根配置](../monorepo#root-configuration)

website/docs/zh/guide/monorepo.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ import { define } from 'rstack';
4949
define.lint(({ js, ts }) => [
5050
js.configs.recommended,
5151
ts.configs.recommendedTypeChecked,
52+
{
53+
languageOptions: {
54+
parserOptions: {
55+
project: ['./apps/*/tsconfig.json', './packages/*/tsconfig.json'],
56+
},
57+
},
58+
},
5259
]);
5360

5461
define.fmt({
@@ -62,6 +69,8 @@ define.staged({
6269
});
6370
```
6471

72+
`parserOptions.project` 列出各个子项目的 `tsconfig.json`,供类型感知预设和 `rs check --type-check` 使用。详见[类型感知检查](./cli/lint#typed-linting)
73+
6574
在根目录的 `package.json` 中提供对应脚本:
6675

6776
```json title="package.json"

0 commit comments

Comments
 (0)