UNPKG

agentsqripts

Version:

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

19 lines (17 loc) 584 B
/** * @file Check if code is inside React component * @description Single responsibility: Determine if a line of code is within a React component */ /** * Check if we're inside a React component */ function isInsideComponent(lines, lineIndex) { // Look backwards for component declaration for (let i = lineIndex - 1; i >= Math.max(0, lineIndex - 50); i--) { if (/function\s+\w+|const\s+\w+\s*=.*=>|class\s+\w+/.test(lines[i])) { return /[A-Z]/.test(lines[i]); // Component names start with uppercase } } return false; } module.exports = isInsideComponent;