Skip to content

Commit

Permalink
fix: remove no longer needed function
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Jan 10, 2021
1 parent 786e400 commit 6f00690
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions @commitlint/resolve-extends/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ export interface ResolveExtendsContext {
require?<T>(id: string): T;
}

function mergeStrategy(objValue: unknown, srcValue: unknown, key: string) {
if (key === 'parserPreset') {
if (typeof srcValue !== 'object') {
return objValue;
}
} else if (key === 'rules') {
if (typeof objValue !== 'object') {
return srcValue;
}
} else if (key === 'plugins') {
if (!Array.isArray(objValue)) {
return srcValue;
}
} else if (Array.isArray(objValue)) {
return srcValue;
}
}

export default function resolveExtends(
config: ResolveExtendsConfig = {},
context: ResolveExtendsContext = {}
Expand All @@ -52,7 +34,24 @@ export default function resolveExtends(
const extended = loadExtends(config, context);
extended.push(config);
return extended.reduce(
(r, {extends: _, ...c}) => mergeWith(r, c, mergeStrategy),
(r, {extends: _, ...c}) =>
mergeWith(r, c, (objValue, srcValue, key) => {
if (key === 'parserPreset') {
if (typeof srcValue !== 'object') {
return objValue;
}
} else if (key === 'rules') {
if (typeof objValue !== 'object') {
return srcValue;
}
} else if (key === 'plugins') {
if (!Array.isArray(objValue)) {
return srcValue;
}
} else if (Array.isArray(objValue)) {
return srcValue;
}
}),
e ? {extends: e} : {}
);
}
Expand Down

0 comments on commit 6f00690

Please sign in to comment.