Skip to content

Commit 8382581

Browse files
authored
[ESLint] Add test for rejected useId in async Components (#31208)
1 parent c7c68ef commit 8382581

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js

+28
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,34 @@ const tests = {
11291129
`,
11301130
errors: [asyncComponentHookError('useState')],
11311131
},
1132+
{
1133+
code: normalizeIndent`
1134+
async function Page() {
1135+
useId();
1136+
React.useId();
1137+
}
1138+
`,
1139+
errors: [
1140+
asyncComponentHookError('useId'),
1141+
asyncComponentHookError('React.useId'),
1142+
],
1143+
},
1144+
{
1145+
code: normalizeIndent`
1146+
async function useAsyncHook() {
1147+
useId();
1148+
}
1149+
`,
1150+
errors: [asyncComponentHookError('useId')],
1151+
},
1152+
{
1153+
code: normalizeIndent`
1154+
async function notAHook() {
1155+
useId();
1156+
}
1157+
`,
1158+
errors: [functionError('useId', 'notAHook')],
1159+
},
11321160
{
11331161
code: normalizeIndent`
11341162
Hook.use();

0 commit comments

Comments
 (0)