diff --git a/lib/config.js b/lib/config.js index 3c91217d..b80422ef 100644 --- a/lib/config.js +++ b/lib/config.js @@ -25,9 +25,21 @@ export function getMergedConfig(dir, home, additional) { const globalConfig = getConfig(GLOBAL_CONFIG, home); const projectConfig = getConfig(PROJECT_CONFIG, dir); const localConfig = getConfig(LOCAL_CONFIG, dir); - mergedConfig = Object.assign(globalConfig, projectConfig, localConfig, additional); + + // Using property descriptors to avoid calling any setter if e.g. a + // localConfig value overrides a globalConfig key. + mergedConfig = Object.create(null, { + ...Object.getOwnPropertyDescriptors(globalConfig), + ...Object.getOwnPropertyDescriptors(projectConfig), + ...Object.getOwnPropertyDescriptors(localConfig), + }); } - return mergedConfig; + return additional + ? Object.create(null, { + ...Object.getOwnPropertyDescriptors(mergedConfig), + ...Object.getOwnPropertyDescriptors(additional), + }) + : mergedConfig; }; export function clearCachedConfig() { mergedConfig = null;