Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/config/resolve-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ const getExplorerMemoized = mem(opts => {
/** @param {{ cache: boolean, sync: boolean }} opts */
function getLoadFunction(opts) {
// Normalize opts before passing to a memoized function
opts = Object.assign({ sync: false, cache: false }, opts);
opts = { sync: false, cache: false, ...opts };
return getExplorerMemoized(opts).load;
}

function _resolveConfig(filePath, opts, sync) {
opts = Object.assign({ useCache: true }, opts);
opts = { useCache: true, ...opts };
const loadOpts = {
cache: !!opts.useCache,
sync: !!sync,
Expand All @@ -74,11 +74,10 @@ function _resolveConfig(filePath, opts, sync) {
const arr = [load, loadEditorConfig].map(l => l(filePath, opts.config));

const unwrapAndMerge = ([result, editorConfigured]) => {
const merged = Object.assign(
{},
editorConfigured,
mergeOverrides(Object.assign({}, result), filePath)
);
const merged = {
...editorConfigured,
...mergeOverrides({ ...result }, filePath)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
...mergeOverrides({ ...result }, filePath)
...mergeOverrides(result, filePath)

mergeOverrides doesn't modify this argument.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

};

["plugins", "pluginSearchDirs"].forEach(optionName => {
if (Array.isArray(merged[optionName])) {
Expand Down Expand Up @@ -126,13 +125,13 @@ resolveConfigFile.sync = filePath => {
};

function mergeOverrides(configResult, filePath) {
const options = Object.assign({}, configResult.config);
if (filePath && options.overrides) {
const { overrides, ...options } = { ...configResult.config };
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice: little refactor here.

if (filePath && overrides) {
const relativeFilePath = path.relative(
path.dirname(configResult.filepath),
filePath
);
for (const override of options.overrides) {
for (const override of overrides) {
if (
pathMatchesGlobs(
relativeFilePath,
Expand All @@ -145,7 +144,6 @@ function mergeOverrides(configResult, filePath) {
}
}

delete options.overrides;
return options;
}

Expand Down