agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
34 lines (28 loc) • 1.08 kB
JavaScript
/**
* @file Detect React-specific bugs
* @description Single responsibility: Main orchestrator for React bug detection
*/
const detectMissingKeys = require('./detect/detectMissingKeys');
const detectHooksViolations = require('./detect/detectHooksViolations');
const detectStateInRender = require('./detect/detectStateInRender');
const detectMissingDependencies = require('./detect/detectMissingDependencies');
/**
* Detect React-specific bugs
* @param {Object} ast - AST tree
* @param {string} filePath - File path
* @param {string} content - File content
* @returns {Array} Detected bugs
*/
function detectReactPatterns(ast, filePath, content) {
const bugs = [];
// Quick check if this is a React file
if (!content.includes('react') && !content.includes('jsx')) {
return bugs;
}
bugs.push(...detectMissingKeys(ast, filePath));
bugs.push(...detectHooksViolations(ast, filePath));
bugs.push(...detectStateInRender(ast, filePath));
bugs.push(...detectMissingDependencies(ast, filePath));
return bugs;
}
module.exports = detectReactPatterns;