Skip to content

Commit c303b72

Browse files
committed
refactor(function-rule): fail fast by checking potential failures and quick returns first
1 parent 8e09a33 commit c303b72

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/function-rule.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ const functionRule: Rule<FunctionRule> = (
1515
when: RuleConfigCondition = 'always',
1616
value: FunctionRule | undefined,
1717
) => {
18-
if (typeof value === 'function') {
19-
return value(parsed, when);
18+
if (typeof value !== 'function') {
19+
throw new Error('Not a valid function!');
2020
}
2121

22-
throw new Error('Not a valid function!');
22+
return value(parsed, when);
2323
};
2424

2525
export default functionRule;

0 commit comments

Comments
 (0)