get-call-expression-arguments-text.js 656 B

123456789101112131415161718192021
  1. 'use strict';
  2. const {isOpeningParenToken} = require('@eslint-community/eslint-utils');
  3. /**
  4. Get the text of the arguments list of `CallExpression`.
  5. @param {Node} node - The `CallExpression` node.
  6. @param {SourceCode} sourceCode - The source code object.
  7. @returns {string}
  8. */
  9. const getCallExpressionArgumentsText = (node, sourceCode) => {
  10. const openingParenthesisToken = sourceCode.getTokenAfter(node.callee, isOpeningParenToken);
  11. const closingParenthesisToken = sourceCode.getLastToken(node);
  12. return sourceCode.text.slice(
  13. openingParenthesisToken.range[1],
  14. closingParenthesisToken.range[0],
  15. );
  16. };
  17. module.exports = getCallExpressionArgumentsText;