Skip to content

Commit 1fb74b4

Browse files
committed
fix: merge resolved config correctly
1 parent 98d11aa commit 1fb74b4

File tree

2 files changed

+7
-46
lines changed

2 files changed

+7
-46
lines changed

@commitlint/cli/src/commands/cmd-lint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async function lint(rawInput, flags) {
3636

3737
// Strip comments if reading from `.git/COMMIT_EDIT_MSG`
3838
if (range.edit) {
39-
loaded.parserOpts.commentChar = '#';
39+
loaded.parserPreset.opts.commentChar = '#';
4040
}
4141

4242
const results = await all(messages, async msg => {

@commitlint/core/src/library/resolve-extends.js

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default async function resolveExtends(config = {}, context = {}) {
2525

2626
// (any, string, string, Function) => any[];
2727
async function loadExtends(config = {}, context = {}) {
28-
return (config.extends || []).reduce(async (configs, raw) => {
28+
return (config.extends || []).reduce(async (accing, raw) => {
2929
const load = context.require || require;
3030
const resolved = resolveConfig(raw, context);
3131
const c = load(resolved);
@@ -52,46 +52,11 @@ async function loadExtends(config = {}, context = {}) {
5252
config.parserPreset = parserPreset;
5353
}
5454

55-
return [...configs, c, ...(await loadExtends(c, ctx))];
55+
const acc = await accing;
56+
acc.push(c);
57+
acc.push(...(await loadExtends(c, ctx)));
58+
return acc;
5659
}, Promise.resolve([]));
57-
58-
/* Return (config.extends || []).reduce((configs, raw) => {
59-
const load = context.require || require;
60-
const resolved = resolveConfig(raw, context);
61-
const c = load(resolved);
62-
const cwd = path.dirname(resolved);
63-
64-
// Remove deprecation warning in version 3
65-
if (typeof c === 'object' && 'wildcards' in c) {
66-
console.warn(
67-
`'wildcards' found in '${raw}' ignored. To silence this warning raise an issue at 'npm repo ${raw}' to remove the wildcards.`
68-
);
69-
}
70-
71-
const ctx = merge({}, context, {cwd});
72-
73-
// Resolve parser preset if none was present before
74-
if (
75-
!context.parserPreset &&
76-
typeof c === 'object' &&
77-
typeof c.parserPreset === 'string'
78-
) {
79-
const resolvedParserPreset = resolveFrom(cwd, c.parserPreset);
80-
81-
const parserPreset = {
82-
name: c.parserPreset,
83-
path: `./${path.relative(process.cwd(), resolvedParserPreset)}`
84-
.split(path.sep)
85-
.join('/'),
86-
opts: require(resolvedParserPreset)
87-
};
88-
89-
ctx.parserPreset = parserPreset;
90-
config.parserPreset = parserPreset;
91-
}
92-
93-
return [...configs, c, ...loadExtends(c, ctx)];
94-
}, []); */
9560
}
9661

9762
function getId(raw = '', prefix = '') {
@@ -111,11 +76,7 @@ function resolveConfig(raw, context = {}) {
11176
const legacy = getId(raw, 'conventional-changelog-lint-config');
11277
const resolved = resolve(legacy, context);
11378
console.warn(
114-
`Resolving ${raw} to legacy config ${
115-
legacy
116-
}. To silence this warning raise an issue at 'npm repo ${
117-
legacy
118-
}' to rename to ${id}.`
79+
`Resolving ${raw} to legacy config ${legacy}. To silence this warning raise an issue at 'npm repo ${legacy}' to rename to ${id}.`
11980
);
12081
return resolved;
12182
}

0 commit comments

Comments
 (0)