Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed May 7, 2019
1 parent e8780d2 commit cf76a40
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions lib/rules/jsx-curly-newline.js
Expand Up @@ -169,33 +169,19 @@ module.exports = {
}
}

/**
* Gets the left curly and right curly tokens of a node.
* @param {ASTNode} node The JSXExpressionContainer node.
* @returns {{leftCurly: Object, rightCurly: Object}} An object contaning left and right curly tokens.
*/
function getCurlyTokens(node) {
return {
leftCurly: sourceCode.getFirstToken(node),
rightCurly: sourceCode.getLastToken(node)
};
}

/**
* Validates the curlys for a JSXExpressionContainer node.
* @param {ASTNode} node The JSXExpressionContainer node.
* @returns {void}
*/
function validateNode(node) {
validateCurlys(getCurlyTokens(node), node.expression);
}

// ----------------------------------------------------------------------
// Public
// ----------------------------------------------------------------------

return {
JSXExpressionContainer: validateNode
JSXExpressionContainer(node) {
const curlyTokens = {
leftCurly: sourceCode.getFirstToken(node),
rightCurly: sourceCode.getLastToken(node)
};
validateCurlys(curlyTokens, node.expression);
}
};
}
};

0 comments on commit cf76a40

Please sign in to comment.