Skip to content

Commit

Permalink
clean up function logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Stramel authored and stramel committed Feb 20, 2019
1 parent ad73985 commit 8e6ff17
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/rules/guard-super-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,13 @@ const rule: Rule.RuleModule = {
return isUnguardedSuperHook(node.consequent, hook);
} else if (
node.type === 'BlockStatement' &&
node.body.some(checkNodeForUnguardedSuperHook(hook))
node.body.some((n) => isUnguardedSuperHook(n, hook))
) {
return true;
}
return false;
}

/**
* Allows for currying the hook to the isUnguardedSuperHook call
* @param {string} hook hook to test
* @return {function}
*/
function checkNodeForUnguardedSuperHook(
hook: string
): (n: ESTree.Node) => boolean {
return (node: ESTree.Node) => isUnguardedSuperHook(node, hook);
}

//----------------------------------------------------------------------
// Public
//----------------------------------------------------------------------
Expand Down Expand Up @@ -153,10 +142,7 @@ const rule: Rule.RuleModule = {
if (
node.key.type === 'Identifier' &&
node.value.type === 'FunctionExpression' &&
node.value.body.type === 'BlockStatement' &&
node.value.body.body.some(
checkNodeForUnguardedSuperHook(node.key.name)
)
isUnguardedSuperHook(node.value.body, node.key.name)
) {
context.report({
node: errNode,
Expand Down

0 comments on commit 8e6ff17

Please sign in to comment.