katoikia-app/web-ui/web-react/node_modules/eslint-plugin-react/lib/util/getTokenBeforeClosingBracke...

17 lines
413 B
JavaScript
Raw Normal View History

2022-07-06 04:15:11 +00:00
'use strict';
/**
* Find the token before the closing bracket.
* @param {ASTNode} node - The JSX element node.
* @returns {Token} The token before the closing bracket.
*/
function getTokenBeforeClosingBracket(node) {
const attributes = node.attributes;
if (attributes.length === 0) {
return node.name;
}
return attributes[attributes.length - 1];
}
module.exports = getTokenBeforeClosingBracket;