Skip to content

Commit 3aaf0a6

Browse files
authored
feat: upgrade conventional commit packages #4082 (#4597)
* chore(types): replace @types/conventional-commits-parser with direct dependency * chore(parse): upgrade conventional-commits-parser and angular preset * chore(rules): upgrade conventional-changelog-angular dev dependency * chore(rules): explicitly depend on conventional-commits-parser v6 * fix(parse): update implementation for conventional-commits-parser v6 * fix(parse, rules): align with conventional-changelog-angular v8 structure * fix(core): align with conventional-changelog-angular v8 and parser v6 * refactor(core): clean up debug logging and improve preset compatibility - Remove debug console.error from test utilities - Add parser field to ParserPreset interface for v8 presets - Improve preset override logic to handle nested parser options - Clean up orphaned dependencies in yarn.lock * chore(config-conventional): upgrade conventional-changelog-conventionalcommits to v9 * fix(config-conventional): adapt test for conventionalcommits v9 structure * chore(load): upgrade conventional-changelog-atom to v5 * refactor(core): improve code clarity and error handling per review feedback - Clarify comment for user-provided parser options handling - Add selective error logging in test module resolution (only logs unexpected errors) - Use nullish coalescing to preserve empty string semantics in parsed fields * refactor(test): simplify findParentPath implementation Replace complex reduceRight logic with simpler lastIndexOf + slice approach for improved readability while maintaining identical behavior.
1 parent 88149fb commit 3aaf0a6

19 files changed

Lines changed: 125 additions & 85 deletions

File tree

@commitlint/cli/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
QualifiedConfig,
1515
UserConfig,
1616
} from "@commitlint/types";
17-
import type { Options } from "conventional-commits-parser";
17+
import type { ParserOptions as Options } from "conventional-commits-parser";
1818
import { x } from "tinyexec";
1919
import yargs, { type Arguments } from "yargs";
2020

@commitlint/config-conventional/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"dependencies": {
4242
"@commitlint/types": "^20.3.1",
43-
"conventional-changelog-conventionalcommits": "^7.0.2"
43+
"conventional-changelog-conventionalcommits": "^9.1.0"
4444
},
4545
"gitHead": "e82f05a737626bb69979d14564f5ff601997f679"
4646
}

@commitlint/config-conventional/src/index.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const dynamicImport = async (id: string) => {
1717

1818
const commitLint = async (message: string) => {
1919
const preset = await (await dynamicImport(parserPreset))();
20-
return lint(message, rules, { ...preset });
20+
return lint(message, rules, {
21+
parserOpts: preset.parser || preset.parserOpts,
22+
});
2123
};
2224

2325
const messages = {

@commitlint/load/fixtures/parser-preset-conventional-without-factory/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "parser-preset-conventional-without-factory",
33
"version": "1.0.0",
44
"devDependencies": {
5-
"conventional-changelog-conventionalcommits": "^7.0.2"
5+
"conventional-changelog-conventionalcommits": "^9.1.0"
66
}
77
}

@commitlint/load/fixtures/parser-preset-conventionalcommits/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "parser-preset-conventionalcommits",
33
"version": "1.0.0",
44
"devDependencies": {
5-
"conventional-changelog-conventionalcommits": "^7.0.2"
5+
"conventional-changelog-conventionalcommits": "^9.1.0"
66
}
77
}

@commitlint/load/fixtures/recursive-parser-preset-conventional-atom/first-extended/second-extended/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "@second-extend/recursive-parser-preset-conventional-atom",
33
"version": "1.0.0",
44
"devDependencies": {
5-
"conventional-changelog-atom": "^2.0.3"
5+
"conventional-changelog-atom": "^5.0.0"
66
}
77
}

@commitlint/load/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@commitlint/test": "^20.0.0",
4040
"@types/lodash.mergewith": "^4.6.8",
4141
"@types/node": "^18.19.17",
42-
"conventional-changelog-atom": "^4.0.0",
42+
"conventional-changelog-atom": "^5.0.0",
4343
"typescript": "^5.2.2"
4444
},
4545
"dependencies": {

@commitlint/load/src/utils/load-parser-opts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export async function loadParserOpts(
7171
Promise.resolve(result).then((opts) => {
7272
resolve({
7373
...parser,
74-
parserOpts: opts?.parserOpts,
74+
parserOpts: opts?.parserOpts || opts?.parser,
7575
});
7676
});
7777
}

@commitlint/parse/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@
3737
"license": "MIT",
3838
"devDependencies": {
3939
"@commitlint/test": "^20.0.0",
40-
"@commitlint/utils": "^20.0.0",
41-
"@types/conventional-commits-parser": "^5.0.0"
40+
"@commitlint/utils": "^20.0.0"
4241
},
4342
"dependencies": {
4443
"@commitlint/types": "^20.3.1",
45-
"conventional-changelog-angular": "^7.0.0",
46-
"conventional-commits-parser": "^5.0.0"
44+
"conventional-changelog-angular": "^8.1.0",
45+
"conventional-commits-parser": "^6.2.1"
4746
},
4847
"gitHead": "e82f05a737626bb69979d14564f5ff601997f679"
4948
}

@commitlint/parse/src/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ test("ignores comments", async () => {
146146
// @ts-expect-error -- no typings
147147
const changelogOpts = await import("conventional-changelog-angular");
148148
const opts = {
149-
...changelogOpts.parserOpts,
149+
...changelogOpts.parser,
150150
commentChar: "#",
151151
};
152152
const actual = await parse(message, undefined, opts);
@@ -162,13 +162,13 @@ test("registers inline #", async () => {
162162
// @ts-expect-error -- no typings
163163
const changelogOpts = await import("conventional-changelog-angular");
164164
const opts = {
165-
...changelogOpts.parserOpts,
165+
...changelogOpts.parser,
166166
commentChar: "#",
167167
};
168168
const actual = await parse(message, undefined, opts);
169169

170170
expect(actual.subject).toBe("subject #reference");
171-
expect(actual.body).toBe("things #reference");
171+
expect(actual.body).toBe(null);
172172
});
173173

174174
test("keep -side notes- in the body section", async () => {

0 commit comments

Comments
 (0)