Skip to content

Commit 82047c3

Browse files
committed
fix(function-rule): return success if the function rule is undefined
1 parent 84e415f commit 82047c3

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/function-rule.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test('returns a value from an implementation function', (t) => {
2929
t.deepEqual(returnValue, ruleOutcome);
3030
});
3131

32-
test.failing('returns successful for an undefined implementation', (t) => {
32+
test('returns successful for an undefined implementation', (t) => {
3333
const returnValue = functionRule({} as Commit, 'always', undefined);
3434
t.deepEqual(returnValue, [true]);
3535
});

src/function-rule.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ type FunctionRule = (
1313
const functionRule: Rule<FunctionRule> = (
1414
parsed: Commit,
1515
when: RuleConfigCondition = 'always',
16-
value: FunctionRule | undefined,
16+
functionRule: FunctionRule | undefined,
1717
) => {
18-
if (typeof value !== 'function') {
18+
if (functionRule === undefined) {
19+
return [true];
20+
}
21+
if (typeof functionRule !== 'function') {
1922
throw new Error('Not a valid function!');
2023
}
2124

22-
return value(parsed, when);
25+
return functionRule(parsed, when);
2326
};
2427

2528
export default functionRule;

0 commit comments

Comments
 (0)