Skip to content

Commit 3ac6c6c

Browse files
committed
test: add test compatibility for combined v19 and v20 lint test
1 parent 4c064e0 commit 3ac6c6c

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

package-lock.json

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

src/index.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ const loadPlugin = test.macro<[keyof typeof versions]>({
3737
test(loadPlugin, '19.x');
3838
test(loadPlugin, '20.x');
3939

40+
/**
41+
* The type of the `RulesConfig` have changed in [commitlint v20.3.1](
42+
* https://github.com/conventional-changelog/commitlint/releases/tag/v20.3.1),
43+
* and are no longer compatible with those from v19. Specifically the types of
44+
* the `scope-case` and `scope-enum` rules have been changed to also accept a
45+
* rule object. While the individual versions are able process this test without
46+
* runtime or type errors, the combined signature causes type errors. To keep
47+
* the test, a relatively long one, the same for both versions, the type of the
48+
* rule config is cast.
49+
*/
4050
const lintUsingPluginRules = test.macro<[keyof typeof versions]>({
4151
async exec(t, version) {
4252
// eslint-disable-next-line @typescript-eslint/await-thenable
@@ -52,6 +62,7 @@ const lintUsingPluginRules = test.macro<[keyof typeof versions]>({
5262
for await (const config of configs) {
5363
const report = await versions[version].lint(
5464
'chore: basic commit message',
65+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
5566
{
5667
[rule]: [
5768
2,
@@ -60,7 +71,7 @@ const lintUsingPluginRules = test.macro<[keyof typeof versions]>({
6071
? async () => config.ruleOutcome
6172
: () => config.ruleOutcome,
6273
],
63-
},
74+
} as unknown as any,
6475
{plugins: {'function-rules': plugin}},
6576
);
6677

0 commit comments

Comments
 (0)