@@ -11,6 +11,10 @@ import type { StagedConfig } from './staged.ts';
1111export type RslintConfigDefinition = RslintConfig | ( ( ) => Promise < RslintConfig > ) ;
1212export type RspressConfigDefinition = UserConfig | UserConfigAsyncFn ;
1313
14+ type RslintConfigFactory = (
15+ lint : typeof import ( '@rslint/core' ) ,
16+ ) => RslintConfig | Promise < RslintConfig > ;
17+
1418export type Configs = {
1519 app ?: RsbuildConfigDefinition ;
1620 lib ?: RslibConfigDefinition ;
@@ -125,10 +129,11 @@ type Define = {
125129 * Defines the Rslint config for linting.
126130 *
127131 * This config is used by the `rs lint` command.
132+ * A config factory receives the exports from `rstack/lint`.
128133 *
129134 * @see {@link https://rstack.rs/config | Rstack configuration guide }
130135 */
131- lint : ( config : RslintConfig | ( ( ) => Promise < RslintConfig > ) ) => void ;
136+ lint : ( config : RslintConfig | RslintConfigFactory ) => void ;
132137 /**
133138 * Defines the Prettier config for formatting.
134139 *
@@ -165,7 +170,11 @@ export const define: Define = {
165170 lib : ( config ) => setConfig ( 'lib' , config ) ,
166171 doc : ( config ) => setConfig ( 'doc' , config ) ,
167172 test : ( config ) => setConfig ( 'test' , config ) ,
168- lint : ( config ) => setConfig ( 'lint' , config ) ,
173+ lint : ( config ) =>
174+ setConfig (
175+ 'lint' ,
176+ typeof config === 'function' ? async ( ) => config ( await import ( '@rslint/core' ) ) : config ,
177+ ) ,
169178 fmt : ( config ) => setConfig ( 'fmt' , config ) ,
170179 staged : ( config ) => setConfig ( 'staged' , config ) ,
171180} ;
0 commit comments