UNPKG

agentsqripts

Version:

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

22 lines (18 loc) 670 B
/** * @file Check if component is large * @description Single responsibility: Determine if a React component is large enough to benefit from memoization */ /** * Check if component is large enough to warrant optimization */ function isLargeComponent(lines, startIndex) { let braceCount = 0; let lineCount = 0; for (let i = startIndex; i < lines.length && lineCount < 50; i++) { braceCount += (lines[i].match(/{/g) || []).length - (lines[i].match(/}/g) || []).length; lineCount++; if (braceCount === 0 && lineCount > 5) break; } return lineCount > 20; // Component with >20 lines is considered large } module.exports = isLargeComponent;