UNPKG

agentsqripts

Version:

Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems

39 lines (32 loc) 975 B
/** * @file Check if AST node is a string operation * @description Single responsibility: Determine if a node represents a string operation */ /** * Check if node is a string operation * @param {Object} node - AST node * @returns {boolean} True if node is a string operation */ function isStringOperation(node) { if (!node) return false; // Direct string literal if (node.type === 'Literal' && typeof node.value === 'string') { return true; } // Template literal if (node.type === 'TemplateLiteral') { return true; } // Binary expression with + if (node.type === 'BinaryExpression' && node.operator === '+') { return isStringOperation(node.left) || isStringOperation(node.right); } // Call to toString() if (node.type === 'CallExpression' && node.callee.type === 'MemberExpression' && node.callee.property.name === 'toString') { return true; } return false; } module.exports = isStringOperation;