Permalink
Browse files

Fix: Remove duplicate values when extending config

Use only unique values for `formatters` and `parsers` when calculating
the final configuration of an `extends`.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Fix #1273
Close #1276
  • Loading branch information...
molant authored and alrra committed Aug 28, 2018
1 parent e3bd336 commit ea3ae22f24d06693f0429232f7b35c1d199e763f
Showing with 12 additions and 2 deletions.
  1. +10 −1 packages/hint/src/lib/config.ts
  2. +2 −1 packages/hint/tests/lib/config.ts
@@ -88,7 +88,16 @@ const composeConfig = (userConfig: UserConfig) => {
return composeConfig(loadedConfiguration);
});
const finalConfig = merge({}, ...configurations, userConfig);
const finalConfig: UserConfig = merge({}, ...configurations, userConfig);
// Otherwise the output could be double or we could trigger double events
if (finalConfig.formatters) {
finalConfig.formatters = Array.from(new Set(finalConfig.formatters));
}
if (finalConfig.parsers) {
finalConfig.parsers = Array.from(new Set(finalConfig.parsers));
}
return finalConfig;
};
@@ -212,10 +212,11 @@ test.serial(`if the configuration file contains an extends property, it should c
sandbox.stub(resourceLoader, 'loadConfiguration').returns(exts);
const configuration = config.Configuration.fromFilePath(path.join(__dirname, './fixtures/valid/withextends.json'), { watch: false } as CLIOptions);
const configuration: UserConfig = config.Configuration.fromFilePath(path.join(__dirname, './fixtures/valid/withextends.json'), { watch: false } as CLIOptions);
t.is((configuration.connector as ConnectorConfig).name, 'chrome');
t.is(configuration.hints['disallowed-headers'], 'error');
t.is(configuration.formatters.length, 1);
});

0 comments on commit ea3ae22

Please sign in to comment.