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
8 changes: 2 additions & 6 deletions website/docs/en/guide/cli/lint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ rs lint --type-check

## Configuration

Configure linting through [`define.lint()`](../configuration#define-lint) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rslint configuration](https://rslint.rs/config/). Presets and plugins can be imported from `rstack/lint` on demand:
Configure linting through [`define.lint()`](../configuration#define-lint) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rslint configuration](https://rslint.rs/config/). A configuration function receives all exports from `rstack/lint`, so presets and plugins do not need to be imported manually:

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

define.lint(async () => {
const { js, ts } = await import('rstack/lint');

return [js.configs.recommended, ts.configs.recommended];
});
define.lint(({ js, ts }) => [js.configs.recommended, ts.configs.recommendedTypeChecked]);
```
8 changes: 2 additions & 6 deletions website/docs/en/guide/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,12 @@ If the root test configuration does not define `extends` and contains `projects`

### `define.lint()` \{#define-lint}

Defines the [Rslint configuration](https://rslint.rs/config/). Pass the configuration directly, or use an async function to load presets and plugins from `rstack/lint` on demand.
Defines the [Rslint configuration](https://rslint.rs/config/). Pass the configuration directly, or use a synchronous or asynchronous function. The function receives all exports from `rstack/lint`, so presets and plugins do not need to be imported manually.

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

define.lint(async () => {
const { js, ts } = await import('rstack/lint');

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

### `define.fmt()` \{#define-fmt}
Expand Down
28 changes: 10 additions & 18 deletions website/docs/en/guide/monorepo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ Use [`define.lint()`](./configuration#define-lint), [`define.fmt()`](./configura
```ts title="rstack.config.ts"
import { define } from 'rstack';

define.lint(async () => {
const { js, ts } = await import('rstack/lint');

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

define.fmt({
singleQuote: true,
Expand Down Expand Up @@ -86,20 +82,16 @@ If some projects need different lint rules, use [`files`](https://rslint.rs/conf
```ts title="rstack.config.ts"
import { define } from 'rstack';

define.lint(async () => {
const { js, ts } = await import('rstack/lint');

return [
js.configs.recommended,
ts.configs.recommended,
{
files: ['apps/web/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
define.lint(({ js, ts }) => [
js.configs.recommended,
ts.configs.recommendedTypeChecked,
{
files: ['apps/web/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
];
});
},
]);
```

## Project configuration
Expand Down
8 changes: 2 additions & 6 deletions website/docs/zh/guide/cli/lint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ rs lint --type-check

## 配置 \{#configuration}

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

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

define.lint(async () => {
const { js, ts } = await import('rstack/lint');

return [js.configs.recommended, ts.configs.recommended];
});
define.lint(({ js, ts }) => [js.configs.recommended, ts.configs.recommendedTypeChecked]);
```
8 changes: 2 additions & 6 deletions website/docs/zh/guide/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,12 @@ define.test({

### `define.lint()` \{#define-lint}

定义 [Rslint 配置](https://rslint.rs/config/)。可以直接传入配置,也可以使用异步函数,按需从 `rstack/lint` 加载预设和插件
定义 [Rslint 配置](https://rslint.rs/config/)。可以直接传入配置,也可以传入同步或异步函数。函数会接收 `rstack/lint` 的全部导出,因此无需手动导入预设和插件

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

define.lint(async () => {
const { js, ts } = await import('rstack/lint');

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

### `define.fmt()` \{#define-fmt}
Expand Down
28 changes: 10 additions & 18 deletions website/docs/zh/guide/monorepo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ Rsbuild 插件、测试库等项目专属依赖,建议定义在实际使用它
```ts title="rstack.config.ts"
import { define } from 'rstack';

define.lint(async () => {
const { js, ts } = await import('rstack/lint');

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

define.fmt({
singleQuote: true,
Expand Down Expand Up @@ -86,20 +82,16 @@ define.staged({
```ts title="rstack.config.ts"
import { define } from 'rstack';

define.lint(async () => {
const { js, ts } = await import('rstack/lint');

return [
js.configs.recommended,
ts.configs.recommended,
{
files: ['apps/web/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
define.lint(({ js, ts }) => [
js.configs.recommended,
ts.configs.recommendedTypeChecked,
{
files: ['apps/web/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
];
});
},
]);
```

## 子项目配置 \{#project-configuration}
Expand Down