@samitouri / QOS-React / commits / 8382581446

[ESLint] Add test for rejected `useId` in async Components (#31208)

Sebastian "Sebbie" Silbermann committed Oct 15, 2024 at 17:17 UTC 838258144652ab2ef0cbe54d03e9bdd454348d48
1 file changed +28
packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
+28
@@ -1129,6 +1129,34 @@ const tests = {
1129 `,
1130 errors: [asyncComponentHookError('useState')],
1131 },
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 + },
1160 {
1161 code: normalizeIndent`
1162 Hook.use();