prefer-use-prefix
Suggests renaming hooks to start with use
.
Example
❌ Bad:
// LINT: Hook names are expected to start with 'use'. Try renaming this declaration.
String myCustomHook() {
useMemoized(() {
...
}, []);
}
class MyWidget extends HookWidget {
// LINT: Hook names are expected to start with 'use'. Try renaming this declaration.
void _myPrivateHook() {
useMemoized(() {
...
}, keys);
}
}
✅ Good:
String useCustomHook() {
useMemoized(() {
...
}, []);
}
class MyWidget extends HookWidget {
void _usePrivateHook() {
useMemoized(() {
...
}, keys);
}
}