diff --git a/@commitlint/load/src/load.test.ts b/@commitlint/load/src/load.test.ts index 824c3e130e..3bafff3438 100644 --- a/@commitlint/load/src/load.test.ts +++ b/@commitlint/load/src/load.test.ts @@ -32,6 +32,22 @@ test('uses seed as configured', async () => { expect(actual.rules['body-case']).toStrictEqual([1, 'never', 'camel-case']); }); +test('rules should be loaded from local', async () => { + const actual = await load({ + rules: { + direct: [1, 'never', 'foo'], + func: () => [1, 'never', 'foo'], + async: async () => [1, 'never', 'foo'], + promise: () => Promise.resolve([1, 'never', 'foo']), + }, + }); + + expect(actual.rules['direct']).toStrictEqual([1, 'never', 'foo']); + expect(actual.rules['func']).toStrictEqual([1, 'never', 'foo']); + expect(actual.rules['async']).toStrictEqual([1, 'never', 'foo']); + expect(actual.rules['promise']).toStrictEqual([1, 'never', 'foo']); +}); + test('rules should be loaded from relative config file', async () => { const file = 'config/commitlint.config.js'; const cwd = await gitBootstrap('fixtures/specify-config-file'); diff --git a/@commitlint/types/src/rules.ts b/@commitlint/types/src/rules.ts index 739c1f61ab..d0df4d0402 100644 --- a/@commitlint/types/src/rules.ts +++ b/@commitlint/types/src/rules.ts @@ -65,7 +65,7 @@ export enum RuleConfigQuality { export type QualifiedRuleConfig = | (() => RuleConfigTuple) - | (() => RuleConfigTuple>) + | (() => Promise>) | RuleConfigTuple; export type RuleConfig<