Skip to content

Commit e7918ec

Browse files
committed
fix(rule): final resolve export rule issue
1 parent 5115ea6 commit e7918ec

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import { default as scopePattern } from "./rules/scope-pattern/index.js";
1+
import { type Plugin } from '@commitlint/types';
2+
import { default as scopePattern } from "./rules/scope-pattern";
23

3-
export const rules = {
4-
'scope-pattern': scopePattern
4+
export const rules: Plugin['rules'] = {
5+
'commitlint-plugin-prevenger/scope-pattern': scopePattern,
6+
};
7+
8+
export default {
9+
rules,
510
};

src/rules/scope-pattern/index.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,43 @@ describe('scope-pattern', () => {
1919
} as Commit
2020
};
2121

22-
it('passes when scope matches pattern and "always" is used', () => {
23-
const result = ruleFn(createCommit('core'), 'always', ['^core$']);
22+
it('passes when scope matches pattern and "always" is used', async () => {
23+
const result = await ruleFn(createCommit('core'), 'always', ['^core$']);
2424
expect(result).toEqual([true, '']);
2525
});
2626

27-
it('fails when scope does not match pattern and "always" is used', () => {
28-
const result = ruleFn(createCommit('utils'), 'always', ['^core$']);
27+
it('fails when scope does not match pattern and "always" is used', async () => {
28+
const result = await ruleFn(createCommit('utils'), 'always', ['^core$']);
2929
expect(result).toEqual([false, 'scope must match pattern: ^core$']);
3030
});
3131

32-
it('passes when scope does not match pattern and "never" is used', () => {
33-
const result = ruleFn(createCommit('utils'), 'never', ['^core$']);
32+
it('passes when scope does not match pattern and "never" is used', async () => {
33+
const result = await ruleFn(createCommit('utils'), 'never', ['^core$']);
3434
expect(result).toEqual([true, '']);
3535
});
3636

37-
it('fails when scope matches pattern and "never" is used', () => {
38-
const result = ruleFn(createCommit('core'), 'never', ['^core$']);
37+
it('fails when scope matches pattern and "never" is used', async () => {
38+
const result = await ruleFn(createCommit('core'), 'never', ['^core$']);
3939
expect(result).toEqual([false, 'scope must not match pattern: ^core$']);
4040
});
4141

42-
it('passes when scope is undefined', () => {
43-
const result = ruleFn(createCommit(undefined), 'always', ['^core$']);
42+
it('passes when scope is undefined', async () => {
43+
const result = await ruleFn(createCommit(undefined), 'always', ['^core$']);
4444
expect(result).toEqual([true, '']);
4545
});
4646

47-
it('uses default "when" and "value" when not provided', () => {
48-
const result = ruleFn(createCommit('anyscope'));
47+
it('uses default "when" and "value" when not provided', async () => {
48+
const result = await ruleFn(createCommit('anyscope'));
4949
expect(result).toEqual([true, '']);
5050
});
5151

52-
it('uses default "value" when only "when" is provided', () => {
53-
const result = ruleFn(createCommit('anyscope'), 'always');
52+
it('uses default "value" when only "when" is provided', async () => {
53+
const result = await ruleFn(createCommit('anyscope'), 'always');
5454
expect(result).toEqual([true, '']);
5555
});
5656

57-
it('uses custom message when provided and fails', () => {
58-
const result = ruleFn(createCommit('utils'), 'always', ['^core$', 'Custom message']);
57+
it('uses custom message when provided and fails', async () => {
58+
const result = await ruleFn(createCommit('utils'), 'always', ['^core$', 'Custom message']);
5959
expect(result).toEqual([false, 'Custom message']);
6060
});
6161
});

src/rules/scope-pattern/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Rule } from '@commitlint/types';
22
import type { Commit } from 'conventional-commits-parser';
33

4-
const rule: Rule = (
4+
const rule: Rule = async (
55
parsed: Commit,
66
when: 'always' | 'never' = 'always',
77
value: [string, string?] = ['']

0 commit comments

Comments
 (0)