securityos/node_modules/eslint-plugin-unicorn/rules/utils/get-call-expression-argumen...

22 lines
656 B
JavaScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
'use strict';
const {isOpeningParenToken} = require('@eslint-community/eslint-utils');
/**
Get the text of the arguments list of `CallExpression`.
@param {Node} node - The `CallExpression` node.
@param {SourceCode} sourceCode - The source code object.
@returns {string}
*/
const getCallExpressionArgumentsText = (node, sourceCode) => {
const openingParenthesisToken = sourceCode.getTokenAfter(node.callee, isOpeningParenToken);
const closingParenthesisToken = sourceCode.getLastToken(node);
return sourceCode.text.slice(
openingParenthesisToken.range[1],
closingParenthesisToken.range[0],
);
};
module.exports = getCallExpressionArgumentsText;