Open artaommahe opened 1 month ago
Is this documented by Playwright to be named use
?
export type TestFixture<R, Args extends KeyValue> = (args: Args, use: (r: R) => Promise<void>, testInfo: TestInfo) => any;
also every example on this page https://playwright.dev/docs/test-fixtures#with-fixtures
And it's not just about playwright usage, it's more about preventing developers from using use
as a custom function name anywhere in the react codebase with this rule enabled
My grandpa is here blustering at me saying "it's kind of amazing that the decision to name a hook use
made it through review"
He sayin "Nobody thought about how the ESLint enforcement would effectively hijack an entire verb?" "No rule config to enable exceptions?"
I told him "Peepaw, just write your own ESLint rule? You don't have to use use"
(At that point, we looked at each other in unspoken agreement that having to now say 'use use' is a deeply unfortunate state of affairs)
And then he got quite loudly (when he gets loudly it gets very loud indeed) Lot of old timey swears and something about how he "doesn't have the time to fiddle with ESLint rules and nested glob patterns for the rest of his life"
He's a bit of a firecracker. I'm trying to reason with him because of course I can see both sides. But I thought I'd share since it's interesting feedback.
What if the rule logic were enhanced such that — when used as a an object method — it will only apply when the object is React
?
Something like:
React.use()
AnyOtherObj.use()
What if the rule logic were enhanced such that — when used as a an object method — it will only apply when the object is
React
?Something like:
Applies
React.use()
Does not apply
AnyOtherObj.use()
In fact, it is quite possible to determine whether that use
is from React
at static analysis level, and not only when used as a an object method. I've created a debug rule to prove it works.
React version: 18.3.1 eslint-plugin-react-hooks: 5.0.0
Steps To Reproduce
React Hook "use" is called in function "smth" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use".eslint[react-hooks/rules-of-hooks](https://reactjs.org/docs/hooks-rules.html)
We got this error with
use
function in the callback of playwright'stest.extend()
Link to code example: -
The current behavior
any custom
use
function is treated likeReact.use
The expected behavior
only
use()
function from react is linted by those rulesAdditional
There is no error with eslint-plugin-react-hooks v4.6.2