[lint] treat React.use() the same as use() (#27769)

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.
This commit is contained in:
Jan Kassens
2023-12-01 15:02:11 -05:00
committed by GitHub
parent d7b45ec9b7
commit 640ccebb7d
2 changed files with 4 additions and 1 deletions
@@ -489,9 +489,12 @@ const tests = {
},
{
code: normalizeIndent`
import * as React from 'react';
function App() {
if (shouldShowText) {
const text = use(query);
const data = React.use(thing);
const data2 = react.use(thing2);
return <Text text={text} />
}
return <Text text={shouldFetchBackupText ? use(backupQuery) : "Nothing to see here"} />
@@ -108,7 +108,7 @@ function isUseEffectEventIdentifier(node) {
}
function isUseIdentifier(node) {
return node.type === 'Identifier' && node.name === 'use';
return isReactFunction(node, 'use');
}
export default {