Skip to content

Commit 9c6922e

Browse files
fix: pass resolved config to staged scan to preserve ancestor inheritance
The staged scan materializes files to /tmp, where loadConfig's ancestor traversal would never find a monorepo root's config. Now the CLI resolves config from the real project directory first and passes it via the new configOverride ScanOption, so customRulesOnly, share, ignore rules, and textComponents all apply correctly during --staged scans. Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
1 parent 8bf8d44 commit 9c6922e

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

packages/react-doctor/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ const program = new Command()
195195
const scanResult = await scan(snapshot.tempDirectory, {
196196
...scanOptions,
197197
includePaths: snapshot.stagedFiles,
198+
configOverride: userConfig,
198199
});
199200

200201
const remappedDiagnostics = scanResult.diagnostics.map((diagnostic) => ({

packages/react-doctor/src/scan.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ export const scan = async (
469469
): Promise<ScanResult> => {
470470
const startTime = performance.now();
471471
const projectInfo = discoverProject(directory);
472-
const userConfig = loadConfig(directory);
472+
const userConfig =
473+
inputOptions.configOverride !== undefined ? inputOptions.configOverride : loadConfig(directory);
473474
const options = mergeScanOptions(inputOptions, userConfig);
474475
const { includePaths } = options;
475476
const isDiffMode = includePaths.length > 0;

packages/react-doctor/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export interface ScanOptions {
106106
scoreOnly?: boolean;
107107
offline?: boolean;
108108
includePaths?: string[];
109+
configOverride?: ReactDoctorConfig | null;
109110
}
110111

111112
export interface DiffInfo {

0 commit comments

Comments
 (0)