From a3c2649a684829899ddb49ce76849df43944927e Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 14 Aug 2026 10:27:45 +0800 Subject: [PATCH] docs: simplify lint configuration examples Co-authored-by: swwind --- website/docs/en/guide/cli/lint.mdx | 8 ++----- website/docs/en/guide/configuration.mdx | 8 ++----- website/docs/en/guide/monorepo.mdx | 28 +++++++++---------------- website/docs/zh/guide/cli/lint.mdx | 8 ++----- website/docs/zh/guide/configuration.mdx | 8 ++----- website/docs/zh/guide/monorepo.mdx | 28 +++++++++---------------- 6 files changed, 28 insertions(+), 60 deletions(-) diff --git a/website/docs/en/guide/cli/lint.mdx b/website/docs/en/guide/cli/lint.mdx index 07b15922..e007abb3 100644 --- a/website/docs/en/guide/cli/lint.mdx +++ b/website/docs/en/guide/cli/lint.mdx @@ -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]); ``` diff --git a/website/docs/en/guide/configuration.mdx b/website/docs/en/guide/configuration.mdx index 55288bbd..49d110f6 100644 --- a/website/docs/en/guide/configuration.mdx +++ b/website/docs/en/guide/configuration.mdx @@ -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} diff --git a/website/docs/en/guide/monorepo.mdx b/website/docs/en/guide/monorepo.mdx index 3ca08420..152b8ddc 100644 --- a/website/docs/en/guide/monorepo.mdx +++ b/website/docs/en/guide/monorepo.mdx @@ -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, @@ -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 diff --git a/website/docs/zh/guide/cli/lint.mdx b/website/docs/zh/guide/cli/lint.mdx index 658ddb8a..48011c5e 100644 --- a/website/docs/zh/guide/cli/lint.mdx +++ b/website/docs/zh/guide/cli/lint.mdx @@ -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]); ``` diff --git a/website/docs/zh/guide/configuration.mdx b/website/docs/zh/guide/configuration.mdx index 4e4e51dc..4f370874 100644 --- a/website/docs/zh/guide/configuration.mdx +++ b/website/docs/zh/guide/configuration.mdx @@ -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} diff --git a/website/docs/zh/guide/monorepo.mdx b/website/docs/zh/guide/monorepo.mdx index 4d780a3b..ae93fee3 100644 --- a/website/docs/zh/guide/monorepo.mdx +++ b/website/docs/zh/guide/monorepo.mdx @@ -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, @@ -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}