Files
low-code-react-app-b/codeql/custom-queries/queries/ComponentCustomHookUsage.ql
2026-01-19 09:34:42 +00:00

21 lines
574 B
Plaintext

/**
* @name Custom hook usage in components
* @description Flags calls to hooks (useX) inside src/components files to guide hook extraction.
* @kind problem
* @severity warning
* @id custom/component-custom-hook-usage
*/
import javascript
predicate isComponentFile(File f) {
f.getRelativePath().regexpMatch("^(src/)?components/.*\\.tsx$")
}
from CallExpr call, File f, VarRef ref
where
f = call.getFile() and
isComponentFile(f) and
ref = call.getCallee() and
ref.getName().regexpMatch("^use[A-Z].*")
select call, "Hook call in component: " + ref.getName()