Permalink
Browse files

Fix: Issue with `summary` formatter always being used

Fix #1273
Close #1290
  • Loading branch information...
sarvaje authored and alrra committed Sep 5, 2018
1 parent 5cbcb70 commit 43a06a9c1f8dee62f6261e085217c941fa3d853c
@@ -45,3 +45,13 @@ the `summary` formatter:
"formatters": ["summary"]
}
```
Notes:
* If you define the property `formatters` when extending
a configuration, the formatters in the configuration will be
replaced with the value you have defined.
* If you define the property `parsers` when extending a
configuration, the parsers in the configuration will be appended
to the values you have defined.
@@ -18,7 +18,7 @@ import * as os from 'os';
import * as path from 'path';
import * as browserslist from 'browserslist';
import { merge } from 'lodash';
import { mergeWith } from 'lodash';
import { UserConfig, IgnoredUrl, CLIOptions, ConnectorConfig, HintsConfigObject } from './types';
import { debug as d } from './utils/debug';
@@ -88,13 +88,19 @@ const composeConfig = (userConfig: UserConfig) => {
return composeConfig(loadedConfiguration);
});
const finalConfig: UserConfig = merge({}, ...configurations, userConfig);
const finalConfig: UserConfig = mergeWith({}, ...configurations, userConfig, (objValue, srcValue) => {
// Arrays need to be concatented, not merged.
if (Array.isArray(objValue) && Array.isArray(srcValue)) {
return objValue.concat(srcValue);
}
// Otherwise the output could be double or we could trigger double events
if (finalConfig.formatters) {
finalConfig.formatters = Array.from(new Set(finalConfig.formatters));
}
return void 0;
});
// The formatters defined by the user has to overwritte the one in the extends.
finalConfig.formatters = userConfig.formatters ? userConfig.formatters : finalConfig.formatters;
// Otherwise the output could be double or we could trigger double events
if (finalConfig.parsers) {
finalConfig.parsers = Array.from(new Set(finalConfig.parsers));
}
@@ -217,6 +217,7 @@ test.serial(`if the configuration file contains an extends property, it should c
t.is((configuration.connector as ConnectorConfig).name, 'chrome');
t.is(configuration.hints['disallowed-headers'], 'error');
t.is(configuration.formatters.length, 1);
t.is(configuration.parsers.length, 2);
});
@@ -10,6 +10,9 @@
"formatters": [
"json"
],
"parsers": [
"javascript"
],
"hints": {
"disallowed-headers": ["warning", {}],
"manifest-exists": "warning",
@@ -11,6 +11,9 @@
"formatters": [
"json"
],
"parsers": [
"typescript"
],
"hints": {
"disallowed-headers": "error"
}

0 comments on commit 43a06a9

Please sign in to comment.