getTokenBeforeClosingBracket.js 413 B

12345678910111213141516
  1. 'use strict';
  2. /**
  3. * Find the token before the closing bracket.
  4. * @param {ASTNode} node - The JSX element node.
  5. * @returns {Token} The token before the closing bracket.
  6. */
  7. function getTokenBeforeClosingBracket(node) {
  8. const attributes = node.attributes;
  9. if (attributes.length === 0) {
  10. return node.name;
  11. }
  12. return attributes[attributes.length - 1];
  13. }
  14. module.exports = getTokenBeforeClosingBracket;