Skip to content

Commit

Permalink
refactor(function-rule): fail fast by checking potential failures and…
Browse files Browse the repository at this point in the history
… quick returns first
  • Loading branch information
jdbruijn committed Apr 17, 2022
1 parent 8e09a33 commit c303b72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/function-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const functionRule: Rule<FunctionRule> = (
when: RuleConfigCondition = 'always',
value: FunctionRule | undefined,
) => {
if (typeof value === 'function') {
return value(parsed, when);
if (typeof value !== 'function') {
throw new Error('Not a valid function!');
}

throw new Error('Not a valid function!');
return value(parsed, when);
};

export default functionRule;
Expand Down

0 comments on commit c303b72

Please sign in to comment.