Skip to content

Commit 40ac266

Browse files
escapedcatclaude
andcommitted
fix: update dependency conventional-changelog-angular to v9
v9 ships its own typings: createPreset() is typed as {} and the named parser export was dropped (still present at runtime). Read the parser options via createPreset().parser in the affected tests and drop the now-unused @ts-expect-error directives. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 41d900a commit 40ac266

8 files changed

Lines changed: 37 additions & 31 deletions

File tree

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

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

@commitlint/parse/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"dependencies": {
3737
"@commitlint/types": "workspace:^",
38-
"conventional-changelog-angular": "^8.2.0",
38+
"conventional-changelog-angular": "^9.0.0",
3939
"conventional-commits-parser": "^7.0.0"
4040
},
4141
"devDependencies": {

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { test, expect } from "vitest";
2+
import type { ParserOptions } from "conventional-commits-parser";
3+
24
import parse from "./index.js";
35

6+
// conventional-changelog-angular@>=9 exposes a single default `createPreset()`
7+
// whose return is typed as `{}`; the parser options live under `.parser`.
8+
const angularParserOpts = async (): Promise<ParserOptions> => {
9+
const { default: createPreset } = await import("conventional-changelog-angular");
10+
const { parser } = (await createPreset()) as { parser: ParserOptions };
11+
return parser;
12+
};
13+
414
test("throws when called without params", async () => {
515
await expect((parse as any)()).rejects.toThrow("Expected a raw commit");
616
});
@@ -143,10 +153,8 @@ test("supports scopes with / and empty parserOpts", async () => {
143153

144154
test("ignores comments", async () => {
145155
const message = "type(some/scope): subject\n# some comment";
146-
// @ts-expect-error -- no typings
147-
const changelogOpts = await import("conventional-changelog-angular");
148156
const opts = {
149-
...changelogOpts.parser,
157+
...(await angularParserOpts()),
150158
commentChar: "#",
151159
};
152160
const actual = await parse(message, undefined, opts);
@@ -158,9 +166,7 @@ test("ignores comments", async () => {
158166

159167
test("parses inline references in subject and body", async () => {
160168
const message = "type(some/scope): subject #reference\n\nthings #reference";
161-
// @ts-expect-error -- no typings
162-
const changelogOpts = await import("conventional-changelog-angular");
163-
const actual = await parse(message, undefined, changelogOpts.parser);
169+
const actual = await parse(message, undefined, await angularParserOpts());
164170

165171
expect(actual.subject).toBe("subject #reference");
166172
expect(actual.body).toBe("");
@@ -186,10 +192,8 @@ test("parses inline references in subject and body", async () => {
186192

187193
test("filters comment lines when commentChar is set", async () => {
188194
const message = "type(scope): subject\n# this is a comment\nbody content";
189-
// @ts-expect-error -- no typings
190-
const changelogOpts = await import("conventional-changelog-angular");
191195
const opts = {
192-
...changelogOpts.parser,
196+
...(await angularParserOpts()),
193197
commentChar: "#",
194198
};
195199
const actual = await parse(message, undefined, opts);
@@ -235,11 +239,9 @@ test("allows separating -side nodes- by setting parserOpts.fieldPattern", async
235239

236240
test("parses references leading subject", async () => {
237241
const message = "#1 some subject";
238-
// @ts-expect-error -- no typings
239-
const opts = await import("conventional-changelog-angular");
240242
const {
241243
references: [actual],
242-
} = await parse(message, undefined, opts);
244+
} = await parse(message, undefined, await angularParserOpts());
243245

244246
expect(actual.issue).toBe("1");
245247
});

@commitlint/parse/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { Parser } from "@commitlint/types";
22

33
import { type Commit, type ParserOptions, CommitParser } from "conventional-commits-parser";
4-
// @ts-expect-error -- no typings
54
import defaultChangelogOpts from "conventional-changelog-angular";
65

76
const defaultParser: Parser = (message, options) => {
@@ -21,7 +20,12 @@ export async function parse(
2120
parser: Parser = defaultParser,
2221
parserOpts?: ParserOptions,
2322
): Promise<Commit> {
24-
const preset = await defaultChangelogOpts();
23+
// conventional-changelog-angular@>=9 ships typings that declare the preset as
24+
// `{}`; the parser options live under `.parser` at runtime.
25+
const preset = (await defaultChangelogOpts()) as {
26+
parser?: ParserOptions;
27+
parserOpts?: ParserOptions;
28+
};
2529
const defaultOpts = preset.parser || preset.parserOpts;
2630
// Support user-provided parser options passed either flat or nested under a 'parser' key
2731
const userOpts = (parserOpts as any)?.parser || parserOpts || {};

@commitlint/rules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@commitlint/test": "workspace:^",
4545
"@commitlint/utils": "workspace:^",
4646
"@types/node": "^22.0.0",
47-
"conventional-changelog-angular": "^8.2.0",
47+
"conventional-changelog-angular": "^9.0.0",
4848
"conventional-commits-parser": "^7.0.0"
4949
},
5050
"engines": {

@commitlint/rules/src/references-empty.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test, expect } from "vitest";
22
import parse from "@commitlint/parse";
33
import { referencesEmpty } from "./references-empty.js";
44

5-
// @ts-expect-error -- no typings
5+
import type { ParserOptions } from "conventional-commits-parser";
66
import preset from "conventional-changelog-angular";
77

88
const messages = {
@@ -14,7 +14,7 @@ const messages = {
1414
};
1515

1616
const opts = (async () => {
17-
const o = await preset();
17+
const o = (await preset()) as { parser: ParserOptions };
1818
o.parser.commentChar = "#";
1919
return o;
2020
})();

@commitlint/rules/src/subject-exclamation-mark.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { test, expect } from "vitest";
22
import parse from "@commitlint/parse";
3-
// @ts-expect-error -- no typings
3+
import type { ParserOptions } from "conventional-commits-parser";
44
import preset from "conventional-changelog-angular";
55

66
import { subjectExclamationMark } from "./subject-exclamation-mark.js";
77

88
const parseMessage = async (str: string) => {
9-
const { parserOpts } = await preset();
10-
return parse(str, undefined, parserOpts);
9+
const { parser } = (await preset()) as { parser: ParserOptions };
10+
return parse(str, undefined, parser);
1111
};
1212

1313
const messages = {

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)