Bug: Rules of hooks lint rule doesn't catch some uses of custom hooks

This issue has been created since 2022-11-22.

React version: Latest

Steps To Reproduce

import * as hooks from "bundle-o-hooks";

function MyComponent({x}) {
    if (x > 1) {
        const something = hooks.useAHook(); // not flagged
     }
}

The current behavior

The current hook-matching rules only counts bare identifiers or member expressions where the target object is in Pascal case

https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js#L25-L44

The expected behavior

I'd like the pascal case restriction to be removed, or at least have the docs updated, as neither the existing docs nor the beta docs mention this additional rule for what gets considered a hook by the linter.

eps1lon wrote this answer on 2022-11-24

Duplicate of #25472

More Details About Repo
Owner Name facebook
Repo Name react
Full Name facebook/react
Language JavaScript
Created Date 2013-05-24
Updated Date 2022-12-01
Star Count 198482
Watcher Count 6646
Fork Count 41196
Issue Count 1106

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Compilation on Windows (PowerShell) 14 2022-03-14 2022-10-07
Substitution in destination URL? 4 2016-10-28 2022-07-16
CSV Import results in "PHP Notice – yii\base\ErrorException – Undefined index: redirectMatchType" 2 2021-08-20 2022-03-25
craft.retour.getHttpStatus gives 200 after 301 redirect 1 2021-11-12 2022-11-28
Trace logging isn't working correctly for in code config 6 2021-07-21 2022-11-07
the buffer name after embark-export is too long ,it is not friendly for tab-line-mode user 9 2022-04-19 2022-12-01
Wrong handling of 4-bytes length buffers 0 2021-06-22 2022-08-21
Adding onion removes : from http://somesite.onion and results in 503 0 2021-04-25 2022-05-12
TypeError: Factory is not a constructor 1 2021-12-19 2022-11-05
Trakt official lists raise : 'TraktList' object has no attribute 'trakt_items' 41 2022-11-01 2022-11-09
PermissionError: [Errno 13] Permission denied: 'C:\\Windows\\System32\\drivers\\etc\\hosts' 3 2021-11-26 2022-11-22
Tiles not loading consistently 2 2021-11-23 2022-12-01
AutoAttack not working properly 1 2022-02-20 2022-10-27
Calendar widget size a little too big? 2 2018-08-18 2022-10-05
Failed to add UI from resource 4 2021-10-07 2022-10-05
[V2] Window Toolbar can be customized 2 2021-11-02 2022-10-07
A non well formed numeric value encountered 1 2021-01-19 2022-11-20
Nota Técnica 2022.001 - v.1.00 - Publicada em 31/05/2022 6 2022-05-31 2022-11-28
`!` not working with screen variants 1 2021-08-23 2022-11-13
对接蓝奏云使用一段时间后,未修改任何东西,原本可用的显示报错 4 2022-05-06 2022-11-01
Make Elasticsearch optional 3 2021-02-08 2022-11-12
Hello, please implement such websites 1 2022-03-14 2022-11-17
Issue with UserHasPerms 0 2022-09-06 2022-11-24
Add option for context timeout. 5 2021-01-13 2022-10-07
Broken link in README.md 0 2022-11-10 2022-11-22
wrong version released 2 2021-09-30 2022-11-03
Why is -UseModernBuildSystem=0 added by default (fixed)? 5 2021-03-19 2022-11-30
SimpleMDE maintenance status 52 2018-06-05 2022-11-30
Dhcp server with wrong dns 1 2021-11-28 2022-11-23
lack of child process support 2 2022-10-14 2022-11-23
2.4 pre-installer does not source nix after reboot in zsh 7 2021-10-19 2022-11-01
[Scholomance] Kirtonos the Herald is unattackable 1 2021-10-31 2022-10-31
[Spellcheck] no longer working 1 2022-03-31 2022-10-24
Add support for application start-up to detect if windows exists and open a new tab in the existing window 0 2022-01-17 2022-09-13
Add a helper to print setup/machine details 2 2022-11-09 2022-11-26
refactor: Move registries into their own module 0 2022-05-13 2022-11-12
Deploying plugin with files that are not in git 8 2019-11-24 2022-10-16
Stuck at “Using ~/.cache/torch_extensions as PyTorch extensions root...” 0 2021-07-09 2022-09-26
Context menu for the time series chart to get to the WPT result 1 2020-01-08 2022-09-27
TargetFile validation on Extract 0 2022-08-15 2022-11-18
sqlpackage.exe DropObjectsNotInSource missing exclude for Schema 1 2022-08-23 2022-11-18
Manually materialize the view 1 2014-03-11 2022-11-07
Add nano.community as a block explorer 0 2021-09-05 2022-11-24
preview header for background should be transparent 1 2020-01-22 2022-11-30
Extension causes high cpu load 0 2020-11-14 2022-10-20
Trouble getting car package installed, thus can't knit 0 2022-09-06 2022-11-21
Python errors with `error=TRUE` fails to knit 3 2022-08-22 2022-11-21
支持通过manager关闭PPS 1 2021-11-15 2022-01-19
Setting message to empty string breaks formatting with pino-pretty 5 2021-03-20 2022-11-22
What is the performant and concise way to remove values from a HeaderMap containing duplicate HeaderName's? 4 2020-07-16 2022-05-13