UNPKG

agentsqripts

Version:

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

25 lines (21 loc) 780 B
/** * @file Check if node is inside specific parent type * @description Single responsibility: Check if AST node is inside a specific type of parent */ /** * Check if a node is inside a specific type of parent * @param {Object} node - Current AST node * @param {Array} ancestors - Array of ancestor nodes * @param {string|Array} parentTypes - Parent type(s) to check for * @returns {boolean} True if node is inside specified parent type */ function isInsideParent(node, ancestors, parentTypes) { if (!ancestors || !Array.isArray(ancestors)) { return false; } const types = Array.isArray(parentTypes) ? parentTypes : [parentTypes]; return ancestors.some(ancestor => ancestor && types.includes(ancestor.type) ); } module.exports = isInsideParent;