From 2ec7a4f5f07f585b52a9670c4a6bc64536475cc8 Mon Sep 17 00:00:00 2001 From: JounQin Date: Mon, 20 Nov 2023 20:11:18 +0000 Subject: [PATCH] fix: wrong nested `package.json` could be resolved close #741 --- lib/options-manager.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/options-manager.js b/lib/options-manager.js index 6feb6ec7..1bc0b47d 100644 --- a/lib/options-manager.js +++ b/lib/options-manager.js @@ -108,7 +108,13 @@ const mergeWithFileConfig = async options => { } const searchPath = options.filePath || options.cwd; - const {config: xoOptions, filepath: xoConfigPath} = (await configExplorer.search(searchPath)) || {}; + let {config: xoOptions, filepath: xoConfigPath} = (await configExplorer.search(searchPath)) || {}; + + // Wrong nested `package.json` resolved + if (!xoOptions && xoConfigPath) { + ({config: xoOptions, filepath: xoConfigPath} = (await configExplorer.search(path.resolve(xoConfigPath, '../..'))) || {}); + } + const {config: enginesOptions} = (await pkgConfigExplorer.search(searchPath)) || {}; options = normalizeOptions({