Skip to content

Commit c7f355b

Browse files
fix(types): fix signature of QualifiedRuleConfig for async configurations (#2868) (#2869)
Co-authored-by: Alessandro Bianco <[email protected]>
1 parent 8a8384f commit c7f355b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

@commitlint/load/src/load.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ test('uses seed as configured', async () => {
3333
expect(actual.rules['body-case']).toStrictEqual([1, 'never', 'camel-case']);
3434
});
3535

36+
test('rules should be loaded from local', async () => {
37+
const actual = await load({
38+
rules: {
39+
direct: [1, 'never', 'foo'],
40+
func: () => [1, 'never', 'foo'],
41+
async: async () => [1, 'never', 'foo'],
42+
promise: () => Promise.resolve([1, 'never', 'foo']),
43+
},
44+
});
45+
46+
expect(actual.rules['direct']).toStrictEqual([1, 'never', 'foo']);
47+
expect(actual.rules['func']).toStrictEqual([1, 'never', 'foo']);
48+
expect(actual.rules['async']).toStrictEqual([1, 'never', 'foo']);
49+
expect(actual.rules['promise']).toStrictEqual([1, 'never', 'foo']);
50+
});
51+
3652
test('rules should be loaded from relative config file', async () => {
3753
const file = 'config/commitlint.config.js';
3854
const cwd = await gitBootstrap('fixtures/specify-config-file');

@commitlint/types/src/rules.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export enum RuleConfigQuality {
6565

6666
export type QualifiedRuleConfig<T> =
6767
| (() => RuleConfigTuple<T>)
68-
| (() => RuleConfigTuple<Promise<T>>)
68+
| (() => Promise<RuleConfigTuple<T>>)
6969
| RuleConfigTuple<T>;
7070

7171
export type RuleConfig<

0 commit comments

Comments
 (0)