Skip to content

Commit

Permalink
fix(types): fix signature of QualifiedRuleConfig for async configurat…
Browse files Browse the repository at this point in the history
…ions (#2868) (#2869)

Co-authored-by: Alessandro Bianco <[email protected]>
  • Loading branch information
alebianco and alebianco-doxee authored Nov 16, 2021
1 parent 8a8384f commit c7f355b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions @commitlint/load/src/load.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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');
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/types/src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export enum RuleConfigQuality {

export type QualifiedRuleConfig<T> =
| (() => RuleConfigTuple<T>)
| (() => RuleConfigTuple<Promise<T>>)
| (() => Promise<RuleConfigTuple<T>>)
| RuleConfigTuple<T>;

export type RuleConfig<
Expand Down

0 comments on commit c7f355b

Please sign in to comment.