[lint] treat React.use() the same as use()#27769
Conversation
0fca22a to
790aab0
Compare
noahlemen
left a comment
There was a problem hiding this comment.
lgtm overall, but it looks like we also could be reusing this fn: https://github.com/facebook/react/blob/790aab0eaa1ec8d3df0bb57247cba4b9d6072a75/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js#L52-L59
should that one be updated to include the lowercase 'react'?
|
|
||
| function isUseIdentifier(node) { | ||
| return node.type === 'Identifier' && node.name === 'use'; | ||
| switch (node.type) { |
There was a problem hiding this comment.
Nit: elsewhere in the implementation, isReactFunction is used to detect React.useX. Might as well use it here too to ensure the behavior is consistent. https://github.com/facebook/react/blob/790aab0eaa1ec8d3df0bb57247cba4b9d6072a75/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js#L52-L60
Updates React from 2c338b16f to 0cdfef19b. ### React upstream changes - react/react#27821 - react/react#27820 - react/react#27818 - react/react#27819 - react/react#27817 - react/react#27703 - react/react#27796 - react/react#27811 - react/react#27804 - react/react#27807 - react/react#27805 - react/react#27792 - react/react#27788 - react/react#26852 - react/react#27790 - react/react#27786 - react/react#27785 - react/react#27783 - react/react#27784 - react/react#27769 - react/react#27766 - react/react#27701 - react/react#27732 - react/react#27740 - react/react#27767 - react/react#27768 - react/react#27765 - react/react#27759 - react/react#27579 - react/react#27709 - react/react#27734 - react/react#27739 - react/react#27717 - react/react#27583 - react/react#27713 Closes NEXT-1887
We should probably treat `React.use()` the same as `use()` to allow it within loops and conditionals. Ideally this would implement a test that `React` is imported or required from `'react'`, but we don't otherwise implement such a test.
We should probably treat `React.use()` the same as `use()` to allow it within loops and conditionals. Ideally this would implement a test that `React` is imported or required from `'react'`, but we don't otherwise implement such a test. DiffTrain build for commit 640cceb.
##### [v5.0.0](https://github.com/facebook/react/blob/HEAD/packages/eslint-plugin-react-hooks/CHANGELOG.md#500) - **New Violations:** Component names now need to start with an uppercase letter instead of a non-lowercase letter. This means `_Button` or `_component` are no longer valid. ([@kassens](https://github.com/kassens)) in [#25162](react/react#25162) <!----> - Consider dispatch from `useActionState` stable. ([@eps1lon](https://github.com/eps1lon) in [#29665](react/react#29665)) - Add support for ESLint v9. ([@eps1lon](https://github.com/eps1lon) in [#28773](react/react#28773)) - Accept `as` expression in callback. ([@StyleShit](https://github.com/StyleShit) in [#28202](react/react#28202)) - Accept `as` expressions in deps array. ([@StyleShit](https://github.com/StyleShit) in [#28189](react/react#28189)) - Treat `React.use()` the same as `use()`. ([@kassens](https://github.com/kassens) in [#27769](react/react#27769)) - Move `use()` lint to non-experimental. ([@kassens](https://github.com/kassens) in [#27768](react/react#27768)) - Support Flow `as` expressions. ([@cpojer](https://github.com/cpojer) in [#27590](react/react#27590)) - Allow `useEffect(fn, undefined)`. ([@kassens](https://github.com/kassens) in [#27525](react/react#27525)) - Disallow hooks in async functions. ([@acdlite](https://github.com/acdlite) in [#27045](react/react#27045)) - Rename experimental `useEvent` to `useEffectEvent`. ([@sebmarkbage](https://github.com/sebmarkbage) in [#25881](react/react#25881)) - Lint for presence of `useEvent` functions in dependency lists. ([@poteto](https://github.com/poteto) in [#25512](react/react#25512)) - Check `useEvent` references instead. ([@poteto](https://github.com/poteto) in [#25319](react/react#25319)) - Update `RulesOfHooks` with `useEvent` rules. ([@poteto](https://github.com/poteto) in [#25285](react/react#25285))
We should probably treat
React.use()the same asuse()to allow it within loops and conditionals.Ideally this would implement a test that
Reactis imported or required from'react', but we don't otherwise implement such a test.