labelHooksPattern
Package: @autotracer/plugin-babel-react18 · Layer: Build · Type: string · Default: "^use[A-Z].*"
labelHooksPattern is a build configuration option passed to @autotracer/plugin-babel-react18 in your Babel config.
It decides which hook calls should have their returned values labeled automatically, based on the hook's name.
Most projects should leave this setting at its default.
Change it only when your project needs hook-name matching that is significantly different from the normal React-style useX pattern, or when you are deliberately turning pattern-based hook labeling off and relying only on explicit names in labelHooks.
If a hook name matches this pattern, the plugin injects labels for the variable names returned from that hook call.
Examples:
const todos = useSelector(...)can be labeled astodosconst [count, setCount] = useState(...)can be labeled ascountandsetCountconst { data, error } = useQuery(...)can be labeled asdataanderror
The hook name itself is not the label. The hook name only decides whether the returned values from that hook call should be labeled automatically.
If a hook name does not match this pattern, it can still be included when you list it explicitly in labelHooks.
An empty string disables pattern-based labeling, leaving only the exact hook names in labelHooks.
Read together with labelHooks when you are tuning automatic hook labeling.
Usage
{
"plugins": [
[
"@autotracer/plugin-babel-react18",
{ "labelHooksPattern": "^(use|with)[A-Z].*" }
]
]
}